Is this safe?
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?
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.
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.
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.
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...)
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.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Thread-Safe reference counted smart pointers in c++ | JeroMiya | 1 | 2,858 |
Nov 21, 2006 12:28 PM Last Post: OneSadCookie |
|

