Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411588 Posts in 69386 Topics- by 58443 Members - Latest Member: Mansreign

May 06, 2024, 02:37:42 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)C++ Win/OSX/Linux Setups
Pages: [1]
Print
Author Topic: C++ Win/OSX/Linux Setups  (Read 2004 times)
bateleur
Level 10
*****



View Profile
« on: November 16, 2009, 05:30:45 AM »

What ho, TIGers! Gentleman

Much as I frequently say rude things about C++, one of the small games in my project queue looks like it probably wants to be in C++ due to a need for very high performance.

This is a 2D game, with no requirement for 3D graphics at all.

What I'm looking for in this thread is recommendations from people who have completed C++-based games (not necessarily commercial) which run on (and have been confirmed to work correctly on) all three of Windows, OSX and Linux. In particular, I'm looking for recs for complete setups. So everything from the editor you use, the compiler you use, all the libraries you use for graphics, sound, file I/O, input peripherals, UI (if different from graphics) and so on.

If your setup also makes it possible to target other platforms (XBLA? PSN?) that's worth mentioning too.

Obviously I'm starting this thread because it will be useful to me, but hopefully it could also be useful to anyone else in the setup stages of a project in future...
Logged

Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #1 on: November 16, 2009, 06:10:53 AM »

I'm doing one right now, here.  Complete source is available via Subversion, but it's still very early.

As for libraries, I use OpenGL for graphics, OpenAL, libogg and libvorbis for sound, and I've just started using FreeType for font handling.

I try to use GCC to compile for all three platforms.  Some people like to use Microsoft's stuff on Windows, but if you do this I highly recommend not doing your coding there first.  The MS compiler is notoriously lenient (and often wrong) when compiling C++ code, and when moving the code to GCC (which you'll almost certainly be using on Mac OS/Linux) you'll run into all sorts of problems.  I'm the Mac maintainer for Bitfighter, and I have this issue all the time.

From an organizational standpoint, I do my projects with a totally platform neutral core, and provide OS specific stuff with a series of front-ends.  This allows a fairly easy migration to new platforms, as you generally just have to write a new frontend.

If you're going to be doing anything on the Mac, learn Objective-C if you don't know it already.  My Mac frontends are always done in Objective-C (or Objective-C++) because it's just a lot easier to get things done in Cocoa than Carbon.  I've heard rumors of Carbon's eventual deprecation as well, which makes Cocoa even more important to learn.

In my experience, trying to make all your code platform neutral is an exercise in pain that is not worth your time.  Make as much of it as possible platform neutral, and take the time to learn the native APIs on each system.  This allows you to take advantage of each platform's strengths and generally keeps your project from looking alien on some platforms.

