Cross-platform Solutions

DJBlufire
Unregistered
 
Post: #1
A friend of mine is working on a OpenGL game engine almost single-handedly and is having some real progress. He's looking to add in other elements to his engine, namely keyboard/mouse input, sockets for multiplayer capability, and a sound library. He's asked me to find a solution for any or all (hopefully Smile) of these. Seeing as how he's on a PC (though he's used macs in the past) and I'm on a mac, one of my biggest criteria for solutions is cross-platform compatibility. Secondly, I'm looking for easy-to-learn set of libraries (heh, who isn't?).

To recap, I'd love it if you guys had some suggestions on cross-platform solutions for:

1. Keyboard/mouse input
2. Sound
3. Sockets

I know this sounds like a lot, but any direction is a big help!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
1) SDL
2) SDL_mixer
3) SDL_net

http://www.libsdl.org/
Quote this message in a reply
Founder
Posts: 1,139
Joined: 2002.04
Post: #3
Might want to add this to the FAQ.
Cool

Carlos A. Camacho,
Founder
iDevGames
Quote this message in a reply
DJBlufire
Unregistered
 
Post: #4
Just a few thoughts after glancing over the intros for the SDL projects:

from the docs for SDL_net:
Quote:SDL_net is a network library that is used with the SDL library, and almost as portable.

What's that supposed to mean? What do you have to do that isn't portable?

For SDL_mixer:
It seems that this is a heavy-duty package for mixing of sounds... would I need this in a game though, and are the audio tools that are built into SDL not enough?

Thanks for the link, it looks like it will be very valuable. Grin
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
"nearly as portable" means there may be platforms that SDL has been ported to that don't yet have an SDL_net port. Fortunately, Mac OS X, Windows and Linux have ports of both.

You may not need the full functionality of SDL_mixer; I'm not sufficiently familiar with what SDL provides "raw" to know. It'll also depend on your precise sound needs.
Quote this message in a reply
DJBlufire
Unregistered
 
Post: #6
SDL looks pretty good so far, but is there a carbon version of SDL? So far i'm stuck either building it in 9 with CW or in OS X with project builder... i would love to be able to do a multi-target project file (for X and windows) in OS X with CW.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #7
The OS X version of SDL uses Cocoa. You should be able to build it with Project Builder and then use the framework with any recent version of CodeWarrior...

Don't bother trying to have a single binary for 9 & X, just treat them as two separate platforms. It's way less work in the long run...
Quote this message in a reply
DJBlufire
Unregistered
 
Post: #8
hmm... now I can't even seem to get the tools to compile in CW under OS9 or OS X... always has a linking error: "main undefined" and then says that it was referenced from a built-in library... if I try to use precompiled SDL libraries, it gives the same link error but states that it was referenced from SDLmain.lib or something... there must be something fundamental i'm doing wrong, because i'm taking the SDL CW projects out of the box and compiling them, only to get these link errors!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #9
You need to include SDL_main.c/m and SDL_main.h in your project.
Quote this message in a reply
DJBlufire
Unregistered
 
Post: #10
Still isn't working in CW... I've included SDLMain.h and SDLMain.m in my project, along with main.cpp and linked the OpenGL and SDL frameworks (in addition to the normal ones). I'm still getting these wierd link errors, but why?

Code:
Link Error   : undefined: 'WriteCharsToConsole' (code)
Referenced from '__write_console' in MSL_All_Mach-O_D.lib

Link Error   : undefined: 'WriteCharsToErrorConsole' (code)
Referenced from '__write_console' in MSL_All_Mach-O_D.lib

Link Error   : undefined: 'ReadCharsFromConsole' (code)
Referenced from '__read_console' in MSL_All_Mach-O_D.lib

Link Error   : undefined: 'RemoveConsole' (non lazy ptr IL)
Referenced from 'check_console' in MSL_All_Mach-O_D.lib

Link Error   : undefined: 'InstallConsole' (code)
Referenced from 'check_console' in MSL_All_Mach-O_D.lib
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #11
Looks like you need the SIOUX library or something. Weird.
Quote this message in a reply
athomson
Unregistered
 
Post: #12
Quote:Originally posted by DJBlufire
Still isn't working in CW... I've included SDLMain.h and SDLMain.m in my project, along with main.cpp and linked the OpenGL and SDL frameworks (in addition to the normal ones). I'm still getting these wierd link errors, but why?

It's a feature (not the errors but the reason they exist). Metrowerks are moving from the SIOUX library to the standard console in Mac OS X but the conversion isn't very stable as yet. You need to add a file called "console_OS_X.c" to your project. It should be in the MSL/MSL_C/MSL_MacOS/Src directory.

Andrew.
Quote this message in a reply
DJBlufire
Unregistered
 
Post: #13
Awesome, it works!! Thank you so much.

Someone should make a note of this somewhere, as I don't think i'll be the only one who will run into this. Rolleyes
Quote this message in a reply
athomson
Unregistered
 
Post: #14
Quote:Originally posted by DJBlufire
Someone should make a note of this somewhere, as I don't think i'll be the only one who will run into this. Rolleyes

It's in the Mach-O development release notes (Making_Mach-O_Projects_Note.txt to be exact), though I saw it in one of the CodeWarrior news groups I read. See, sometimes reading the documentation is a good thing Grin

Andrew.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cross platform question kordeul 13 5,098 Aug 22, 2007 03:09 AM
Last Post: kordeul
  Cross-platform gui? Duane 13 5,583 Jul 6, 2007 06:38 PM
Last Post: mac_girl
  Best cross platform API for PC & MAC Tarek Demiati 6 3,269 Apr 16, 2006 03:07 PM
Last Post: Dan Potter
  cross-platform code leggo 35 12,659 Jul 18, 2004 05:05 PM
Last Post: Fenris
  Cross platform game code on a budget Carlos Camacho 7 3,756 Apr 19, 2003 09:29 PM
Last Post: Mars_999