Page 1 of 1

OpenGL data types

Posted: Sun Dec 27, 2009 11:18 am
by davidthefat
Are they really necessary? I can just use the regular old data types in place of them right? Any pros and cons?

Re: OpenGL data types

Posted: Sun Dec 27, 2009 4:27 pm
by GroundUpEngine
davidthefat wrote:Are they really necessary? I can just use the regular old data types in place of them right? Any pros and cons?
There are no pros and cons as far as I know of, but what I do know is thier necessary because they are an important part of the OpenGL syntax e.g.

The syntax for binding a texture is -> glBindTexture(GLenum target, GLuint texture);

Code: Select all

This is correct->

GLuint tex[5];
glBindTexture(GL_TEXTURE_2D, tex[0]);

Code: Select all

This is incorrect->

unsigned int tex[5];
glBindTexture(GL_TEXTURE_2D, tex[0]);

--------------------------------------

Meaning that without them, the wrong texture may show up or no texture will be draw at all.
Hope it help ;)

Re: OpenGL data types

Posted: Sun Dec 27, 2009 5:52 pm
by davidthefat
Then How will I use them with SDL? Do I have to convert them or something?

Re: OpenGL data types

Posted: Sun Dec 27, 2009 6:08 pm
by RyanPridgeon
You can play it safe by just typecasting.

unsigned int x;
x = 123;
glSomething( (GLuint) x );

Re: OpenGL data types

Posted: Sun Dec 27, 2009 6:29 pm
by GroundUpEngine
Edit:

What he said.
|
|
|
Ë…

Re: OpenGL data types

Posted: Mon Dec 28, 2009 3:54 am
by K-Bal
These #typedefs ensure that your variables always have the same number of bits on each platform. I use them.

Re: OpenGL data types

Posted: Mon Dec 28, 2009 5:47 pm
by short
edit: what kbal said.

Re: OpenGL data types

Posted: Wed Dec 30, 2009 1:02 am
by Falco Girgis
K-Bal wrote:These #typedefs ensure that your variables always have the same number of bits on each platform. I use them.
^ this, gentlemen, is very important when you're trying to develop software for multiple platforms.

All sorts of shitty bugs could creep into your code when you start having data types that are different sizes (and hold different max numbers) on different platforms.