What API do 2D MacOSX games use?

Member
Posts: 20
Joined: 2003.04
Post: #1
I'm hoping that this question hasn't already been asked lots of times before, but I was wondering what APIs all the shareware Mac OS X games use?

I got pretty far through developing a game using SDL (in pure C), but found it to be pretty frickin' slow for complete screen flips (I couldn't get double buffering to work for some reason either).

I had a look at SpriteWorld (soon to be 3.0) and SAT, but the way they handle graphics is confusing to me - I just want to be able to blit images onto a buffer with colorkeys, then flip front and back buffers.

The thing preventing me from going all out and learning Cocoa/ObjC properly is that I really wanted to make it cross platform to start with, and also I heard that Cocoa's Core graphics were really slow?!

I feel like I'm running out of options now. Should I be learning OpenGL even though I'm not doing anything 3D, just to get the speed of hardware acceleration?
Quote this message in a reply
macboy
Unregistered
 
Post: #2
Quote:Originally posted by joephish
Should I be learning OpenGL even though I'm not doing anything 3D, just to get the speed of hardware acceleration?
Probably. :?:
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #3
OpenGL is very fast and very easy. Unless you want to target old computers, go with OpenGL.
Quote this message in a reply
Ice Cream Joe
Unregistered
 
Post: #4
I personally use a combination of SDL and OpenGL. The OpenGL is for all the graphics, and SDL is for the rest of the application. If you have most of a game already in SDL, just replacing the graphics with OpenGL shouldn't be nearly as hard as rewriting the whole thing. OpenGL is also cross platform.

And OpenGL works just as good for 2D games as it does for 3D. You can also take advantage of its rotation and blending functions (not to mention the hardware acceleration.)

(Edit: If you use OpenGL, you can also use GLUT, which can handle basic event loops and such. Very easy stuff if your game is relatively simple.)
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #5
I switched to OpenGL at the start of the Airburst Extreme project and it's definitely the way to go for 2D games, especially if you're targetting OS X.
Quote this message in a reply
Tycho
Unregistered
 
Post: #6
Quote:I got pretty far through developing a game using SDL (in pure C), but found it to be pretty frickin' slow for complete screen flips (I couldn't get double buffering to work for some reason either).


The Mac OS X SDL implementation seems rough in a few areas. From my experience, due to the way OS X works, every window you create is double buffered, whether you specify it or not. That means that if you are doing your drawing to an offscreen buffer and then copying that to the screen, you are effectively triple buffering. You can just create a window without double buffering specified, and use something like
[SOURCECODE]SDL_UpdateRect(surface, 0, 0, 0, 0);[/SOURCECODE]
to flip the buffers.
Quote this message in a reply
Member
Posts: 20
Joined: 2003.04
Post: #7
Ice Cream Joe - what do you mean you use SDL for the rest of the application? You use it's other capabilities such as audio etc?

Tycho - yeah I've tried looooads of different stuff. I even started doing really complicated stuff with detecting which bits I need to redraw and using UpdateRect properly, but even that got slow! (I'm sure i didn't have a bottleneck elsewhere either). I'm just really tired with fussing about with it.

You guys have made up my mind now though - I'll definitely be going with OpenGL. Sounds like the answer to my problems, and will be crossplatform. Thanks!
Quote this message in a reply
Tycho
Unregistered
 
Post: #8
What I'm saying is that you can just create a window as if it were single buffered and draw directly to it. Since all windows are really double buffered in OS X, calling UpdateRect basically flips the buffers. If this is still too slow (or if you've already tried it), then OpenGL would be a good choice. It's really not much harder than using SDL, and you get lots of useful stuff for free.
Quote this message in a reply
Ice Cream Joe
Unregistered
 
Post: #9
Quote:Originally posted by joephish
Ice Cream Joe - what do you mean you use SDL for the rest of the application? You use it's other capabilities such as audio etc?


Yeah. Pretty much everything that isn't graphics.

Although, for audio I strongly considered FMOD. I ended up going with SDL_mixer- mostly because I just wanted to learn it and get practice using it. The audio that comes with SDL proper was a little too low level for me, and doesn't really offer any additional capability than SDL_mixer.
Quote this message in a reply
Mars_999
Unregistered
 
Post: #10
SDL has a problem with double buffering in OSX.

Q: Why doesn't page flipping work?
A: The SDL_DOUBLEBUF flag (and hence page flipping) is unsupported on Mac OS X. There is no support in the operating system for this feature.

Prior to version 1.2.6, SDL did not report an error when SDL_DOUBLEBUF was used, but instead returned a single-buffered surface. This resulted in various visual anomalies, depending on the application.

The only good alternatives are to use a software surface instead (SDL_SWSURFACE), or use OpenGL. With OpenGL, you'll have to write your own blitting engine, or borrow someone elses.


Use OpenGL with SDL and if you're are not interested in Perspective viewing use Ortho projection for 2D games.
Quote this message in a reply
Member
Posts: 104
Joined: 2002.04
Post: #11
I've done plain Quartz (ZedNought and upcoming game) and OpenGL (Headache) for 2D graphics. Both are useful and usable. I think that in the end, OpenGL may provide slightly more headaches, but is slightly faster. So, if you want something easy, that won't be too taxing... try Quartz. If you don't mind getting your hands dirty, and you need the speed, go OpenGL.

I can't comment on SDL, as I haven't used it.
Quote this message in a reply
cheez0r
Unregistered
 
Post: #12
Hmm.. I'm interested in this type of thing. Making a 2D game using OPenGL, but I haven't found TOO much info on it, what's this ORTHO projection?
also, by doing this, i'd be able to use 3D Models in the game and full animate them, etc? I plan on using a top-down 2D view for the game, but using models as the 'pieces'
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #13
orthographic view means there is no perspective... that means when looking top down, things on the right of your screen look the same on the left, bottom, top, anywhere, just like in a normal 2D game. You can use 3D models just like you normally would (I tried this in my game BOB2 and got some odd blending problems, but I used some workarounds so you never notice Wink )
Quote this message in a reply
cheez0r
Unregistered
 
Post: #14
yeah i opened up my opengl book and was like 'i'm dumb' after asking that question Wink
Quote this message in a reply
AJ Infinity
Unregistered
 
Post: #15
Don't forget about kelvin's CocoaBlitz.
Quote this message in a reply
Post Reply