Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL GLint, GLsizei limit?

OpenGL define its own datatype. Such as GLint or GLsizei. And they are different across platforms. Where can I find limits for the types?

Edit

Added language tag to clarify domain. And I know that GL* types will be resolved into basic C types, but it can be different by platform. (actually that's why they are defined.) And even basic C types are not guaranteed to be fixed size on any platform. That's why the limit.h is exist, and I expect there's also similar thing in GL itself for GL* types because they're semantically different with C types, and it means they need their own limit definitions.

like image 680
eonil Avatar asked Aug 17 '12 19:08

eonil


2 Answers

Assuming you are using C++ you can use std::numeric_limits<GLint>::max() to get the correct maximum value for a type or any other property of the type.

The spec doesn't guarantee that GLint is actually an int on any platform but only that it is an at least 32bit wide signed integral type, so MAX_INT is the lower size bound on a platform where int is actually 32 bits wide (e.g. x86_64).

like image 160
pmr Avatar answered Sep 18 '22 02:09

pmr


EDIT: Note that as pmr points out from the OpenGL spec, it is not guaranteed that GLint or GLsizei will always be defined as int. GLint and GLsizei are only guaranteed to be at least 32 bits.

from GL/gl.h

typedef int GLint;
typedef int GLsizei;

Those type are int's and sized according to the platform. To get the min and max values you can use INT_MIN and INT_MAX which should be found in limits.h ( assuming C ).

like image 21
Chimera Avatar answered Sep 22 '22 02:09

Chimera