|
Post by BloodKnight on Apr 22, 2007 11:41:56 GMT -5
Ok, so I'm working with Allegro right now, it seems like a good game development library. It also seems to be compatible with many OSs, in particular Mac OS X and Linux. I wish to make any future games I develop, available for these OSs, you know, multi-platform and all that.
If anyone can help me answer this, how do I actually port? Could I compile multi-platform ports, just using Windows, or would I have to be using the target OS to compile a port? I'm using Dev-C++ for compilation by the way.
|
|
|
Post by Doan the Nado on Apr 22, 2007 12:49:15 GMT -5
I know that it is possible to compile for other operating systems using gcc, but I am not as familiar with Windows. The Google search term you want is "cross compilation" or something to that effect (i.e. "cross compilation in Windows"). If you're not worried about providing the source (there are various licenses such as the GPL which protect the code as your property and prevent others from copying it and taking credit), you can simply create a Makefile for your code, compress all the files into a single package which includes the Makefile, and then put it out there. Also be sure to list the requirements (such as Allegro). If you do not want to provide source code, then cross compiling is your only option. If you can't find a suitable Windows compiler which can compile Linux binaries, you should give gcc a shot. In order to use it, you may have to install Cygwin, which provides a unix environment on top of Windows. Actually, if someone has written a howto for cross compilation in Windows, I would bet that it would utilize gcc in Cygwin. The only other issues you might run into involve your code. Be sure to not use any functionality that is provided by winbase.h or windows.h (or whatever other windows-specific stuff there is). Make sure that you instead locate the desired function in Allegro, which will be intentionally written to use the correct libraries depending on what system it is compiled for. And thanks a lot for making the effort to make your program cross-platform. I don't have anything against people using Windows, but I do get really annoyed when developers pretend like it's the only kind of computer there is. Your efforts are to be commended .
|
|
|
Post by BloodKnight on Apr 22, 2007 16:42:52 GMT -5
Wow Doan, thanks for the info! While it does seem complicated to get started, GCC seems like the best(and only) option.
I can understand the whole deal with many companies only supporting Windows. Some developers wish to take great advantage of certain tools, and unfortunately certain tools make applications incompatible with other systems. To make those programs compatible then, it seems you have to disassociate the program with the OS dependant tools, then associate it with whatever tools are available for another platform. That process seems like it can be a pain, especially when the staff available is ill-equipped to do it.
Though I hear that there are many users on Mac and Linux that wish to play games as well(which bodes well for shareware makers), and supporting multiple platforms can enlarge your userbase, that's why I wish to do it.
|
|
|
Post by Doan the Nado on Apr 22, 2007 17:48:17 GMT -5
Believe it or not, it's not all that hard to decouple your application from a specific platform, even without a toolkit like Allegro or GTK. I've written OpenGL graphics applications from scratch that compiled and ran just fine on both Windows and Linux. The key is to understand what functions you need that are provided by the OS. Instead of writing these operations directly into your code (i.e. Sleep, a Windows-only command, as opposed to sleep), you instead have to collect them all into one library called e.g. os.h. Then, you write your own functions that simply call these, and you are set.
If you simply do this, it becomes very easy to add support for other operating systems later on down the line, if you find demand for it. Basically, all you have to do is add stuff like:
#ifdef _WIN32 /* Code for Windows-specific stuff */ #else #ifdef _GCC /* Code for Linux-specific stuff */ #else /* Code for Macintosh-specific stuff */ #endif #endif
Now you have one place that provides compatibility on multiple platforms, and if the API changes (which Windows is wont to do quite frequently), you only have to change one part of your code. Even better, this library you create will end up being useful to all future programs you write, not just the one you are currently working on.
If everyone coded like this, there would be no compatibility problems at all (or at least many less). The problem is that people code OS-specific calls directly into their main body of code, all over the place.
Anyways, I don't think this is much of an issue for you, but it's been something that's been bugging me. Cross-compatibility is not that hard to do, and I'm glad to see you doing it (although I admit that the part which involves figuring out how to do cross-compilation is a bit tricky).
|
|
|
Post by BloodKnight on Apr 22, 2007 19:26:57 GMT -5
That above sounds like a good DIY solution, instead of cross-compilation. Or am I getting things mixed up?
So, I guess it seems I just install cygwin, then run GCC in a Unix/Linux environment, then compile the code in said environment?
It seems I might have a solution to Linux, but I wonder if there are any for Mac OS X?
|
|
|
Post by NASH7777 on Apr 22, 2007 19:30:25 GMT -5
I use REALbasic in which I can compile apps for Linux, Mac OSX, and XP.
|
|
|
Post by BloodKnight on Apr 22, 2007 19:39:49 GMT -5
I'm not using BASIC, I'm using C++ though. Know of a C to BASIC converter? I looked RB up though, and it seems great.
|
|
|
Post by NASH7777 on Apr 22, 2007 20:00:21 GMT -5
RealBasic is by no means "basic"
The language is extraordinarily easy to learn. And they have language reference and auto fill to help out.
Here's some sample stuff I'll take from stuff I did:
if mode=0 then If s1=chara then //run into wall if s2.Group=1 then if direction=0 then chara.X=chara.X-6 end if if direction=2 then chara.Y=chara.Y-6 end if
If Keyboard.AsyncKeyDown(123) then mario.x=mario.x-1 end if If Keyboard.AsyncKeyDown(124) then mario.x=mario.x+1 end if If Keyboard.AsyncKeyDown(&h00) then SpriteSurface1.stop end if If Keyboard.AsyncKeyDown(126) then mario.y=mario.y-2 if action=0 then jumplv=mario.y-100 action=1 end if jumplv>mario.y then action=2 end If action=2 then mario.y=mario.y+4 end end if
If s1=mario then mario.y=mario.y-1 action=0 end if s2=object1 then mario.y=mario.y+10 action=2 if switch1=false then switch1=true elseif switch1=true then switch1=false end end if s2.group=2 then if s2.image=goombastomp then s2.Close end if s2.image=goomba then s2.image=goombastomp s2.y=315 mario.y=mario.y-40 end end ~~~~ ~~~~ Has your basic data types: booleans numerical types array multidimensional arrays etc... plus can make your own
|
|
|
Post by BloodKnight on Apr 22, 2007 22:10:16 GMT -5
I'm learning C++, and I've gotten pretty good at it; it has all I need in terms of data types(the visual side is handled by Allegro). I just want a way to port games I develop using C++/Allegro on Windows, to other platforms is all. I've tried so many game creation tools, that I don't need an easier language. Though RB fits my need supposedly for a cross-platform compiler, it uses a language I'm not using. That's why I asked for a converter.
|
|
|
Post by thetruecoolness on Apr 22, 2007 22:14:27 GMT -5
Well with the preprocessor commands Doan suggested, you still have to compile for a specific system in order to get an executable in the correct format. To the best of my knowledge all the major OSes still have their own executable formats. What Doan showed is just a way to get the compiler to ignore certain commands and lines. The other alternative is just to use cross-platform languages that run on a virtual machine, but of course then you have the overhead of the virtual machine. Java is a compile once, run (read debug) everywhere type of language. .NET I believe can also be ported easily to other systems if they have Mono www.mono-project.com/Main_Page (open source implementation of the .NET framework) installed, since all .NET languages also run on a virtual machine. Apparently it also runs more than just .NET. But if you want to run natively you're going to have to compile the program for each target OS. Or ask your user to, by providing them with a make, or batch file.
|
|
|
Post by Doan the Nado on Apr 23, 2007 3:17:10 GMT -5
Yeah, the code snippet that I wrote was a comment on style. Using that methodology will lead to source code that is effortlessly multi-platform. If, however, you don't want to distribute that source code, but instead to distribute binaries, you will need to compile it for each individual platform. Here's a quick HOWTO I found through Google: metamod-p.sourceforge.net/cross-compiling.on.windows.for.linux.htmlOf course, if you have too many issues, don't worry about it. Just note which DLLs are necessary (under Windows), and people who have Wine can simply install those DLLs and run the program on top of Wine. I was able to play Smurf's RPGMXP game in Linux on top of Wine, so I don't anticipate any problems with what you're working on, unless you're doing really crazy stuff (if you're not sure, then you're almost certainly not). Unfortunately, neither of those solutions offer any help to Mac users. Honestly, the easiest way is just to share the source code, because then there are no worries at all, but beyond that and what I've mentioned, I don't have any other advice for you. Good luck .
|
|
|
Post by BloodKnight on Apr 23, 2007 7:45:52 GMT -5
Sharing the source is an undesirable approach for me, it negates the point of me developing a game, and I like doing it(trying to argue with me on this is futile ). I guess I'll burn the bridge when I come to it. I've thought about a few options and as long as I have the funds, they don't seem too bad. Thanks for the help everyone, I really appreciate it.
|
|