| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Even for very small batches? I've always heard (and repeated) that for very small batches (at one point Apple's performance notes said 11 or less), you might as well use Immediate mode as the overhead is virtually the same.
Richard
On May 8, 2008, at 4:33 PM, John Stiles wrote:
I'm surprised that no one has yet said "avoid immediate mode."
Immediate mode is not really recommended for real development; it's slow and doesn't really match the design of the hardware any more.
You should really use glDrawElements or something like that. That's more important than whether you use a struct array or a float array (since the compiler will generate basically the same code either way).
Jocelyn Houle wrote: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_______________________________________________ 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
_______________________________________________ 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
_______________________________________________ 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
| References: | |
| >Structs versus Vectors (From: Richard Somers <email@hidden>) | |
| >Re: Structs versus Vectors (From: "Wesley Smith" <email@hidden>) | |
| >Re: Structs versus Vectors (From: "Keith Bauer" <email@hidden>) | |
| >Re: Structs versus Vectors (From: Jocelyn Houle <email@hidden>) | |
| >Re: Structs versus Vectors (From: John Stiles <email@hidden>) | |
| >Re: Structs versus Vectors (From: "Richard S. Wright Jr." <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.