Using GL types instead of primitive

Hello all!

Fisrt of all,if it is a duplicated question, I am very sorry! :frowning:

I have found a lot of GL* types in cocos2d framework such like GLInt, GLfloat, and etc

Are there any reasons to use GL types instead of the primitive types?

One thing that I know is that the size of int depends on a platform. If I use the primitive int it could be different size according to platform.

So if I want to support multi platform(for example, android and iphone), Am I supposed to use GL types instead of primitive?

Is anybody able to talk to me about this?

thank you!

The GL Types are used where cocos is inter-operating with OpenGL and thus help ensure that they remain consistent to the OpenGL requirements on each platform. i.e. in your hypothetical case where the primitive type was different to the OpenGL type then it would be an error to use the primitive type instead.

@farproc I appreciate your reply. you mean that I must use primitive types than GL types. GL means OpenGL, and GL types is for OpenGL. :smile:

Nothing will happen if you use primitive types instead of the GL variants, provided the size of the primitive is adequate, and the sign is preserved.

Using the GL variants makes the code somewhat easier to read, although these days with c++11 auto it probably doesn’t make much difference. For class and stack variables it makes sense to use the GL types, and just use auto for everything else, i.e. return types.

@mannewalis thank you much! using it is safe~! :smile: