🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
beginner open gl problem
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.
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
you might want to make that this
Edited by - TheBlackJester on December 9, 2001 6:39:40 PM
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
I don''t know if it''s your problem but since you are using 2 textures memset(TextureImage,0,sizeof(void *)*1);
should be: memset(TextureImage,0,sizeof(void *)*2);
should be: memset(TextureImage,0,sizeof(void *)*2);
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement