PDA

View Full Version : Question about texture display



Bruce.Zhou
06-17-2009, 02:35 AM
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.
http://vrlab.whu.edu.cn/doc/question.jpg
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!

ZbuffeR
06-17-2009, 03:14 AM
Do you define correct texture coordinates for the train interior ?

Bruce.Zhou
06-17-2009, 05:14 AM
Yes, I modeled the train by 3DMax, and render it right in Max, using 3ds to export to my application!

remdul
06-17-2009, 05:47 AM
Replace GL_DECAL with GL_MODULATE, like this:

glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

Bruce.Zhou
06-17-2009, 07:40 AM
Thanks,
I did as you told, then get the fellowing image http://vrlab.whu.edu.cn/doc/question01.jpg

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