OpenGL data types
Moderator: Coders of Rage
- davidthefat
- 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
Are they really necessary? I can just use the regular old data types in place of them right? Any pros and cons?
- GroundUpEngine
- 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
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.davidthefat wrote:Are they really necessary? I can just use the regular old data types in place of them right? Any pros and cons?
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.
- davidthefat
- 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
Then How will I use them with SDL? Do I have to convert them or something?
- RyanPridgeon
- 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
You can play it safe by just typecasting.
unsigned int x;
x = 123;
glSomething( (GLuint) x );
unsigned int x;
x = 123;
glSomething( (GLuint) x );
- GroundUpEngine
- 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
Edit:
What he said.
|
|
|
Ë…
What he said.
|
|
|
Ë…
Last edited by GroundUpEngine on Wed Dec 30, 2009 1:32 pm, edited 2 times in total.
Re: OpenGL data types
These #typedefs ensure that your variables always have the same number of bits on each platform. I use them.
- short
- 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
edit: what kbal said.
My github repository contains the project I am currently working on,
link: https://github.com/bjadamson
link: https://github.com/bjadamson
- Falco Girgis
- 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
^ this, gentlemen, is very important when you're trying to develop software for multiple platforms.K-Bal wrote:These #typedefs ensure that your variables always have the same number of bits on each platform. I use them.
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.