I'm following a tutorial about OpenGL 4 and the author always use glDrawArrays (with simple shape) but I'm wondering how he could draw complex shape without using any Index Buffer ?
Jump to content
Posted 13 January 2014 - 07:02 AM
glDrawArrays can be used for meshes of any complexity. Indexing is just a vehicle that helps in certain situations to improve performance. A code snippet w/o indexing looks less cluttered, so it may be meant to be better suited for demonstration purposes as occurs in such a tutorial (assuming that the attention is on something else, of course).
Posted 13 January 2014 - 07:57 AM
The only thing you wind up doing if you don't have an index buffer is repeating vertex data. Unless that is causing your program to bottleneck, it really doesn't matter that you're repeating the vertex data. Index buffers just add a layer of indirection like pointers do for normal code.
Whether you use index buffers or duplicate data a bit, it probably won't matter. Odds are pretty good you won't meaningfully impact your end result either way since you're probably not trying to make a AAA title. If you ever do need to optimize, you might just do it in different places for each approach.
Most people don't even have noticeable performance issues when using TRIANGLE_LIST or such until they are well into development, and in that situation you're talking almost 2/3 of the data being duplicated for no benefit.
Posted 18 January 2014 - 08:40 PM
if you are using complex models, and they are indexable - use it
if you have a flat-ish world that uses normals that are weighted - use it
otherwise, just stay away from indexing
if your meshes aren't indexable to a larger degree, you will likely just incur a performance loss
the thing that matters the most is reusing indices to the maximum degree, and that is something you really want a mesh generator for
you can also google the subject as there are various methods to generating heightmapped terrain with varying degrees of effectiveness vs generation speed
in the end it doesn't really matter much.. maybe its 15 fps at some extreme
also, use a profiler if you can you'd be surprised at what REALLY chopped your fps in half