Jump to content
  • Advertisement

Archived

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

Hairu

Array Pointers

This topic is 6194 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

Has anyone successfully got "index" vertex arrays to work with texture arrays? If so, does the index pointer work for both the texture array and the vertex array, or just the vertex array? What i''m saying is, should the texture coords also be index in accordance with the vertex array?

Share this post


Link to post
Share on other sites
Advertisement
index vertex arrays are meant to be used in colour index mode ie 256colours.
is that what u want? maybe a misunderstanding

Share this post


Link to post
Share on other sites
No, i mean like using the index for the actual vertices of the triangles that I am drawing. Here''s a code sample for a routine in my game library....




void DH_Model::show()
{
// if we dont have a model, we cant show anything
if(!model_loaded){ DH_Error.push("Model Not Loaded"); return; }



// if a texture box is set, use it to set the texture
if(texture_box_set)
TextureBox->setTexture(header.TextureName);



// set the texture coordinate arrays
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords);

// set the normal arrays
glNormalPointer(GL_FLOAT, 0, Normals);

// set the vertex pointer
glVertexPointer(3, GL_FLOAT, 0, Vert_public);

// show the model
glDrawElements(GL_TRIANGLES, header.numFaces*3, GL_UNSIGNED_INT, index);

};


The problem is, i''m not sure how i should setup my texture array "TexCoords". The results i''m getting, are different than I expected. I''m building the array as if it wasn''t indexed. Is this correct?




Share this post


Link to post
Share on other sites


u should have exactlly the same number of vertices as texcoords as normals

eg for a square u have

B-----C
| |
| |
A-----D 4 verts, 4 texcoords, 4 normals
A B C D
verts[] = { {0,0,0}, {0,1,0}, {1,1,0}, {1,0,0} };
texcoords[] { { 0,0 }, { 0,1 }, { 1,1 }, { 1,0 } };
normals[] = { {0,0,1}, {0,0,1}, {0,0,1}, {0,0,1} };

GLuint index[] = {0,1,2,3};
glDrawElements( GL_QUADS, 4, GL_UNSIGNED_INT, index );

or in this case better(faster) yet

glDrawArrays( GL_QUADS, 0, 4 );

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!