Multi-platform & 2d OpenGL
Hello,
I'm starting a new project (for windows), but I want to port it to MacOS and MacOS X (at least). What libraries do you recomend me? For graphics I'll use OpenGL and OpenAL for sound, but what about keyboard, mouse and joystick? The game will be developed with C/C++.
Another question: I'm a complete newbie with OpenGL... Do you know any 2D tutorial with OpenGL? I've investigated a little in nehe.gamedev.net, but I couldn't find anything about 2d programming...
All that I want to do is a tile-based "engine" (very simple, only the minimum for my game...)
Thanks a lot and sorry for my bad english,
Marc Casas
I'm starting a new project (for windows), but I want to port it to MacOS and MacOS X (at least). What libraries do you recomend me? For graphics I'll use OpenGL and OpenAL for sound, but what about keyboard, mouse and joystick? The game will be developed with C/C++.
Another question: I'm a complete newbie with OpenGL... Do you know any 2D tutorial with OpenGL? I've investigated a little in nehe.gamedev.net, but I couldn't find anything about 2d programming...
All that I want to do is a tile-based "engine" (very simple, only the minimum for my game...)Thanks a lot and sorry for my bad english,
Marc Casas
Quote:Originally posted by roka-tarat
Thanks a lot and sorry for my bad english,
your english is fine!
if its a 2D game then check out SDL - runs on Mac 9&X, Windows, and Linux. Handles graphics, input, sound and more.
hope this helps,
Codemattic
Quote:Do you know any 2D tutorial with OpenGL? I've investigated a little in nehe.gamedev.net, but I couldn't find anything about 2d programming...
You want to focus a lot on Nehe tutorial 6- texture mapping. If you want to make a tile, just make one polygon and map the tile to it as a texture. For basic tiling this is all you need.
If you want more good stuff for 2D graphics, focus on tutorials 9, 13, and 20.
You can use the info from Tutorial 9 to eliminate the background color from your textures, letting you make odd-shaped 2D graphics. Tutorial 20 builds on this and you can use this to make opaque objects, and 2D overlays (for a GUI perhaps)
Tutorial 13 is basic text drawing.
I'm no expert, and I'm still starting out myself, but this is basically exactly what I'm learning with too.
Let me add that SDL is wicked easy to learn, too. They even have an example that uses OpenGL, which you can copy-paste into PB and it just runs. (Provided you've installed SDL)
Good luck!
Joe
The main question I have about 2d OpenGL is: how can I do that all the polygons are the exacte size I want? I'll explain, I use 32x32 pixels tiles, if I want to make a tile-based game, what's better, one big polygon with a texture calculated very time (with all the tiles and sprites in it) or a polygon for every tile and sprite?
You want a polygon for every tile, but you might want to fit multiple tiles into a single texture for efficiency. The last thing you want to do is change the texture image every frame -- at that point, you'd be doing no better than a software blitter.
SDL isn't the nicest API ever as people seem to make out, but it's a good solid choice for cross-platform game development. If you find it too complicated, GLUT may well serve your needs.
You can make pixel-precise images by setting up a 2D (ortho) projection which matches the pixel dimensions of your window. The OpenGL red book has a couple of hints about making sure you hit pixel boundaries with your geometry which might be worth reading at some point.
SDL isn't the nicest API ever as people seem to make out, but it's a good solid choice for cross-platform game development. If you find it too complicated, GLUT may well serve your needs.
You can make pixel-precise images by setting up a 2D (ortho) projection which matches the pixel dimensions of your window. The OpenGL red book has a couple of hints about making sure you hit pixel boundaries with your geometry which might be worth reading at some point.
Quote:SDL isn't the nicest API ever as people seem to make out, but it's a good solid choice for cross-platform game development.
What are some of the disadvantages of SDL?
The only thing I can see is that since it seems to be implemented on top of Cocoa, there would be more overhead in making an SDL call, as it is making calls to Cocoa that otherwise could have been called directly.
Is the overhead pretty big? Are there any other limitations/performace hits when using SDL as opposed to Cocoa?
Joe
I use SDL and like it. Its staight foward and is Cross platform which is great. SDL also has a large library to load music, sounds, networking, input, output, OpenGL, ect... SDL limits are bound by you. SDL is only 2D no 3D. If you want 3D you have to use OpenGL. So no big deal for me since I like and pefer OpenGL anyway. =)
If you'd ever looked through the SDL source code, you'd know how ugly and hack-like it is underneath 
The API is simply bloated for what most people want to do. It also does things like using blocking event loop APIs, which may not provide the best performance.
The LGPL is slightly annoying, too.

The API is simply bloated for what most people want to do. It also does things like using blocking event loop APIs, which may not provide the best performance.
The LGPL is slightly annoying, too.
(assuming you know a bit about OpenGL)
OpenGL is good for 2D stuff too when setting up the Projection Matrix (in init) you can do this:
glOrtho2D(0, 640, 480, 0);
Then you can plot to the screen with the usual GL_LINES, GL_QUADS using
glVertex2i(x, y);
x should be in the range of 0 - 640
y should be in the range of 0 - 480
good luck
OpenGL is good for 2D stuff too when setting up the Projection Matrix (in init) you can do this:
glOrtho2D(0, 640, 480, 0);
Then you can plot to the screen with the usual GL_LINES, GL_QUADS using
glVertex2i(x, y);
x should be in the range of 0 - 640
y should be in the range of 0 - 480
good luck
Another question... I'm a newbie in Mac OS X developing... I want to use C or C++ for my games/apps, but I'm completely lost with all these libraries... What should I use, Cocoa or Carbon?
And the last question... In a game, what's the "typical" way to read from keyboard or joystick?
Thanks a lot,
Marc Casas
And the last question... In a game, what's the "typical" way to read from keyboard or joystick?
Thanks a lot,
Marc Casas
If you want to use C/C++ then you need to use Carbon.
Quote:Originally posted by roka-taratTypical now, or typical then? In order to achieve greater speed, older games would use GetKeys to get the current state of the keyboard instead of relying on events. I would not recommend that for today's games though. Since computers are quite a bit faster, and handling events is a nicer approach, I would use the event manager to track key up/key down events.
And the last question... In a game, what's the "typical" way to read from keyboard or joystick?

