Results 1 to 5 of 5

Thread: Question about texture display

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    3

    Question about texture display

    Hi, I meet a problem in rendering a textured train.
    When I use material I can get the image like the left image.
    But when I change to use a texture the image is right image.

    I use one light in my scene, set the Ambient=0.1, Diffuse=0.2, Specular=0.1
    For Texture para
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
    glEnable(GL_LIGHTING)

    What is the problem? How can I get the right result!
    Thanks for all!

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Question about texture display

    Do you define correct texture coordinates for the train interior ?

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    3

    Re: Question about texture display

    Yes, I modeled the train by 3DMax, and render it right in Max, using 3ds to export to my application!

  4. #4
    Senior Member Regular Contributor remdul's Avatar
    Join Date
    Mar 2004
    Location
    The Netherlands
    Posts
    346

    Re: Question about texture display

    Replace GL_DECAL with GL_MODULATE, like this:

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2009
    Posts
    3

    Re: Question about texture display

    Thanks,
    I did as you told, then get the fellowing image

    For clearly, I give the opengl codes here:
    glPushAttrib(GL_LIGHTING_BIT | GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_HINT_BIT);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glEnable(GL_LIGHTING);
    glDisable(GL_NORMALIZE);
    glShadeModel(GL_SMOOTH);
    glDepthFunc(GL_LEQUAL);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    glBind(GL_TEXTURE_2D,iTexID);
    glBegin(GL_TRIANGLE_STRIP);
    for(j = 0; j < wptPoint; j++)
    {
    glTexCoord2fv((float*)&amp;pSupScene->m_pTexCoord[*((WORD*)&amp;pSupScene->m_pPoly3Mat[i].pMemBlock[iOffset + iTexSize])]);
    glNormal3fv((float*)&amp;pSupScene->m_pNormals[*((WORD*)&amp;pSupScene->m_pPoly3Mat[i].pMemBlock[iOffset + iNormalSize])]);
    glVertex3fv((float*)&amp;pSupScene->m_pVertices[*((WORD*)&amp;pSupScene->m_pPoly3Mat[i].pMemBlock[iOffset])]);
    iOffset += iVertexSize;
    }
    glEnd();

    All of these included in a display list

Similar Threads

  1. Display function question
    By sonnik in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-07-2009, 10:54 PM
  2. DIsplay Lists Question
    By ToddAtWSU in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 02-09-2007, 10:31 AM
  3. display list question
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-13-2005, 10:29 AM
  4. display list question
    By incus in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 05-31-2002, 11:49 AM
  5. Display List Question
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-10-2001, 01:18 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