Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Structs versus Vectors



I am developing a graphics application which will use OpenGL, Cocoa, and Core Data.

Apple defines a point like this.

     typedef struct _NSPoint {
         float x;
         float y;
     } NSPoint;

Apple also repeats this pattern in some of their sample code like this.

     typedef struct {
         GLdouble x,y,z;
     } recVec;

I assume here that rec means a storage record or struct and vec means vector which in mathematics is a matrix with one row or one column.

Anyway I started using this design pattern for some of my data types and associated functions. Every thing was working well and nice and tidy. A struct is a great way to keep the data together in one chunk and labeled nicely. But then I ran into what appears to be a problem. None of my structs and associated functions are loop friendly.

OpenGL does not appear to use structs at all but instead will do something like this.

     extern void glVertex3f (GLfloat x, GLfloat y, GLfloat z);
     extern void glVertex3fv (const GLfloat *v);

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?

Best Regards,
Richard

_______________________________________________
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


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.