PDA

View Full Version : DIB file



phuongmaruko
12-09-2010, 08:09 AM
Hi all!

About texture mapping, there is one problem with my loading function
Here is my code

void COGLTexture::LoadFromFile(char *filename)
{
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1,&ID);
glBindTexture( GL_TEXTURE_2D, ID);
Image = auxDIBImageLoadA( (const char*) filename );
Width = Image->sizeX;
Height = Image->sizeY;
gluBuild2DMipmaps( GL_TEXTURE_2D,
3,
Image->sizeX,
Image->sizeY,
GL_RGB,
GL_UNSIGNED_BYTE,
Image->data);
delete Image;
}

exactly, it is the code from codecolony and it works with sample picture "Tex1.bmp" which is used in codecolony page. when I replace this picture with another one, an error occurred: "Failed to open DIB file floor.bmp". what could lead to this error? anyone can help me! (I compared properties of 2 pictures and they are completely the same);

phuongmaruko
12-09-2010, 08:31 AM
oh, I found the solution. I set absolute path for the image and it works. But I can't understand why we need absolute path for my picture while with sample picture, relative path is enough...vhat is the difference between them?

aqnuep
12-09-2010, 08:37 AM
It should work with relative path as well, just in your case I think the current execution directiory is incorrect.