Archived

This topic is now archived and is closed to further replies.

skjinedmjeet

GLint vs. int (or long, or...)

Recommended Posts

What are the rules regarding when you should use a "GL" variable type (eg, GLuint), as opposed to a regular "unsigned int", or whichever type one is using? For example: When a map is loaded into my tile program, it loads the lighting information from a RAW file, consiting of three short''s per vertex. Since these values are ultimately going to be used in the rendering process, should they be GLints? Or does it matter? Currently, there is no difference between the two, so I''m speculating that the only use for "GL" variables is for the sake of portability?

Share this post


Link to post
Share on other sites
I hate "GL" variable types with a passion. I also hate stupidities like FLOAT and INT which MS seems to think was a smart idea. I don''t mind aliases as long as they''re not just plain stupid(I use DWORD on occasion). The GL variables don''t tell you anything new about the variable. Something like typedef unsigned int uint; is about as far as I ever go. But realize that deep down, they''re all the same thing.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The GL variables are there because of the guarentees they provide. That is, GLint will always be at least 32 bits and can contain negative and positive quantities. Granted, this scheme isn''t really necessairy now that we have stdint.h, but GL is also supposed to be supported on older compilers/platforms that have weird integer formats.

Technically, if you''re going to call a GL function, and that function takes a GL* type parameter, then you should pass it such a parameter. You could also cast your int to GLint or whatever. However, when sending pointers to OpenGL, you must make sure they are of the right type (that is, a GLfloat* points to GLfloats and not plain floats). You never know when types might change...

Share this post


Link to post
Share on other sites
The GL predefined types are there with some perpose.SGI is not so stupid to put something that makes no sence with the greatest 3D library.If you''ve noticed,every library/engine/... has predefinitions of the basic types.The make the code a lot more easier.Why should we write "unsigned short" or "unsigned long" when we can simply use USHORT/WORD or ULONG/DWORD.That''s 10 bytes of the code file don''t you think?!

The PAIN is coming...this summer!!!In cinemas everywhere.

Share this post


Link to post
Share on other sites