I want to be the next Will Wright
February 6, 2007 6:00 AM   Subscribe

Cross-Platform SDL/OpenGL programming - I want to write some software for Mac and PC. I know C at a moderate level for data processing work, but have never done advanced programming nor graphics work. I'm 100% self-taught on computers. Where can I find some good resources that are NOT dead trees on how to get started?

I can find Cocoa tutorials out the yinyang, but I'm not all that interested in just plain Cocoa... it's kinda hard to compile Objective C in VC++2k5. In the same vein, I can find lots of dead trees books that promise to teach me all that I'll ever need to know to program t3h most wonderfulest gam3z in t3h world, but they all seem to be aimed at either experienced programmers or 13 year olds.

Most of what I'm doing involves moving PNG sprites around. I'm not yet looking to do anything 3d or particularly fancy.

This is a long-term project and I'm willing to acquire the skills as necessary to see it through. I just can't seem to find a good place to get started besides some basic "Here's how to access the SDL libs on Mac" tutorials. Great. Now what do I *do* with SDL, and how do I build something that I can compile on both platforms?

(Shucks, if it wasn't such a dog performance-wise, I'd use pygame. :-P)
posted by SpecialK to Computers & Internet (14 answers total) 1 user marked this as a favorite
 
ClanLib is an example of a cross-platform toolkit library (Linux, Windows, OS X) which uses SDL or OpenGL for 2D graphics. You could get started coding some simple games with that. You can think of it as a cross-platform wrapper around SDL, if that helps. And looking at the source code for the library itself might give you some idea of how to write cross-platform code for SDL/OpenGL at that level. It has some bare-bones documentation which should get you up and running.

I remember looking into Ogre3d as a cross-platform 3D engine a while back. I know you're not looking to do 3D yet, but I do seem to remember the implementation of the cross-platform stuff being quite well documented/commented, so that might be worth a dig too.
posted by chrismear at 6:33 AM on February 6, 2007


I've only used OpenGL for a class that I took, and I'm not very familiar with SDL, but Kiet Le has taken all of the C code from the OpenGL RedBook and converted it into Java so that they can be opened with Java Web Start. If you are just learning OpenGL, the RedBook is a great place to start, and Java will probably be more cross-platform friendly. All of the source code, jnlp, and class files are located in the .jar files listed in the right side column. .jar files are essentially java zip files, so if you want to get right at them, just change the extension to .zip and open with your favorite archiving program.
posted by Roger Dodger at 7:58 AM on February 6, 2007


After looking at SDL, my answer is not what you are looking for, but may be interesting anyway!
posted by Roger Dodger at 8:05 AM on February 6, 2007


Response by poster: Actually, I'm looking through ClanLib and I think it's a bit closer to what I want ... that means I have to learn C++, but when's that ever stopped me from doing anything?
posted by SpecialK at 8:24 AM on February 6, 2007


ClanLib is an example of a cross-platform toolkit library (Linux, Windows, OS X) which uses SDL or OpenGL for 2D graphics.

I used to work at the Virtual Reality Applications Center at Iowa State as a student, and people worked with lots and lots of crazy-ass APIs. One lesson I took away is: work with old, established APIs the guys there were always jumping on the latest new thing, which was invariably buggy, poorly documented, missing needed features or otherwise a huge pain in the ass. I did some Open GL code while I was there, but I tried to keep it as simple as possible. Sometimes there would be build conflicts between the libraries (like using different versions of the libc, ugh)

I was never a graphics guru like a lot of the people there, and my 3-D kung fu was weak, and mostly involved using other APIs and just moving objects around. I tried to avoid using these trendy APIs as much as possible, and wrote plain C++ code with OpenGL calls, as well as doing model loading using various scene graph libs. One of my programs became "cross platform" by using "#ifdef win32" statements. It's not that hard to do.

Anyway, the point is, avoid using trendy brand new libraries (clanlib hasn't even reached 1.0) and stick to the basics. That's been my experience, at least in terms of doing 3-D, which I haven't done much of.

Another thing to keep in mind, I don't really think the technology matters to much as far as the basics of 2D programming. I wrote my first "game" for win16 using borland's "Object Windows Library" with graphics done using the windows Device Context. I've done tons and tons of graphics programming using Java's Graphics2D api (and it's precursor). It's all very straightforward and for 2D, it transfers easily: You are basically just drawing things at certain coordinates (sometimes with scaling) based on your games internal state.

Anyway the point I was trying to make was avoid clanlib and stick with things like SDL and OpenGL.
posted by delmoi at 9:04 AM on February 6, 2007


Wow, that post was scatterbrained. I got distracted a few times and came back to it.
posted by delmoi at 9:05 AM on February 6, 2007


Response by poster: No, actually, you made a good point ... one that i'd reached myself about five minutes ago after parsing and thinking on some of the ClanLib docs, and seeing the complete lack of activity on their forums.

My only problem with OpenGL so far is that people seem to publish everything on trees and/or do everything with Windows, and I can't seem to find a way to get started with OpenGL on Macs. Even the Apple Developers website says ... go buy the damned trees.

Looks like I get to go buy some books. Hopefully Half Priced Books will have something.
posted by SpecialK at 9:44 AM on February 6, 2007


Surprised no one has mentioned the NeHe tutorials yet. I've also don't a lot of SDL programming and I have to stay it's a really nice framework. The SDL tutorials page has a lot of resources for learning SDL.
posted by cmicali at 9:52 AM on February 6, 2007


BTW the NeHe tutorials have a special section dedicated to developing OpenGL on Mac OS X
posted by cmicali at 9:54 AM on February 6, 2007


And one more, SDL and OpenGL together under OS X
posted by cmicali at 9:56 AM on February 6, 2007


Cmicali beat me too it but I am seconding nehe. They had the best info when I was playing around with opengl
posted by phil at 9:58 AM on February 6, 2007


Response by poster: cmicali -- Oh, I didn't realize that the tutorials were still there. Most of gamedev seems to be completely down, including the non-static content at nehe... and as I say that, nehe.gamedev.net 'fall down go boom' while I was trying to load another tutorial.
posted by SpecialK at 10:15 AM on February 6, 2007


SpecialK, check the libraries. I know the university libraries by me are loaded with OpenGL and graphics programming books.
posted by Roger Dodger at 12:06 PM on February 6, 2007


Oh, and I forgot about the game programming class I took. We used the Allegro game engine. It handled input, output, sound, graphics. It's pretty old, but it is cross platform and tons of examples and tutorials are available. If you are doing a sprite based game, it's perfect. We also used Mappy for level editing. It's not SDL/OpenGL, but if you are doing simple 2D game programming, it might be a way to go.

Class project was a 2D platformer. Turned out very nice.
posted by Roger Dodger at 12:17 PM on February 6, 2007


« Older I Can Hear Just Fine, Thanks   |   Help me drive in the snow. Newer »
This thread is closed to new comments.