What should I use, subclassing or delegate (opengl es)?

Member
Posts: 249
Joined: 2008.10
Post: #1
Hi friends.

What is better to create an opengl es game, subclassing or delegate?
Or which one is the easiest one?
and BTW, do you use a timer or a thread to control your app?

Thanks a lot.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #2
I have an OpenGL View class that delegates the drawing and input to a game state class.

For timing I do something like the following:
Code:
while(true){
    // pump events
    while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
    
    update();
    draw();
}

VBL sync is always enabled on the iPhone, so this loop will only run 60 times a second at most (don't assume it though!). What I actually do is a bit more complicated and flexible than that, but it's a good place to start. Maybe I'll post some of my game state code after I clean it up a bit.

This works better than a timer because it only sleeps exactly as long as it needs for the VBL sync. You don't have the timer sleeps mixed in with the VBL sleeps, and it won't randomly skip frames.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Moderator
Posts: 3,579
Joined: 2003.06
Post: #3
Skorche Wrote:Maybe I'll post some of my game state code after I clean it up a bit.

I'd be interested in taking a gander at that. Smile
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  UITextView delegate inconsistency... daveh84 1 2,486 May 29, 2009 11:31 AM
Last Post: daveh84