Results 1 to 8 of 8

Thread: Disable Texture Coordinate Generation

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Disable Texture Coordinate Generation

    Hi Everyone!

    I'm having problems resetting the texture state on one of my texture units in
    an OpenGL application I'm writing with OpenGL 2.1 on Linux.

    I'm rendering my geometry into a shadow map bound to texture unit 0 (out of 4
    available texture units on my machine). Later I use the texture (still bound
    to texture unit 0) to render shadows to my scene.

    At the end of each frame I want to draw some HUD elements to the screen using
    the same texture unit. But the HUD quad with the texture applied is drawn like
    a single color quad whos color seems to depend on which way the camera is
    pointed.

    I suspected that the problem was that I had texture coordinate generation
    active for the current texture unit. But, even if I disable texture coordinate
    generation in the HUD drawing function, the result is still exactly the same
    as before.

    Code :
    glActiveTexture( GL_TEXTURE0);
    glBindTexture( GL_TEXTURE0, iHudTexture);
    glDisable( GL_TEXTURE_GEN_S);
    glDisable( GL_TEXTURE_GEN_T);
    glDisable( GL_TEXTURE_GEN_R);
    glDisable( GL_TEXTURE_GEN_Q);

    I'm starting to run out of ideas about this thing, I hope someone can point me
    in the right direction.

    Thanks in advance

    Fredrik

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2006
    Location
    Sweden
    Posts
    744

    Re: Disable Texture Coordinate Generation

    it could be the texture matrix, you can reset it using

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity ();
    glMatrixMode(GL_MODELVIEW);

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Re: Disable Texture Coordinate Generation

    Hi, thanks for the reply!

    I tried to reset the texture matrix too, but the problem persists unfortunately.

  4. #4
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: Disable Texture Coordinate Generation

    But the HUD quad with the texture applied is drawn like
    a single color quad whos color seems to depend on which way the camera is
    pointed.
    Sounds like lighting still enabled...

    Try

    glDisable(GL_LIGHTING)

    before drawing any huds, and in case you are using it, also reset the texture compare mode:

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE)

  5. #5
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Re: Disable Texture Coordinate Generation

    I tried to do

    glDisable(GL_LIGHTING);
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);

    It does not seem to work either.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,658

    Re: Disable Texture Coordinate Generation

    You've got the source, so you're definitely the best to determine which GL state your setting in your app and thus the candidate states that might need reset.

    At the top of your renderer before you start messing with these textures, try:

    glPushAttrib( GL_ALL_ATTRIB_BITS );

    and between the shadow render and scene render at the appropriate point, put a:

    glPopAttrib();
    glPushAttrib( GL_ALL_ATTRIB_BITS );


    see if you can make the problem go away. If you can, then try refining the push/pop to only certain groups of attributes.

    Another possibility is to use a tool like gDEBugger, and snapshot the state at app startup, and compare to app state at the point you're about to rendering something with the problem. Diff for ideas.

    Also, you are doing a glOrtho to wax your perspective and get a parallel PROJECTION matrix, aren't you? You'll also want a fresh VIEWING matrix that unlike the scene is prob static and doesn't change.

  7. #7
    Member Contributor
    Join Date
    Jul 2009
    Location
    Buenos Aires
    Posts
    67

    Re: Disable Texture Coordinate Generation

    Or start commenting the shadow drawing code out, until the hud works, then you'll know wich state is causing trouble.

  8. #8
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    4

    Re: Disable Texture Coordinate Generation

    Nice suggestions, I'll start investigating, when I get home later tonight.

Similar Threads

  1. Texture Coordinate generation
    By Diggio in forum OpenGL: GLSL
    Replies: 2
    Last Post: 11-09-2007, 10:27 AM
  2. Is there a way to disable texture coordinate interpolation?
    By Aaron in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-22-2007, 09:00 AM
  3. texture coordinate generation...
    By nishal in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 09-28-2003, 04:40 AM
  4. Texture Coordinate Generation
    By Tokage in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-27-2003, 12:55 PM
  5. Texture coordinate generation
    By fshana in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-05-2000, 08:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean