Advertisement Jump to content
Sign in to follow this  
Atemu

OpenGL OpenGL 4 and Index Buffer

This topic is 1824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey,

 

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 ?

Share this post


Link to post
Share on other sites
Advertisement

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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :D

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!