SDL dev for portability : Howto question

Started by
7 comments, last by hotdot 22 years, 3 months ago
Ok here is my problem, i want my game to be portable on multiple platform. I only have access to a XP workstation, no linux and mac though i am targeting these. First my major concern is developing with MsVC. I know it is not the best dev tool for portability because of ms related stuff. But in a way i could not compile in other platform if i wanted because the compiler cant(correct me here if i am worng plz). So i tried Codewarrior, and i was suprised that it didnt featured data member auto-completion (one feature i REALLY apreciate). Is there other dev tool i can use for that kind of job(compile all type of platform code on microsoft platform...) ? Secondly, how can we write true portable code with SDL, i mean just for the entry function (i.e. WinMain(...), Main(...)) is there a multiplatform entry fonction that i could only write once (Mac code references isnt well documented) ? As for headers and stuff like that i know that if i use ANSI stuff it should be supported on all platform right ? if any of you knows good links to multiplatform coding it would be nice also. I would really appreciate input because my project isnt very far so i can still work things out apropriately. thanks May the code be with us !
May the code be with us !
Advertisement
Use Delphi/Kylix, SDL, OpenGL combo. For demos (x-platform) on SDL and Delphi visit http://www.delphi-jedi.org and click on the link pointing to SDL.

You don''t need to use Delphi/Kylix. I''m writing a 100% portable (between Windows and Linux, I haven''t tested MacOS since I don''t own one) engine in C++ without a problem. SDL is somewhat difficult to setup in MSVC, but it''s very possible (hey, I did it). Besides SDL I''m also using OpenGL, GLU, OpenAL, VorbisFile, and ZLib; all of which are easily portable.

SDL''s entry point is always "int main(int argc, char *argv[])". You can''t leave out those parameters in MSVC or it won''t work.

[Resist Windows XP''s Invasive Production Activation Technology!]
"You can''t leave out those parameters in MSVC or it won''t work."

what do you mean by that ? this is my entry function :

//
#include "Main.h"

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CMain Main;

return Main.GameFunction(hInstance);
}

this is all you need to make it work on windowz...but then again the winmain isnt very portable. As for your knowledge i am developing in C++. Do you have more specific details on how you have implemented your portable code and how do you procede to make binaries...do you need a linux env. to make linux binairies ? or is it posible to use gcc in windowz ? and is gcc capable of generating mac binaries ?
May the code be with us !
Of course WinMain isn''t portable. If you''re using WinMain you''re doing it wrong. You should be using main, like I said. I simply use those libraries, you don''t have to do anything else, besides being cautious, to have a single fully crossplatform codebase. I built my library in Linux. You can install GCC in Windows too, but I''m not sure how to set it up to cross compile for Linux. GCC can also compile for Mac but, like I said, I don''t know how to set it up to cross compile.

[Resist Windows XP''s Invasive Production Activation Technology!]
quote:Original post by Null and Void
SDL''s entry point is always "int main(int argc, char *argv[])". You can''t leave out those parameters in MSVC or it won''t work.


Hi,
I hope this is only for windows, because I have used int main() in linux - no parameters and it works fine.


Hello from my world
If you are using SDL, then you use:

int main(int argc, char** argv)

even if you are using Windows. SDL provides it''s own WinMain behind the scenes, does some basic setup, then calls your main function.

That makes it really handy, since SDL takes care of the instance handles, message pumps and various other non-portable things.

Hope this helps.

Take care,
Bill
To the AP who mentioned Delphi: c++ / SDL is way more portable than Delphi / SDL. Look at how many platforms are supported by SDL - why would you want to restrict your game to only two? It goes against the idea of using SDL in the first place...

I usually write char *argv[] rather than char **argv. It makes no difference, though...
quote:Original post by flame_warrior
Hi, I hope this is only for windows, because I have used int main() in linux - no parameters and it works fine.

Like I said: MSVC.

[Resist Windows XP''s Invasive Production Activation Technology!]

This topic is closed to new replies.

Advertisement