Reputation: 3590
Is it possible to draw more than one OpenGL primitive shape and one call to glDrawElements or glDrawArrays?
For example:
In vertices[0 to N...] use GL_TRIANGLE_STRIP while in vertices[N to M] use GL_QUADS?
Or is there any other way on how to work around this kind of thing?
Because I want to limit the call for glDrawers
.
How can I achieve something like this using GL_TRIANGLE*?
It's suppose to be colored rectangle.
Upvotes: 0
Views: 934
Reputation: 18813
The closest you can get is to use glDrawElements with GL_TRIANGLES, reusing points as needed for the corresponding shape (have used this to transform begin...end sequences to modern GL with fewer draw calls).
For instance, if you want to draw a GL_QUAD, store the corner coordinates in the vertex array (as you would do for glDrawArrays(), then store 0, 1, 2, 0, 2, 3 in the elements array to build the quad out of two triangles.
See line 134 ff. of this example (it's Java source but it should be straight forward to build something similar in C++): https://code.google.com/p/playn-gl11-emulation/source/browse/src/main/java/playn/gl11emulation/MeshBuilder.java
Upvotes: 1