Jump to content
  • Advertisement
Sign in to follow this  
Sythlin

OpenGL TexCoord Problems

This topic is 4913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey Guys, Currently I am having a problem with my rendering engine with OpenGL. I am using RTG's, with VBO's and drawelements. And when I load in a standard box with a simple texture applied to it. Only the front...top..and back are textured correctly, but the sides are all streched and weird looking. Wanted to see if you guys have any suggestions. Here is some of my code for Building the VBO's and drawing. I also think its how the texindices are being applied to the object which is wrong. Most of everythin is being stored through indices. Building the VBO's //Generate the Vertex Information Into the card glGenBuffersARB( 1, &ptemp->mesh.Hierarchy.m_uiVertBufferID); glBindBufferARB( GL_ARRAY_BUFFER_ARB, ptemp->mesh.Hierarchy.m_uiVertBufferID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB,ptemp->mesh.Hierarchy.iNumVerts*3*sizeof(float), ptemp->mesh.Hierarchy.m_fVerts , GL_STATIC_DRAW_ARB); glGenBuffersARB( 1, &ptemp->mesh.Hierarchy.m_uiNormalBufferID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, ptemp->mesh.Hierarchy.m_uiNormalBufferID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB,ptemp->mesh.Hierarchy.iNumNorms*3*sizeof(float), ptemp->mesh.Hierarchy.m_fNormals, GL_STATIC_DRAW_ARB); glGenBuffersARB( 1, &ptemp->mesh.Hierarchy.m_uiTexCoordBufferID ); glBindBufferARB( GL_ARRAY_BUFFER_ARB, ptemp->mesh.Hierarchy.m_uiTexCoordBufferID ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, ptemp->mesh.Hierarchy.iNumTexCs*2*sizeof(float), ptemp->mesh.Hierarchy.m_fTexCoords, GL_STATIC_DRAW_ARB); Drawing Function glPushMatrix(); glMultMatrixf(temp->data->objmatrix.matrix); // Enable the Client State of VBO glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); // Bind the Buffers to the Data to Render glBindBufferARB( GL_ARRAY_BUFFER_ARB, temp->data->mesh.Hierarchy.m_uiVertBufferID ); glVertexPointer(3,GL_FLOAT,0,(char*)NULL); glBindBufferARB( GL_ARRAY_BUFFER_ARB, temp->data->mesh.Hierarchy.m_uiNormalBufferID ); glNormalPointer(GL_FLOAT,0,(char*)NULL); glBindBufferARB( GL_ARRAY_BUFFER_ARB, temp->data->mesh.Hierarchy.m_uiTexCoordBufferID ); glTexCoordPointer(2,GL_FLOAT,0,(char*)NULL); // Draw the Array of Triangles for the Mesh glDrawElements(GL_TRIANGLES,temp->data->mesh.Hierarchy.iNumPolys*3,GL_UNSIGNED_INT,temp->data->mesh.Hierarchy.m_fVertInd); // Disable the ClientState glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); if you guys have any other suggestions please tell me. thanks a lot Sythlin

Share this post


Link to post
Share on other sites
Advertisement
The first thing I would look at is to see if you're mapping the texture points to the correct vertices, I can't tell offhand looking from your code if it does or not.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!