Archived

This topic is now archived and is closed to further replies.

hello_there

beginner open gl problem

Recommended Posts

hello_there    122
when ever i try to load textures and display them they just come out white. i can''t get it to work. i used nehe''s way and it didn''t work. AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image { FILE *File=NULL; // File Handle if (!Filename) // Make Sure A Filename Was Given { return NULL; // If Not Return NULL } File=fopen(Filename,"r"); // Check To See If The File Exists if (File) // Does The File Exist? { fclose(File); // Close The Handle return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer } return NULL; // If Load Failed Return NULL } int LoadGLTextures() // Load Bitmaps And Convert To Textures { AUX_RGBImageRec *TextureImage[2]; memset(TextureImage,0,sizeof(void *)*1); TextureImage[0] = LoadBMP("64grass.bmp"); TextureImage[1] = LoadBMP("64wall.bmp"); glGenTextures(2, &texture[0]); // We are generating two textures glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data); for (int t = 0; t < 2; t++) { if (TextureImage[t]) { if (TextureImage[t]->data) { free(TextureImage[t]->data); } free(TextureImage[t]); } } return(1); } that''s nehe''s code i put that into my programe along with the nehe init function and try load load my texture to my square but it didn''t work please help.

Share this post


Link to post
Share on other sites
TheBlackJester    142
Hey,

Post the section where you make the quad and texture it so i can have a look at that too. You problem might be there.

Also look at this



if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}

return NULL; // If Load Failed Return NULL
}



you might want to make that this


if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}
else
{
return NULL; // If Load Failed Return NULL
}




Edited by - TheBlackJester on December 9, 2001 6:39:40 PM

Share this post


Link to post
Share on other sites