views:

109

answers:

2

I understand CGFloat should be used in Cocoa applications to make them 64-bit clean. But what about in a simple OpenGL game that uses Cocoa/Objective-C for everything but the rendering (to an NSOpenGLView)? CGFloat is a part of Core Graphics, so if I would it also be alright to use CGPoint, CGRect etc.? or should I just write rects and vectors and that kind of stuff myself?

Basically is it fine to mix OpenGL with CoreGraphics types?

+3  A: 

I would recommend using GLFloat everywhere you plan on passing floats to OpenGL and CGFloat for anything in Cocoa. While they may be the same width now (I assume they are, but I didn't look), there's no guarantee that they'll be the same forever. You'll probably be safer writing your own rect and size structs. Shouldn't be too much work.

wbyoung
+2  A: 

In 64-bit Intel binaries, sizeof(CGFloat) is 8, and sizeof(GLfloat) is 4.

Dan Waylonis