Thread: texture disappears!

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    5

    Question 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
    Last edited by Salem; 03-13-2012 at 11:22 AM. Reason: font abuse - use PASTE AS TEXT in future

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. OpenGL - Texture or no texture?
    By MathFan in forum Game Programming
    Replies: 1
    Last Post: 12-21-2008, 12:48 PM
  2. How to view the programme before it disappears
    By yousuf in forum C Programming
    Replies: 2
    Last Post: 03-22-2008, 08:12 AM
  3. compiler disappears
    By spveer in forum C Programming
    Replies: 5
    Last Post: 07-07-2005, 10:38 AM
  4. 'Hello World' - window disappears as soon as I run.
    By GandyCobra in forum C Programming
    Replies: 16
    Last Post: 09-15-2004, 11:38 AM
  5. Manual rendering disappears
    By Magos in forum Windows Programming
    Replies: 7
    Last Post: 02-29-2004, 09:25 PM