I’m trying to load a transparent png file. I seem to have data corruption when trying to load multiple images. It works fine when loading one image.
I think this is what is wrong with my game.
GLuint loadTexture(const char* filename){
SDL_Surface* img = IMG_Load(filename);
if(img == NULL)cout<<"Image failed to load"<<endl;
GLuint id;
glGenTextures(1, &id);
glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->w, img->h, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, img->pixels);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
SDL_FreeSurface(img);
return id;
}