Jump to content
  • Advertisement
Sign in to follow this  
Grellin

Cross platform compiling (SDL)

This topic is 5395 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been using SDL for a while now on Windows and although I know it is a cross platform API, I had never actually tried. Needless to say I was shocked when it actually worked. I cut and pasted some of my code from Windows MSVC++ 6 to Fedora Core 2 using KDevelope and it compiled and executed flawlessly. I don't know why I was shocked since everything else I have read about SDL has been true, but I was. Anyway, I decided to start making all of my projects for Windows and Linux and had a question for those who may already do that. What are some of the pitfalls I should try to avoid? I will continue to explore this new world of possibility but any heads up would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement
You've got half the battle won using SDL. That shields you from having to do the windowing, input, sound, etc. The only things that might be problematic is if you're used to the Windows API only. Linux, for example, doesn't have one of those pretty "find directory" dialogs via API. You'll have to code something like that yourself.

Just stay away from those sorts of things and you'll be OK. SDL does the hard work for you :).

Share this post


Link to post
Share on other sites
I've not tried VS.net yet, but if you're using VS6 you may find one or two issues with the C++ standard bite you from time to time. A common one for me is
for(int x = 0; x < 2; ++x) { blah(); }
for(int x = . . .
which is fine in C++ but VS6 doesn't like it.

um ... actually, everything else I've done so far just works, so long as you stick with C++. If you start doing old fashioned C things you end up needing different headers (unistd.h etc).

Stick with SDL for timing issues because that's one area that different OS's try to be as incompatible as possible on.

Share this post


Link to post
Share on other sites
If you want to load DLLs (or SOs on Linux), then you'll have to write your own code. If you keep all code in one main program you won't have this problem though.

Share this post


Link to post
Share on other sites
Thanks for the replies. This is really working out better than I imagined. At this point I haven't noticed any difference in performance but I am only using 2d for now. Soon to try incorperating OpenGL with it.

Share this post


Link to post
Share on other sites
Something i see ALOT of people doing wrong in SDL is not using the SDL defined typedefs that wrap over the normal data types (like Uint32 and Sint8).

Share this post


Link to post
Share on other sites
i dont understand the purpose of using the SDL data types in replace of char, int, or short... what IS the point exactly? is it for enianess purposes? and where is the SDL float and double ?

Share this post


Link to post
Share on other sites
Quote:
Original post by graveyard filla
i dont understand the purpose of using the SDL data types in replace of char, int, or short... what IS the point exactly? is it for enianess purposes? and where is the SDL float and double ?

DISCLAIMER: Might not be accurate.

Yep its for diffrent machines. Since mac is big endiean and pc is little endian some data types are diffrent.

Share this post


Link to post
Share on other sites
ok, but, i dont understand.... if i compile my source on a mac, and a mac user runs the program, wont it work fine if i used int, long, short, etc?? i mean, since i compiled (or even just executed) it on a mac, wouldnt it know that i wanted mac endianess? i mean, i doubt theres some sort of macUint8, right? im guessing they call it int too ? so, why even bother?

the only situation i see a problem is in a cross platform networked game. in which case you should be converting from / to host / network byte order when sending / receiving anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!