Skip to main content
GameDev.net gamedev.net
🔒 Locked

Compeletly Cross-Platform Source

Started by TheRealMAN11 Dec 5, 2001 at 11:31 PM 7 replies 350+ views
Original Post
TheRealMAN11
TheRealMAN11
In light of the new sdl article, I was wondering if it was possible to create a complete game with the source being completely cross plaform. Meaning you just change compilers and you have your game on another platform. It seems possible using sdl, opengl, openal, and hawknl. Just wanted some input on this one. (this is kinda how I want my next game to be)
It is foolish for a wise man to be silent, but wise for a fool. Matthew WebMaster www.Matt-Land.com All your Xbox base are belong to Nintendo.
It is foolish for a wise man to be silent, but wise for a fool.
a person
a person
yes, but when dealing with certain things you may need to use #ifdef PLATFORM1
do stuff here for PLATFORM1
#endif
#ifdef PLATFORM2
do stuff for PLATFORM2
#endif
do stuff that works on all platforms
#ifdef PLATFORM1
need some extra stuff on this platform
#endif

you get the picture? (this is how crossplatform libraries work and you may or may not need to do this, but most likly you will at some point)
Dean Harding
Dean Harding
Actually, You don''t really need to use any #ifdef''s at all. So for example, say you''re writing a windowing library that you want to work in both MS Windows and X-Windows, you have a class called CWindow. Now, you implement it twice, once in the Win32_Window.cpp file, and once in the X_Window.cpp file. If there''s enough common code in them both, you can have a base class for the window class (but still have each platform-specific class called the same thing), like you might have CWindow as the base class, and then implement CWindowImpl in both Win32_Window.cpp and X_Window.cpp. Now, in your Win32 makefile, you include only the Win32_Window.cpp file, and in your X-Windows makefile, you include only X_Window.cpp.

Simple, and no (evil) #ifdef''s!


codeka.com - Just click it.
Fruny
Fruny
Then you have to find a cross-platform make utility...
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Dean Harding
Dean Harding
No you don''t, you just write a make script for each platform (using whatever native make utility is on that platform, GNU make on linux, nmake on windows, etc) - you can''t get away from that; you''d have to anyway.


codeka.com - Just click it.
Kwizatz
Kwizatz
Actualy if you use Mingw32, you can even use the same makefile (and GNU Make), heck! if you make a cross mingw32 compiler, you can even code for Windows under Linux, and test your program with WINE but some of you might find that sick and twisted . . . but then, the script for cross compiling mingw is hosted at libsdl.org . . . perhaps SDL for Windows is compiled under Linux?

bobatefrei
bobatefrei
I use wxWindows and OpenGL. They are both cross-platform and on the wxWindows site, I''ve found some utilities to generate makefile to gcc and vc++

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.