PDA

View Full Version : Apple "OpenGL Game Template"


OneSadCookie
2006.08.03, 04:31 AM
New sample code posted today -- Apple "OpenGL Game Template"

http://developer.apple.com/samplecode/OpenGL_game_template/index.html

OneSadCookie
2006.08.03, 04:45 AM
On quick review, we, the IRC channel, have decided that this template is complete rubbish. Use it at your own risk!

aarku
2006.08.03, 05:02 AM
But no one has a better free one online anywhere, so it rocks by default.

OverTheEdge sells an excellent "OpenGL Game Template," however. *ducks and quacks*

-Jon

OneSadCookie
2006.08.03, 05:09 AM
<cough>http://onesadcookie.com/svn/repos/GameShell</cough> :p

aarku
2006.08.03, 05:29 AM
No Xcode project, no dice. :D

OneSadCookie
2006.08.03, 05:38 AM
Stick the source files in any Xcode project and you're done... it's not a library, it doesn't build anything useful.

BeyondCloister
2006.08.03, 06:01 AM
I've not had a chance to look at the Apple stuff or the GameShell yet (not at home and MacBook dead), but do either of them use GLUT? The reason I ask is that I have seen mentioned on here numerous times that GLUT is okay but not for a commerical game.

OneSadCookie
2006.08.03, 06:25 AM
No, both use Cocoa, as does SDL.

GLUT's unconfigurable preference dialog, lack of good screen resolution information, and limited keyboard and mouse handling really cramp it for a finished game. It's a bit easier to set up than SDL though, so it can be good early in the development cycle when quick results are more important than slick results ;)

Skorche
2006.08.03, 06:52 AM
On quick review, we, the IRC channel, have decided that this template is complete rubbish. Use it at your own risk!

Wow, no kidding... No menus, and if you close the window it keeps running and doesn't respond to cmd-Q. :???:

KittyMac
2006.08.03, 09:50 AM
On quick review, we, the IRC channel, have decided that this template is complete rubbish. Use it at your own risk!

Wow, that is absolute rubbish. If they entered a few uDG contests before they decided to become game developers, they'd have a much better sample.

Why the heck does ESC quit the application? Just because we write games, suddenly the human interface guidelines no longer apply?

Duane
2006.08.03, 12:05 PM
I sense that there was a deadline and they were too close to it....

Ingemar
2006.08.03, 02:52 PM
Why the heck does ESC quit the application? Just because we right games, suddenly the human interface guidelines no longer apply?
You mean "write", right?

I have become very sceptical to Apple's official sample code. It is often beginner-level code, not speaking of audience but of code quality. Every time I learn a new Apple API, the first thing I do is to write a better demo than Apple provided.

And human interfaces, that's a BIG problem in games. Many, many games insist on using 80's-style interfaces, wading through horribly clumsy menus. And quitting by ESC without asking is an absolute nono, and still I have seen it in commercial games.

KittyMac
2006.08.03, 03:03 PM
You mean "write", right?

Fixed, thanks! :sneaky:

And human interfaces, that's a BIG problem in games. Many, many games insist on using 80's-style interfaces, wading through horribly clumsy menus. And quitting by ESC without asking is an absolute nono, and still I have seen it in commercial games.

Which makes it all the more important that Apple provides good sample code. My point was we've had many uDG entries which display bad Mac programming practices, and that's usually the first feedback they receive.

Apple is supposedly taking a bigger stance with games at this WWDC, I hope they get it right.

TomorrowPlusX
2006.08.03, 03:57 PM
On quick review, we, the IRC channel, have decided that this template is complete rubbish. Use it at your own risk!

Any particular parts which are rubbishy? "The whole thing" is not the answer I'm looking for :p

Frank C.
2006.08.03, 05:34 PM
Well, switching to fullscreen results in a nice blank display for me. If Apple really wants to help game devs they need to do better than this. I hope yer all using those feedback links at the bottom of the page...

KittyMac
2006.08.03, 06:38 PM
This was just a skim.. what'd I miss?

Right, basically it is not an "OpenGL based game template" as the title suggests. It is simply a hodge-podge of previous OpenGL and OpenAL samples thrown together.

If it were advertised as a "Window/Fullscreen OpenGL with OpenAL" sample, I think we'd be fine with it (except for Frank C., for which it doesn't work :p)

aarku
2006.08.03, 06:39 PM
Any particular parts which are rubbishy? "The whole thing" is not the answer I'm looking for :p

Feel free to add onto my list...



No screen/resolution selection. This is one of the main things you want a template like this to do as it's not trivial.
It's organized poorly. Input being handled in Renderer.c ??? (The Readme.txt says "Renderer.h and Renderer.c define the interface that the developer can choose to implement to suit their own needs." Yeah, I got a zero line template called "main.c" that does this just as well.
Game does not pause when in the background
The key handling should be abstracted, not a switch statement with magic numbers. See next point.
There is a half assed attempt to make this more portable. On one hand there is #define PATH_SEPARATOR "/" , but on the other hand there are direct calls to CoreGraphics in the same source file. Pick one!
"#define MAX_STR_LENGTH 1024" What the heck happened to PATH_MAX?
Poor OpenAL code. It doesn't handle errors very well at all.
Lame comments: alSourcePlay(gSource); // play the sound
Very few Mac OS X conventions followed. Come on, how hard is this in 2006 with Cocoa? If it was 1996 I'd have pity.
The sound loading function is hardwired to play one specific sound at load time. That's insanely unuseful! What's a template for, again?
I just find this funny from an Apple example: // OpenAL lessons: <http://www.devmaster.net/articles.php?catID=6>
usleep(1000000/getGameFPS()); Their FPS model assumes your game loop doesn't take any processor time. This is not useful. Why show a really wrong way to do something?
What's the point of programmically creating everything? If there is one, it's no excuse to skip little things like "menu bar" and "command-q quits."