Perhaps more importantly, learn how programs are supposed to work on each platform, especially Linux.  Windows programmers seem to like to assume that they can write files wherever the hell they please (even though you shouldn't do this on Windows, either) and you can't get away with that shit on Linux, and usually Mac OS too.  Know what users of each platform expect.  I remember downloading a Linux port of a Windows game where the programmers had named the binary with a .exe extension.  That sort of stuff annoys Linux folk.
Logged



What would John Carmack do?
Ivan
Owl Country
Level 10
*


alright, let's see what we can see


View Profile
« Reply #2 on: November 16, 2009, 08:45:29 AM »

SDL + OpenGL for graphics (but make sure that the SDL parts are abstracted out so they can be replaced by other stuff if needed). OpenAL or fmod (not free, but better) for sound. That should get you on your way to code that will compile flawlessly on all three platforms.

SDL is a good way to get a window up with some input and initialize an OpenGL context and it will carry you for awhile without learning platform specific stuff, but later on you might want to replace it with custom platform stuff as Average Software mentioned, so you can make things more flexible.

I am currently finishing a cross platform engine that compiles on win/osx out of the box and here's the libraries i'm using if it's helpful at all:

OpenGL
SDL for the core (replaced by native stuff as of late)
libpng for image loading
freetype for font rendering
box2d for 2d physics and collision
bullet for 3d physics and collision
physfs for resource packages
Cg for shaders
openAL for sound
ogg/vorbis for sound loading
Lua for scripting

Not counting the recent platform specific stuff, it compiles with (almost) no code changes between windows and osx. (Xcode in OSX and both in MingW and MSVC on windows).
Logged

http://polycode.org/ - Free, cross-platform, open-source engine.
mcc
Level 10
*****


glitch


View Profile WWW
« Reply #3 on: November 16, 2009, 09:01:43 AM »

So I have a setup like this which I tried to build into a pick-up-and-go package other people can use. Here's the package download and instructions on how to set it up (libraries included are listed at that link). It's a bit bare-bones and it uses OpenGL rather than SDL2D-- although OpenGL is pretty nice for 2D work, and either way it should be relatively easy to adapt that package to using SDL 2D.

I mostly assume you're doing your main development on the mac with XCode, but I also included a quick set of step by step instructions for running things from the Windows side with MingGW/MSYS.
« Last Edit: November 16, 2009, 09:09:28 AM by mcc » Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Aquin
Level 10
*****


Aquin is over here.


View Profile WWW
« Reply #4 on: November 16, 2009, 11:15:16 AM »

I use:

Code::Blocks
  -mingw
  -OpenGL
SFML

That's all.  I set up a friend yesterday so he can make a C++ game; it took him 5 minutes to figure it out.  Go to codeblocks.org and get set up.  Then go to sfml's website and install the package.  Point code::blocks to the include directory, copy over the dlls, and you are finished.

SFML has wrappers for OpenAL and a bunch of other libraries and is completely free to use for any purpose.  Awesome stuff.
Logged

I'd write a devlog about my current game, but I'm too busy making it.
BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #5 on: November 16, 2009, 11:25:50 AM »

Personally, I recommend:

Code::Blocks
It works on all 3 platforms.

SFML
It's a "Simple and Fast Multimedia Library", which lives up to it's name. It's much easier to use than alternatives like SDL and Allegro, and is more than easy to integrate with OpenGL. It's entirely cross-platform, so no worries.

I'm only guessing you don't want to deal with an arseload of technicalities and framework creation, in that case I definitely recommend SFML.

*highfives Aquin*
Yes, it is awesome stuff.  Well, hello there!
Logged

Aquin
Level 10
*****


Aquin is over here.


View Profile WWW
« Reply #6 on: November 16, 2009, 11:31:49 AM »

*highfive received*

Yeah Jakman you have no idea how long I wandered in the darkness.  I used Dev C++, Microsoft Visual, SDL, Allegro, etc.

Man, you name it I tried it (well before 2005 anyway.)  Now that I've found Code::Blocks and SFML, I refuse to let go!  NEVER!    Grin

Logged

I'd write a devlog about my current game, but I'm too busy making it.
Hideous
That's cool.
Level 10
*****


3D models are the best


View Profile WWW
« Reply #7 on: November 16, 2009, 11:47:08 AM »

Man, regarding libraries - I wish more libraries would have a tutorial like "make a simple shmup or other game with this library so you know how to use it in most situations! woo!".
Logged

BlueSweatshirt
Level 10
*****

the void


View Profile WWW
« Reply #8 on: November 16, 2009, 11:50:18 AM »

*highfive received*

Yeah Jakman you have no idea how long I wandered in the darkness.  I used Dev C++, Microsoft Visual, SDL, Allegro, etc.

Man, you name it I tried it (well before 2005 anyway.)  Now that I've found Code::Blocks and SFML, I refuse to let go!  NEVER!    Grin



I'm pretty much the same.
First I started out in MSVC, then my programming book used Dev-C++, so I switched to that. I used DCpp for a while, only working with the command line. I found Code::Blocks, and never used another IDE again. Then learned SDL, hated it, went back to my command line for a while, then tried Allegro. I worked with Allegro for quite a while, and eventually raegquit it. Went for straight OpenGL, which was a pain in the arse.

Then I found SFML, and we've been happily married for about a month now.  Hand Shake Left Corny Laugh Hand Shake Right Best part is, she doesn't mind me going back and using both her and OpenGL at the same time, either. Very accepting and flexible woman.  Kiss (which comes in handy when I have to do rough things with her)

@Hideous
That's a good idea... I should do that.
Logged

Aquin
Level 10
*****


Aquin is over here.


View Profile WWW
« Reply #9 on: November 16, 2009, 11:54:54 AM »

Yeah myself I started doing everything by hand (makefiles etc.) in linux.  I used OpenGL and GLUT and OpenAL.  Then I got unstupid and used a decent IDE.

SFML has a great attitude, because I can use as little or as much as I care for.  It also simplifies way more than SDL.  SDL demands that you write dozens of lines of code just to 'prepare' for certain simple actions.  SFML will do it in one line.  Like setting the icon of the window.

Allegro was great (I used it in my DOS days), but it's just too limited for a lot of my work.  I seriously SERIOUSLY doubt I will ever find something as useful/powerful as SFML ever again.

Also, SFML is available in Python and a bunch of other languages.  That is hot.
Logged

I'd write a devlog about my current game, but I'm too busy making it.
increpare
Guest
« Reply #10 on: November 16, 2009, 12:21:37 PM »

Use SDL sometimes, allegro sometimes; no fancy interfaces, for SDL i have a makefile that tends to build most projects on both windows + osx, with allegro I have codeblocks/xcode project files that I can rebuild easily enough.  Porting takes usually about ten minutes, but occasionally longer (esp. when I'm using a library for the first time...).
Logged
bateleur
Level 10
*****



View Profile
« Reply #11 on: November 16, 2009, 01:52:04 PM »

Thanks for the replies everyone! Beer!

@Average Software - I don't actually have access to a Mac, so writing platform specific code that will take more than a few hours to get working is out of the question for now. (And whilst I know my way around Linux I'm also wary of rolling my own solution in that space because distros - and even individual installs - vary way too much.)

@Ivan - I've reached a stage with writing games where I'll happily trade "more flexible" away in favour of "more portable". Life's too short for hand-porting stuff!

Overall it's sounding like SFML will probably be the first approach I try out...
Logged

mcc
Level 10
*****


glitch


View Profile WWW
« Reply #12 on: November 16, 2009, 10:23:02 PM »

Man, regarding libraries - I wish more libraries would have a tutorial like "make a simple shmup or other game with this library so you know how to use it in most situations! woo!".
Hm.

There are these "screencast" thingies that a number of web CMS engines have on their websites, where they basically film someone making a small website in about ten minutes. These usually double as a quick tutorial and a sales pitch for the engine. It would make a lot of sense to do something like this for some game engines.
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Martin 2BAM
Level 10
*****


@iam2bam


View Profile WWW
« Reply #13 on: November 16, 2009, 10:42:25 PM »

SFML is the shit Hand Thumbs Up Left Smiley Hand Thumbs Up Right
The interface is pretty awesome for a game lib. Complete yet uncluttered.

I only tested it on Windows (bought a MacMini after the project), but apparently you can easily port everything to OS X and Linux.

And as someone mentioned: You can bypass SFML and shoot OpenGL/AL code straight into your code Smiley

One thing: Be prepared to hack it.
I recommend you to download the latest repository version, learn to build the lib from scratch.
Debugging will be easier because your IDE will get into the guts of SFML and you can learn why something could be failing.
And besides, if you find a bug, you can contribute to it's development.

Btw, I use VC++2008 express on Windows and Xcode on OS X.

Regards!
Logged

Working on HeliBrawl
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic