iDevGames Forums
What API do 2D MacOSX games use? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: What API do 2D MacOSX games use? (/thread-7120.html)

Pages: 1 2 3 4 5


What API do 2D MacOSX games use? - joephish - Apr 27, 2003 01:09 PM

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?


What API do 2D MacOSX games use? - macboy - Apr 27, 2003 01:11 PM

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. :?:


What API do 2D MacOSX games use? - Josh - Apr 27, 2003 01:23 PM

OpenGL is very fast and very easy. Unless you want to target old computers, go with OpenGL.


What API do 2D MacOSX games use? - Ice Cream Joe - Apr 27, 2003 01:24 PM

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.)


What API do 2D MacOSX games use? - Zwilnik - Apr 27, 2003 01:36 PM

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.


What API do 2D MacOSX games use? - Tycho - Apr 27, 2003 01:42 PM

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.


What API do 2D MacOSX games use? - joephish - Apr 27, 2003 01:48 PM

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!


What API do 2D MacOSX games use? - Tycho - Apr 27, 2003 02:04 PM

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.


What API do 2D MacOSX games use? - Ice Cream Joe - Apr 28, 2003 11:11 AM

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.


What API do 2D MacOSX games use? - Mars_999 - Apr 30, 2003 04:02 PM

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.


What API do 2D MacOSX games use? - GoodDoug - May 1, 2003 10:26 AM

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.


What API do 2D MacOSX games use? - cheez0r - May 1, 2003 10:47 AM

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'


What API do 2D MacOSX games use? - skyhawk - May 1, 2003 11:44 AM

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 )


What API do 2D MacOSX games use? - cheez0r - May 1, 2003 01:09 PM

yeah i opened up my opengl book and was like 'i'm dumb' after asking that question Wink


What API do 2D MacOSX games use? - AJ Infinity - May 3, 2003 08:07 PM

Don't forget about kelvin's CocoaBlitz.