This was just a skim.. what'd I miss?

-Jon

edit: Hehe, tweaked my post after a reply accidently, sorry :)

aarku
2006.08.03, 06:44 PM
Right, basically it is not an "OpenGL based game template" as the title suggests. It is simply a hodge-podge of previous OpenGL and OpenAL samples thrown together.

If it were advertised as a "Window/Fullscreen OpenGL with OpenAL" sample, I think we'd be fine with it (except for Frank C., for which it doesn't work :p)
The timing of the example suggests they will be endorsing it at WWDC in one of their games sessions or something. Too bad they're under NDA so I can't post a "roast" video when it comes to an audience Q&A.

-Jon

KittyMac
2006.08.03, 06:46 PM
Too bad they're under NDA so I can't post a "roast" video when it comes to an audience Q&A.

I'll be at WWDC too, we can roast them together :)

FreakSoftware
2006.08.03, 06:57 PM
Feel free to add onto my list...

So are you going to stand up at WWDC and shove the list in their faces? :D

Edit: bah -- I'll take those posts as a yes. I should have read ahead.

OneSadCookie
2006.08.03, 07:02 PM
I'm looking forward to a vivid description of the particular shade of red on their cheeks :D

monteboyd
2006.08.03, 08:05 PM
Heh, they've taken the sample down, the link goes to a page not found error.

FreakSoftware
2006.08.03, 08:21 PM
Heh. You're right. It's still listed in the "New and Updated" block in the sidebar but they removed it. Obviously someone at Apple reads the forums. :)

aarku
2006.08.03, 08:28 PM
Heh. You're right. It's still listed in the "New and Updated" block in the sidebar but they removed it. Obviously someone at Apple reads the forums. :)
Lucky I grabbed it before they took it down so I can use it for my upcoming MMORPG. ;)

-Jon

KittyMac
2006.08.03, 09:01 PM
Heh, they've taken the sample down, the link goes to a page not found error.

It is possible that they mean to use it during a WWDC session, and that it was not supposed to be posted until after WWDC.

Or, as someone noted, they are reading these forums.

OneSadCookie
2006.08.03, 09:07 PM
Lucky I grabbed it before they took it down so I can use it for my upcoming MMORPG. ;)

-Jon

:lol: LOL :lol:

Xenos
2006.09.03, 07:26 PM
<cough>http://onesadcookie.com/svn/repos/GameShell</cough> :p

OneSadCookie,

I was looking through the GameShell source code you linked above. I was wondering why you defined your GSOpenGLView class as and NSView as opposed to an NSOpenGLView?

Also is there anything wrong with using NSAnimation to handle the timing of your animations instead of NSTimer?

Please bear with me, I am very new to OpenGL and fairly new to Cocoa so there may be some obvious reasons for doing this that my lack of knowledge is not allowing me to see. Thanks.

OneSadCookie
2006.09.03, 07:58 PM
I was looking through the GameShell source code you linked above. I was wondering why you defined your GSOpenGLView class as and NSView as opposed to an NSOpenGLView?

Good question :) I seem to recall that I had problems in full-screen mode with NSOpenGLView setting the context back to its own context, rather than my full-screen context. It's been a long time though, so I'm not 100% certain any more...

Also is there anything wrong with using NSAnimation to handle the timing of your animations instead of NSTimer?

I have never used NSAnimation, but I suspect NSTimer is better -- you always want to run as fast as you can and block in -[NSOpenGLContext flushBuffer] rather than running at some random frame rate, for example.

FreakSoftware
2006.09.03, 08:29 PM
NSAnimation isn't at all useful for the core timing of a game.

aarku
2006.09.04, 01:55 AM
It. Is. Back.

http://developer.apple.com/samplecode/OpenGL_game_template/index.html

!?

KittyMac
2006.09.04, 02:00 AM
Oh dear, it is unchanged as well. :wacko:

OneSadCookie
2006.09.04, 04:34 AM
Bug filed... I suggest others complain too :)

TomorrowPlusX
2006.09.05, 10:03 AM
There was -- for what it's worth -- one good thing in the now defunct demo. It showed a hacky ( but functional ) way to convert mouse coordinates when switching to a fullscreen context in a different resolution. It even linked to a thread here on iDevGames regarding the hack.

ksiazegz
2006.09.05, 06:37 PM
hi guys,

You're right that Apple enginers read these forums, I am one of them and let me say that the template is not finished.

If you want the template to rock, please work with us by filing bugs, as some of you have already done. You are the experts here, Apple doesn't make games, so we need your feedback!


cheers

OneSadCookie
2006.09.05, 06:47 PM
Huh, I wasn't aware that Apple employs people in Canada...