Archived

This topic is now archived and is closed to further replies.

hotdot

SDL dev for portability : Howto question

Recommended Posts

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 !

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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!]

Share this post


Link to post
Share on other sites
"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 ?

Share this post


Link to post
Share on other sites
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!]

Share this post


Link to post
Share on other sites
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.


Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites