GLuint LoadTexture(char *filename)
{
static GLuint holder;
AUX_RGBImageRec *TextureImage[1]; // storagespace for 1 texture
memset(TextureImage,0,sizeof(void *)*1); // clear the mem
if (TextureImage[0] = LoadBMP(filename)) // load the file
{
glGenTextures(1, &holder); // create space for texture
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glBindTexture(GL_TEXTURE_2D, holder); // bind the loaded texture
glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0,
GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // set params
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // set params
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
if (TextureImage[0])
{
if (TextureImage[0]->data)
{
free(TextureImage[0]->data); // free the loaded bmp
}
free(TextureImage[0]); // and the memory
}
}
else
{
MessageBox(NULL, filename, "Error loading file", MB_OK);
exit(0);
}
return holder;
}
glGenTextures question
glGenTextures doesn''t seem to put the texture number in holder. What am i doing wrong?
Thanx, Marty
PS: This is the source:
_____ /____ /|| | || MtY | ||_____|/Marty
Are you calling this code before you have a valid OpenGL context?
Enigma
Enigma
yes. I''m using glut... I do call it before opening the context, because I give feedback in the same window as glut is going to use. I did glEnable(GL_TEXTURE_2D). Isn''t that enough?
Thanx,
Marty
Thanx,
Marty
_____ /____ /|| | || MtY | ||_____|/Marty
You have to create a window and set up a context before you do any Opengl calls
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement