This is the first time I've had this problem, my code just won't load the images I need it to.
Here is my first function for loading the image into data:
void C_Resource_Loader::v_Create_Image(std::string filename,int nID)
{
//create image and bind to it
ilGenImages(1, &image[nID]);
ilBindImage(image[nID]);
//check if DevIL successfully loads the image
success = ilLoadImage(filename.c_str());
if(success)
{
success = ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);
if (!success)
SDL_Quit();
//create texture and bind to it
glGenTextures(nID,&texture[nID]);
glBindTexture(GL_TEXTURE_2D,texture[nID]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexImage2D(GL_TEXTURE_2D, 0, ilGetInteger(IL_IMAGE_BPP), ilGetInteger(IL_IMAGE_WIDTH),
ilGetInteger(IL_IMAGE_HEIGHT), 0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,
ilGetData());
ilDeleteImages(nID, &texture[nID]);
}
}
and here is my code for putting the image on the screen:
void C_Resource_Loader::v_Apply_Image(int nID, int pn_X, int pn_Y, int pn_Depth)
{
glPushMatrix();
//bind the image so it can be textured
glGenTextures(1,&texture[nID]);
glBindTexture(GL_TEXTURE_2D,texture[nID]);
//move the image to the set x and y
glTranslatef(pn_X,pn_Y,-600);
glBegin(GL_QUADS);
glTexCoord2i(0,0);
glVertex3f(0,0,pn_Depth);
glTexCoord2i(0,1);
glVertex3f(0,32,pn_Depth);
glTexCoord2i(1,1);
glVertex3f(32,32,pn_Depth);
glTexCoord2i(1,0);
glVertex3f(32,0,pn_Depth);
glEnd();
glPopMatrix();
}
Is there a major problem with it, because this code should work, I've used it many times before...
ilInit()
before loading the image, and so OpenGL is getting NULL data. \$\endgroup\$ – kevintodisco May 13 '12 at 21:51