Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jappie

Vertex arrays & texturing

This topic is 6033 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 people, perhaps someone can help me with this little problem: I have created a terrain mesh using vertex arrays, it''s just when I add a texture coordinate array, the tris are just drawn in a shade of grey rather than textured. Here''s what I do:
  
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

glTexCoordPointer(2, GL_FLOAT, 0, g_TexCoords);
glVertexPointer(3, GL_DOUBLE, 0, g_Vertices);

glDrawArrays(GL_TRIANGLES, 0, g_NumIndices / 3);

glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
  
Now, g_TexCoords is an array of float, containing the UV coords for every vertex. g_Vertices contains the XYZ coords for all vertices, and g_NumIndices is the amount of indices in the g_Vertices array. Does anyone know why my textures aren''t showing? ----------------------------- Jappie BabJap Productions "There''s no such things as bugs; they''re just unintentional extra features"

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Are you forgetting to glEnable(TEXTURE_2D);?

Billy - BillyB@mrsnj.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Are you positive that the texture is loaded properly, and that you are binding the texture?

Try this function:

//This will draw the array with texture using basics.
void TestDrawArray(float *vList, float *tList, unsigned short Faces, int tNum)
{
int ctr;
glBindTexture(GL_TEXTURE_2D, tNum);
glBegin(GL_TRIANGLES);
for (ctr=0;ctr!=Faces;++ctr)
{
glTexCoord2f(*(tList++(,*(tList++));
glVertex3f(*(vList++),*(vList++),*(vList++));
}
glEnd();
}


Billy - BillyB@mrsnj.com

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can further speed that function up if you''re really going to be using it like so:
  
//This will draw the array with texture using basics.

void TestDrawArray(float *vList, float *tList, unsigned short Faces, int tNum)
{
int ctr;
glBindTexture(GL_TEXTURE_2D, tNum);
glBegin(GL_TRIANGLES);
for (ctr=0;ctr!=Faces;++ctr)
{
glTexCoord2fv(tList);
glVertex3fv(vList);
tList+=2;
vList+=3;
}
glEnd();
}

Share this post


Link to post
Share on other sites

  • 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!