Jump to content
  • Advertisement

Archived

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

BGCJR

DrawElements

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

Advertisement
Like this:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 3, GL_FLOAT, 0, vectorArray );

where vectorArray is the pointer to your vector Array.

If by vector Array you mean stl vector:

vector pCoords; // List of vertices

Then give the pointer to the first element of the array like this:
glVertexPointer( 3, GL_FLOAT, 0, &pCoords[0] );

after that you can use glDrawElements
Assign all the indices of triagles in one array pointer pIndices.

unsigned int *pIndices;

glDrawElements(GL_TRIANGLES, numberOfIndices, GL_UNSIGNED_INT, pIndices);

See the Red Book for details...

Share this post


Link to post
Share on other sites
quote:
Original post by skremon
If by vector Array you mean stl vector:

vector<CVector3> pCoords; // List of vertices

Then give the pointer to the first element of the array like this:
glVertexPointer( 3, GL_FLOAT, 0, &pCoords[0] );

Note that this isn''t completely safe. Although most STL vector implementations store the data in contiguous memory, the C++ spec does not (yet) require this.

Share this post


Link to post
Share on other sites
Thanks Both, I''ll be testing it. I already added it my model editor and VBO , 44000tris in 4 opengl windows at one time runs pretty well.
i''m using stl vector to save memory leaks. So, it seems fine right now. but, if it does split up, i can save by reserving data?

Bobby

Share this post


Link to post
Share on other sites
quote:
Note that this isn''t completely safe. Although most STL vector implementations store the data in contiguous memory, the C++ spec does not (yet) require this.



I''m quite sure that Visual C++ compiler stores stl vector in contiguous memory. Can you tell me of any other compilers that doesn''t do it?
BTW First i used STL vectors but eventually i used pointers (copied them from vector to memory) for vertex arrays.

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!