Results 1 to 3 of 3

Thread: glTexGen problem

  1. #1
    Guest

    glTexGen problem

    I need to generate texture coordinates(using glTexGen) for a plane which is centered around the origin, that is it goes from -Width/2 to Width/2 in the x direction and from -Height/2 to Hgith/2 in the y direction. I don't really know how to set up my s and t vectors to avoid getting negative texture coordinates.
    Using this...
    Code :
    float sVec[]= {1/Width, 0, 0, 0};
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);   
    glTexGenfv(GL_S, GL_OBJECT_PLANE, sVec); 
    (and the same for t)
    ... will not work properly as half the coordinates become negative.
    Maybe I'm just being stupid here, but how do I generate texture coordinates for objects with vertices with both negative and positive coordinates?

  2. #2
    Member Contributor
    Join Date
    Mar 2003
    Location
    Suffolk, United Kingdom
    Posts
    99

    Re: glTexGen problem

    Try ...
    Code :
    float sVec[]= {1/Width, 0, 0, 0.5};
    glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);   
    glTexGenfv(GL_S, GL_OBJECT_PLANE, sVec);
    You will have been getting coordinates between -0.5 and +0.5 with your code, so use the 0.5 in the "w" (as above) to always adjust the generated coordinates back into the 0.0 to 1.0 range.


    [This message has been edited by Rog (edited 07-31-2003).]

  3. #3
    Guest

    Re: glTexGen problem

    Thanks alot. It seems to work now.

Similar Threads

  1. Replies: 3
    Last Post: 01-24-2007, 02:48 PM
  2. problem with glTexGen
    By FireCat12 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-23-2005, 11:43 PM
  3. glTexGen
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-07-2001, 07:28 AM
  4. glTexGen
    By HFAFiend in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-01-2001, 01:41 PM
  5. glTexGen*() ????????
    By SaF in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 03-11-2001, 02:54 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