Browse Source

fix sign casting

master
Odilitime 5 years ago
parent
commit
7d0bda824b
  1. 10
      src/graphics/components/ImageComponent.cpp

10
src/graphics/components/ImageComponent.cpp

@ -31,7 +31,7 @@ for (int py = 0; py < 1024; py++) { @@ -31,7 +31,7 @@ for (int py = 0; py < 1024; py++) {
if (!anime) {
std::cout << "Can't set up image component, couldn't read " << filename << std::endl;
}
int loadWidth = anime->width, loadHeight = anime->height;
unsigned int loadWidth = anime->width, loadHeight = anime->height;
if (loadWidth > 1024 || loadHeight > 1024) {
std::cout << "Can't set up image component, " << filename << " resolution too large " << std::endl;
loadWidth = 1024;
@ -42,10 +42,10 @@ for (int py = 0; py < 1024; py++) { @@ -42,10 +42,10 @@ for (int py = 0; py < 1024; py++) {
}
std::cout << "loading " << filename << " at " << loadWidth << "," << loadHeight << std::endl;
for (int py = 0; py < loadHeight; py++) {
for (int px = 0; px < loadWidth; px++) {
for (unsigned int py = 0; py < loadHeight; py++) {
for (unsigned int px = 0; px < loadWidth; px++) {
if (anime) {
for (int i = 0; i < 4; i++) {
for (unsigned int i = 0; i < 4; i++) {
//data[1023 - py][px][i] = anime.pixel_data[((px * 4) + (py * 4 * 1024)) + i];
data[loadWidth - 1 - py][px][i] = static_cast<unsigned char>(anime->m_Ptr[((px * 4) + (py * 4 * loadWidth)) + i]);
}
@ -93,7 +93,7 @@ for (int py = 0; py < 1024; py++) { @@ -93,7 +93,7 @@ for (int py = 0; py < 1024; py++) {
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, loadWidth, loadHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<int>(loadWidth), static_cast<int>(loadHeight), 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
#ifndef __MINGW32__

Loading…
Cancel
Save