Original Post
I am loading a .tga image to texture a quad, however somewhere along the way, something is wrong. My quad comes out white. I dont think the problem is in loading the .tga I think its in the 'binding' of that texture (not sure if thats the correct term) Or in the drawing of the quad with the texture. Here is some of the code I am placing the loaded .tga in this struct I believe that all .tga is correctly loaded into this struct, its the next step, the 'binding' that i think is incorrect, here is the function that does this. now my main program creates an object of sTexture called text sTexture text; then then 'text' is sent to the above program like this LoadGLTexture (&text,"testpic.tga"); then the draw routine is ran, (below) Thanks for any help you can give.
struct sTexture
{
GLubyte * imageData;
GLuint bpp;
GLuint width; GLuint height; GLuint texID; GLuint type;
sTexture() {imageData = NULL;}
~sTexture() {Destroy();}
void Destroy() {if (imageData!=NULL) free(imageData);imageData=NULL;}
};
bool LoadGLTexture(sTexture *texture,char *filename)
{
if (LoadTGA(texture,filename))
{
glGenTextures(1,&texture->texID);
glBindTexture(GL_TEXTURE_2D,texture->texID);
glTexImage2D(GL_TEXTURE_2D, 0, texture->bpp / 8,texture->width, texture->height, 0, texture->type, GL_UNSIGNED_BYTE, texture->imageData);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
texture->Destroy();
return true;
}
return false;
}
void Draw (void)
{
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity ();
glTranslatef (0.0f, 0.0f, -6.0f);
glBindTexture(GL_TEXTURE_2D, text.texID);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);glVertex3f( -1.0f, -1.0f,1.0f);
glTexCoord2f(1.0f, 0.0f);glVertex3f(1.0f, -1.0f,1.0f);
glTexCoord2f(1.0f, 1.0f);glVertex3f(1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f);glVertex3f( -1.0f, 1.0f, 1.0f);
glEnd();
glFlush ();
}