PDA

View Full Version : Drawing several meshes



mobeen
01-15-2011, 02:44 AM
Hi all,
I have a couple of distinct meshes. Each mesh has vertex pos/normal/uv coord. Currently, I have setup a separate vao for each mesh (each VAO has a VBO for vertices/uv and normals) so in pseudocode it is something like this



//setup
for i:1 to N
bind vao[i]
ARRAY_BUFFER <- vertVBO
(BufferData <- vertices

ARRAY_BUFFER <- normalVBO
(BufferData <- normals

ARRAY_BUFFER <- uvVBO
(BufferData <- uv coords.

ELEMENT_ARRAY_BUFFER <- indices
end for

//render
for i:1 to N
bind vao[i]
glDrawElements (...)
end for

My question is, is this efficient in terms of performance. What other alternates do i have and how do i decide which to choose. From my preliminary search, I have found glMultiDrawElements which consolidates the multiple drawelements call into a single call. Is there any other alternate?

_arts_
01-15-2011, 06:00 AM
From your code, I could say that maybe you should use only vao/vbo since you call glDrawElements for each of your vao/vbo.

ugluk
01-15-2011, 06:44 AM
Hey moby, what language do you use for your GL program? It looks like octave or maybe matlab?

mobeen
01-15-2011, 07:28 AM
Hey moby, what language do you use for your GL program? It looks like octave or maybe matlab?
Hi i said its just a pseudocode representation. I work in c++ though anyways thanks for the inputs.