Is this safe?

Member
Posts: 194
Joined: 2009.02
Post: #1
Two questions. One, if I use GLfloats and GLuints in place of regular floats and ints is this an entirely safe practice(and more specifically is it future-proof)? Also is there a tangible casting penalty when passing regular floats to glVertex and alike functions?
Quote this message in a reply
Member
Posts: 227
Joined: 2008.08
Post: #2
1)Yes, GLfloat is a 32bit single-precision floating point (I.e. C float), GLuint is an unsigned int (technically an unsigned long int, but long is the same as int on 32 and 64 bit hardware)
2)No, actually you should use floats for OpenGL almost exclusively (some exceptions, like textures) OpenGL stores it's Matrices and points as floats anyway.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
Oddity007 Wrote:1)Yes, GLfloat is a 32bit single-precision floating point (I.e. C float), GLuint is an unsigned int

They *currently* are. The typedefs exist to give them the flexibility to change the underlying types later. Using them interchangeably isn't entirely future-proof, but safe on current architectures as far as I know.

Oddity007 Wrote:(technically an unsigned long int, but long is the same as int on 32 and 64 bit hardware)

Er, no. x86_64 and ppc64 use LP64, which means longs and pointers are 64 bits wide. int remains 32.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #4
ThemsAllTook Wrote:Er, no. x86_64 and ppc64 use LP64, which means longs and pointers are 64 bits wide. int remains 32.
For GCC. If you decide to compile for Windows with Microsoft's compiler, longs will be 32 bits long for both 64 bit and 32 bit machines. If you want guarantees for the sizes, you need to use stdint.h. (but you'll need to download a version for Microsoft's compiler since they don't include it...)
Quote this message in a reply
Member
Posts: 194
Joined: 2009.02
Post: #5
ThemsAllTook Wrote:They *currently* are. The typedefs exist to give them the flexibility to change the underlying types later. Using them interchangeably isn't entirely future-proof, but safe on current architectures as far as I know.

That option entirely slipped my mind, thanks.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Thread-Safe reference counted smart pointers in c++ JeroMiya 1 3,354 Nov 21, 2006 12:28 PM
Last Post: OneSadCookie