Results 1 to 3 of 3

Thread: Texture and Color

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2005
    Location
    India
    Posts
    11

    Texture and Color

    Hai,

    In my quad i wnat to draw a texture in front and back faces and all other faces fill with different colors.
    Is it possible

    i wrote this way
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glBindTexture(GL_TEXTURE_2D, texBr[0]);
    glBegin(GL_QUADS);
    if( face==FRONT or face BACK)
    {
    //Draw the texture
    }
    else
    {
    glColor3f(0,1,0);
    //Draw the face
    }

    But the faces didn't fill with the specified color. it always appears the texture color.

    Anyone have any idea??


    Thanks

    Anish

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2004
    Posts
    314

    Re: Texture and Color

    OpenGL only makes a distinction between front faces and back faces.

    A front face is a surface which faces in the general direction of the viewer.
    A back face is a surface which faces away from the viewer.
    The facing is determined by the surface normal (which is derived from the order in which you specify the vertices).

    Think of surfaces in OpenGL as sheets of paper. You can only see one side at a time.

    If you want something fancier, you'll have to code it yourself.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Texture and Color

    Do it like that:

    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL );
    glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
    glBindTexture(GL_TEXTURE_2D, texBr[0]);

    glBegin(GL_QUADS);
    //Draw front and back faces
    glEnd();

    glDisable (GL_TEXTURE_2D);
    glColor3f(0,1,0);
    glBegin(GL_QUADS);
    //Draw other faces
    glEnd();

    The main issue that remains is how you calculate if a face is front/back or other. Common graphic applications only distinguish front and back faces. More only front faces are visible and other faces (back) will never.

Similar Threads

  1. Replies: 1
    Last Post: 12-26-2014, 04:57 PM
  2. Replies: 1
    Last Post: 03-10-2014, 12:51 PM
  3. Depth texture and color texture fragment matching
    By glTomm in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-05-2014, 08:26 AM
  4. OpenGL 4.2, How to Copy a color texture into a depth texture ?
    By imported_cippyboy in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 08-26-2013, 01:17 AM
  5. Drawing color affected by texture color
    By yossi in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-14-2001, 03:56 AM

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