OpenGL data types

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

OpenGL data types

Post by davidthefat »

Are they really necessary? I can just use the regular old data types in place of them right? Any pros and cons?
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: OpenGL data types

Post 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 ;)
User avatar
davidthefat
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 529
Joined: Mon Nov 10, 2008 3:51 pm
Current Project: Fully Autonomous Robot
Favorite Gaming Platforms: PS3
Programming Language of Choice: C++
Location: California
Contact:

Re: OpenGL data types

Post by davidthefat »

Then How will I use them with SDL? Do I have to convert them or something?
User avatar
RyanPridgeon
Chaos Rift Maniac
Chaos Rift Maniac
Posts: 447
Joined: Sun Sep 21, 2008 1:34 pm
Current Project: "Triangle"
Favorite Gaming Platforms: PC
Programming Language of Choice: C/C++
Location: UK
Contact:

Re: OpenGL data types

Post by RyanPridgeon »

You can play it safe by just typecasting.

unsigned int x;
x = 123;
glSomething( (GLuint) x );
Ryan Pridgeon
C, C++, C#, Java, ActionScript 3, HaXe, PHP, VB.Net, Pascal
Music | Blog
User avatar
GroundUpEngine
Chaos Rift Devotee
Chaos Rift Devotee
Posts: 835
Joined: Sun Nov 08, 2009 2:01 pm
Current Project: mixture
Favorite Gaming Platforms: PC
Programming Language of Choice: C++
Location: UK

Re: OpenGL data types

Post by GroundUpEngine »

Edit:

What he said.
|
|
|
Ë…
Last edited by GroundUpEngine on Wed Dec 30, 2009 1:32 pm, edited 2 times in total.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: OpenGL data types

Post by K-Bal »

These #typedefs ensure that your variables always have the same number of bits on each platform. I use them.
User avatar
short
ES Beta Backer
ES Beta Backer
Posts: 548
Joined: Thu Apr 30, 2009 2:22 am
Current Project: c++, c
Favorite Gaming Platforms: SNES, PS2, SNES, SNES, PC NES
Programming Language of Choice: c, c++
Location: Oregon, US

Re: OpenGL data types

Post by short »

edit: what kbal said.
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: OpenGL data types

Post 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.
Post Reply