Archived

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

Alkar

vertex_array disabled after glBegin when generating displaylist

Recommended Posts

Alkar    122
Hi! I have a lot of 2D static triangles to draw in VB (VB sucks, I know, but I didn''t choose it). Now I''m using a displaylist to draw them, but I''m triying to optimize rendering speed by using vertex array. After enabling vertex (2D) an color (RGBA) arrays, I start the displaylist generation. I have noticed that calling glBegin GL_TRIANGLE disables automatically both arrays. Is that usual? What can be wrong? Is it possible to use Vertex Array inside a DisplayList? Thanks! Breaking up is hard to do

Share this post


Link to post
Share on other sites
RipTorn    722
you don''t use glBegin/glEnd to draw from a VA. you use glDrawElements to draw them all in 1 line of code.
by enabling the arrays, I assume you mean glEnableClientState(GL_VERTEX_ARRAY) (or whatever it is) - which is what its'' meant to be.

Share this post


Link to post
Share on other sites
Alkar    122
Mmmm... I have been using as guide this example from the Red Book, v1.2.

Example 2-10 Using glArrayElement() to Define Colors and Vertices

GLint vertices [] = {25, 25, 100, 325, 175, 25, 175, 325, 250, 25, 325, 325};
GLfloat colors [] = {1.0, 0.2, 0.2, 0.2, 0.2, 1.0, 0.8, 1.0, 0.2, 0.75, 0.75, 0.75, 0.35, 0.35, 0.35, 0.5, 0.5, 0.5};

glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glColorPointer(3, GL_FLOAT, 0, colors);
glVertexPointer(2, GL_INT, 0, vertices);

glBegin(GL_TRIANGLES);
glArrayElement(2);
glArrayElement(3);
glArrayElement(5);
glEnd;


So it seems that it is possible to use glArrayElement with gl*Pointer and glEnableClientState (what other use can be given to it?)

Major changes to my data structure has to be made in order to use glDrawElements...

What can be happening?

I''m not ugly, just bad rendered

Share this post


Link to post
Share on other sites