Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Array Pointers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Hairu   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 July 2001 - 06:57 AM

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?

Sponsor:

#2 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 31 July 2001 - 10:33 AM

index vertex arrays are meant to be used in colour index mode ie 256colours.
is that what u want? maybe a misunderstanding

#3 Hairu   Members   -  Reputation: 122

Like
Likes
Like

Posted 31 July 2001 - 04:59 PM

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?






#4 zedzeek   Members   -  Reputation: 528

Like
Likes
Like

Posted 01 August 2001 - 09:45 AM



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 );




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS