-
texture disappears!
I load a HDR image as a texture and I wrote shaders to map the 2 texture to a sphere but texture disappears when I click on it or when I resize the window! Here is my code for display function:
Code:
void Draw()
{
qobj = gluNewQuadric();
gluQuadricTexture(qobj, GL_TRUE);
model->GetFaces();
glEnable(GL_CULL_FACE);
glFrontFace(GL_CW /* or GL_CCW */ ); //default is GL_CCW
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glPushMatrix();
glTranslatef(tx, ty, 0);
glRotatef(rotx, 1, 0, 0);
glRotatef(roty, 0, 1, 0);
LShader.bind();
glEnable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
gluSphere(qobj, 1, 30, 30);
int texture_location =
glGetUniformLocation(LShader.GetID(), "color_texture");
glUniform1i(texture_location, texture);
gluDeleteQuadric(qobj);
glDisable(GL_TEXTURE_2D);
LShader.unbind();
glPopMatrix();
glutSwapBuffers();
};
Thanks in advance