Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL 4 and Index Buffer

Started by Atemu Jan 13, 2014 at 12:52 PM 3 replies 1.9k views
Original Post
Atemu
Atemu

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 ?

haegarr
haegarr

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

AbandonedAccount
AbandonedAccount

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.

Atemu
Atemu

Alright, thanks for your answers :)

Kaptein
Kaptein

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.