bhatiaharsh

03-26-2011, 02:10 PM

Hi,

I am using glDrawElements to highlight some special triangles in my mesh. My mesh contains about 720000 triangles. While after some computations, I want to highlight about 50000 of these triangles.

Earlier, I was maintaining a special array of vertices (corresponding to these special triangles), and rendering them as triangles using glDrawArrays. And I realized I was eating up a lot of memory to duplicate the vertices.

So, I tried switching it to glDrawElements. Now I am maintaining indices of the vertices corresponding to the special triangles, and rendering them using the vertices of the mesh.

My Question is, which of them is faster ?

1. If I use glDrawArrays, I spend extra memory to duplicate the vertices. But I only pass the vertices that are needed for the special triangles.

2. If I use glDrawElements, instead of 3 doubles (representing a vertex), I only need 1 integer for its index. But then, I have to pass this enormous sized mesh to openGl which contains mostly unused vertices.

I would like to save the memory unless the openGL call to glDrawElement is way too slower than glDrawArrays.

Any ideas ?

I am using glDrawElements to highlight some special triangles in my mesh. My mesh contains about 720000 triangles. While after some computations, I want to highlight about 50000 of these triangles.

Earlier, I was maintaining a special array of vertices (corresponding to these special triangles), and rendering them as triangles using glDrawArrays. And I realized I was eating up a lot of memory to duplicate the vertices.

So, I tried switching it to glDrawElements. Now I am maintaining indices of the vertices corresponding to the special triangles, and rendering them using the vertices of the mesh.

My Question is, which of them is faster ?

1. If I use glDrawArrays, I spend extra memory to duplicate the vertices. But I only pass the vertices that are needed for the special triangles.

2. If I use glDrawElements, instead of 3 doubles (representing a vertex), I only need 1 integer for its index. But then, I have to pass this enormous sized mesh to openGl which contains mostly unused vertices.

I would like to save the memory unless the openGL call to glDrawElement is way too slower than glDrawArrays.

Any ideas ?