You can always do:
NSPoint p;
glVertex2fv((float *)&p);
Careful, NSPoint is a typedef of CGPoint in 64-bit (and optionally in
32-bit) with the 10.5 SDK, and CGFloat is a double in 64-bit.
Indeed... I assumed too much...
So, let's come back to Richard's original question, which was:
---
So I am thinking that the OpenGL vector data type and corresponding
function looks extremely loop friendly. Maybe I should pattern my
geometric primitives and associated functions after OpenGL not Cocoa.
I have not gotten into Core Data yet so I am not sure which data type
would be more compatible a struct or a vector (array).
Any comments or suggestions on structs versus vectors?
---
I usually write a small class (or struct, same difference) such as:
struct MyPoint
{
float x;
float y;
};
To loop by index, I redefine the operator[] in C++ and/or write a
small ptr() method return the address of the first member.
And if you want to go crazy, you can go with unions:
struct MyPoint
{
union
{
struct
{
float x;
float y;
};
float ptr;
}
};
where you can access things like:
MyPoint pt;
pt.x = 1.0f;
pt.ptr[1] = 2.0f;
Of course, I've got full-fledge interface beyond that, but it gives an
idea.
So, in the end, I've got BOTH struct and vector forms... Best of both
worlds. ;-)
Enjoy!
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Mac-opengl mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/mac-opengl/email@hidden
This email sent to email@hidden