Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GLubyte vs GLshort for Indices

Tags:

indices

opengl

Looking through documentation for vertex arrays in OpenGL, two of the most common memory types used for indices I found were GLubyte (GL_UNSIGNED_BYTE) and GLshort (GL_SHORT). I was wondering if there was any actual difference between using the two for indices

Thanks, Dragonwrenn

like image 605
Prime Avatar asked Nov 22 '25 09:11

Prime


2 Answers

GL_UNSIGNED_BYTE is OK for models which have at most 256 vertices - that's really not many.

GL_UNSIGNED_SHORT, taking 2 bytes, would limit you to 65536 vertices - still that's kind of few.

I'd say the most common variant is GL_UNSIGNED_INT, as even 2 bytes may not be enough for mid-poly and high-poly models.

like image 163
Kos Avatar answered Nov 25 '25 10:11

Kos


GL_UNSIGNED_BYTE is 1 byte, GL_SHORT is 2 bytes. The only advantage of bytes is that they're smaller so they take less memory to store and less time to transfer to the graphics memory (assuming vertex arrays or VBOs).

Beware that not all types are available for all uses: You can't have GL_UNSIGNED_BYTE vertices, for example.

like image 23
Ben Jackson Avatar answered Nov 25 '25 09:11

Ben Jackson