Skip to content Skip to sidebar Skip to footer

How I Can Use Gldrawelements For Many Squares?

I am developing a 2D Open GL game and i have to draw many squares on screen for a tilemap, with a diferent glTexCoordPointer from the texture. Now, I don't know how to use Gldrawel

Solution 1:

If the squares are adjacent to each other, then use a quad-strip (or a equivalently a triangle-strip):

quad-strip of adjacent quads

If the squares are disjoint simply use quads

enter image description here

You can also use a quad-strip (equivalently a triangle-strip) in this case by adding degenerate quads (triangles):

GLushort indices[]={A, B, C, D, D, E, E,F, G, H, H, I, I, J, K, L}

Two squares with the same vertex positions, but different texture coordinates must be represented with different quads.

Post a Comment for "How I Can Use Gldrawelements For Many Squares?"