Difference between GLvoid and void

Hey people,

there’s something I’m confused about. Why are there GL… datatypes? Regarding to the gl.h, all these datatypes are just typedefs of the “normal” types, like void, bool, int ect.

So, where is the difference? Are the GL datatypes stored in the Graphic Memory instead of the RAM?


This is to maintain portability across platforms. For example, a GLfloat must be 32 bits minimum, and so it might be typedef’d differently on a different platform to ensure this. :slight_smile:

HexCat is right, although I would rephrase that ‘minimum’ stuff. Normal C/C++ types are defined with a minimum word size defined by the compiler.
Compilers of 15 years ago might well have defined an int as 16-bits, whereas it’s usually a 32-bit now, and now that 64-bit CPUs are becoming common the defaults may well change again.
However OpenGL’s expected word sizes are exact. The link libraries and drivers expect certain sizes because they are not recompiled when the application is compiled, so the application must use the correct sizes. That’s what the GL… types are for.

Of course a void does not have any storage at all, so why a GLvoid would be necessary is anyone’s guess. Since it can appear anywhere and not just in front of a function (returning nothing), my guess is that it’s there merely for consistency.

According to the Red Book:

“Finally, OpenGL defines the type of GLvoid. This is most often used for OpenGL commands that accept pointers to array of values.”
[OpenGL Programming Guide, Third Edition (OpenGL V1.2) Page 9.]

I hope this helps. :slight_smile: