Results 1 to 8 of 8

Thread: glTexCoord and glNormal

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    22

    glTexCoord and glNormal

    Hello. I have some questions that need to be answered. What exactly is the function of glTexCoord and what is the difference between glTexCoord and glNormal?

  2. #2
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: glTexCoord and glNormal

    glNormal specifies the per-vertex normal vector, which is used in lighting calculation, glTexCoord specifies the per-vertex texture coordinate which is used in texture application (read the corresponding pages from the OpenGL specification). Feel free to ask more specific questions...

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    22

    Re: glTexCoord and glNormal

    I 've read the corresponding pages in OpenGl specification. What i am trying to do is to create an angular fisheye from a cubemap. So i got the idea to wrap the texture of the cubemap around a sphere and map the texture according to the maths that are applied in order to create the angular fisheye. In order to understand better what i try to do, here is the link:

    http://local.wasp.uwa.edu.au/~pbourk...ction/fisheye/

    What i do not understand is this: must i ,for each point of the sphere, determine the vector for the mapping by use of glTexcoord? In fact, should i use glTexCoordd at all?

    PS: In order to understand, read the the paragraphs "Creating an angular fisheye" and "Inverse transform".

  4. #4
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: glTexCoord and glNormal

    If I understand that case correctly, normal and texture coordinates equal each other (if you interpret the cubemap as a normal vector lookup table). Still, GL maps texture to a surface using the texture coordinates, so you will have to specify texture coordinates, unless you use shaders and do anything manually anyway.

  5. #5
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    22

    Re: glTexCoord and glNormal

    (if i remember correctly, with shaders you manipulate directly the GPU "programmable pipeline.) i do not use shaders. i use glNormal3f and when i want to generate texture coordinates, i use these functions:

    glTexGenfv(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
    glTexGenfv(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
    glTexGenfv(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT);
    glEnable(GL_TEXTURE_GEN_S);
    glEnable(GL_TEXTURE_GEN_T);
    glEnable(GL_TEXTURE_GEN_R);

    What intrigues me in the link that i gave you to look is this:
    In the paragraph "Inverse transform", it says that for each unit vector (x,y,z) we find a (u,v) coordinates. I wrote the code for the calculations of (u,v) , given the (x,y,z), and then before calling glVertex i called glTexCoord2f for the (u,v) and from the code above i deleted the first 3 lines. The results was catastrophic to be exact. What could 've gone wrong???

    PS: Sorry if i tire you with my questions

  6. #6
    Senior Member OpenGL Pro Zengar's Avatar
    Join Date
    Sep 2001
    Location
    Germany
    Posts
    1,931

    Re: glTexCoord and glNormal

    Uhm, TexGen "replaces" manually specified texture coordinates with the generated ones. So when you enable it (with glEnable) then all data you specify with TexCoord is lost. Even so, you don't need to specify texture coordinates if they are generated: what I meant is that you need them for texture mapping, no matter where they come from (manually or generated)!

  7. #7
    Junior Member Newbie
    Join Date
    Dec 2007
    Posts
    22

    Re: glTexCoord and glNormal

    what i know that TexGen is used to create "automatically" the texture coordinates using OpenGL's modes. What i do not know (exactly) is how to create manually texture coordinates (in this case the necessary coordinates for fisheye). Something is missing, but i do not know what

  8. #8
    Senior Member OpenGL Pro dletozeun's Avatar
    Join Date
    Jan 2006
    Location
    FRANCE
    Posts
    1,367

    Re: glTexCoord and glNormal

    I don't know fisheye projection, but there should be a way to generate these texture coordinates procedurally.
    For an arbitrary 3D mesh, texture coordinates are often generated in 3D modelers by artists using projections like: plane, spherical, cylindrical, ... projections.

Similar Threads

  1. about the glNormal
    By zydgyy in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 11-25-2011, 03:57 AM
  2. Understanding of glTexCoord*
    By Tyvan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-14-2009, 05:10 AM
  3. Display lists and glTexCoord
    By imported_huntc in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 07-07-2005, 04:00 AM
  4. glVertex & glTexCoord
    By dimensionX in forum OpenGL ES
    Replies: 3
    Last Post: 09-30-2004, 10:23 AM
  5. glTexCoord coordinates
    By delic in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-06-2002, 10:02 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