Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I need suggestions for the best method of acheiving what I am trying to do:

-Using either OpenGL ES 1.x or 2.x

I need to pass a bunch of vertices to the GPU. Each one has 3 attributes: Position, Color, and Texture coords.

The vertices form quads, which share vertices. The shared vertices have both position and color attributes in common, but texcoords are not shared because each quad is textured with a 'tile' from a texture atlas.

I already know that it is not possible to use separate indices for a glDrawElements() call, so does that mean I can only use indexing for individual quads(specify 4 unique vertices per quad)? .. or is there any better solution?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

If you have a lot of quads (with shared vertices), but each quad needs its own texcoords, you can't use shared vertices, but each quad has to be defined separately.

It's better to use interleaved arrays in each case, because you have stored all attributes for one vertex consecutively in memory. So if you are trying to read for example vertex position, also some surrounding data from memory (in your case color and texcoords) are send to cache. If you have a lot of data, it's more efficient.

And you don't have to use glDrawElements in this case, you can just use glDrawArrays (you don't have to pass indices, if they are just sequence of increasing numbers).

I also hope, you are using VBOs (data are stored in GPU memory instead of system memory).

share|improve this answer
    
On Android devices, the GPU does not have dedicated memory.. doesn't that mean that VBOs are useless? And also, I have the use glDrawElements because then I need to specify 6 vertices per quad( There is no such thing as GL_QUADS in OpenGL ES) –  Jonathan Apr 8 '11 at 10:17
    
I am sorry, I don't have experience with Opengl ES. –  zacharmarz Apr 8 '11 at 11:17
add comment

Use glDrawElements and pass GL_TRIANGLE_FAN (4 indexes per quad).

You can use an uniform to get to a specific region in the texture, so your quads share the same texcoords but map to a certain area using the uniform variable.

share|improve this answer
    
This idea would kill batching. –  Jimmy Shelter Mar 13 '13 at 9:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.