Cross Platform coding

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
hayk0510
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 21
Joined: Tue Mar 10, 2009 11:03 pm

Cross Platform coding

Post by hayk0510 »

Just had a quick question, I couldn't seem to find the answer searching the forums.

I want to make games for Linux, and contribute to expanding the Linux gaming scene, but I would also like for my games to be able to run on Windows as well.

Let's say I am using C++ with Python and use SDL and openGL with them. Coding them in Code::Blocks and compiling them with the GCC compiler.

My question is, will I be able to run the game on both OS's by just recompiling the code in each? Or will I run into OS specific code and have to rewrite a lot of it?

I'm a big Linux fan, but I want everyone to be able to play my games. (Which might mean a Mac port also. But I have no experience in their OS.)
"Manually managing blocks of memory in C is like juggling bars of soap in a prison shower: It's all fun and games until you forget about one of them."
User avatar
JaxDragon
Chaos Rift Junior
Chaos Rift Junior
Posts: 395
Joined: Mon Aug 04, 2008 2:03 pm
Current Project: Kanoba Engine
Favorite Gaming Platforms: PS3, PC
Programming Language of Choice: C++
Location: Northeast NC

Re: Cross Platform coding

Post by JaxDragon »

If you use just C++, Python, SDL, and OpenGL, you shouldn't come across any errors. And when you do, they're generally not hard to fix. Its when you get into things like GUI programming(unless you use pythons built in GUI library), networking(unless you use something like SDL_Net), thats when you start rewriting code.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Cross Platform coding

Post by Falco Girgis »

If you see yourself doing something like:

Code: Select all

#include <windows>
or

Code: Select all

#include <unistd>
punch yourself in the face, and you'll be fine. :D
User avatar
hayk0510
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 21
Joined: Tue Mar 10, 2009 11:03 pm

Re: Cross Platform coding

Post by hayk0510 »

GyroVorbis wrote:If you see yourself doing something like:

Code: Select all

#include <windows>
or

Code: Select all

#include <unistd>
punch yourself in the face, and you'll be fine. :D
Haha, I'll keep that in mind.

Btw, I'm just curious. But which programming languages did you know before you learned C++? And when did you start learning it?

People in other forums tend to avoid C++ like the plague, and usually recommend C over it. But then again, those people aren't really game developers either. :D
"Manually managing blocks of memory in C is like juggling bars of soap in a prison shower: It's all fun and games until you forget about one of them."
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Cross Platform coding

Post by K-Bal »

hayk0510 wrote: People in other forums tend to avoid C++ like the plague, and usually recommend C over it. But then again, those people aren't really game developers either. :D

The worst C++ programmers are often the ones who have learned C before. They try to abuse C++ for procedural programming.

I would recommend a OOP language from the beginning. Not because I'm propagating OOP but because it makes software design for beginners more intuitive.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Cross Platform coding

Post by MarauderIIC »

<windows.h> and <unistd.h>, I don't think there are extensionless version of them.

Falco knew C before C++ but I can't say what he knew before that. C is "better" for game development because it's more "lowlevel".
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: Cross Platform coding

Post by Falco Girgis »

K-Bal wrote:
hayk0510 wrote: People in other forums tend to avoid C++ like the plague, and usually recommend C over it. But then again, those people aren't really game developers either. :D

The worst C++ programmers are often the ones who have learned C before. They try to abuse C++ for procedural programming.

I would recommend a OOP language from the beginning. Not because I'm propagating OOP but because it makes software design for beginners more intuitive.
I resent this statement.

I came from a C background. While I definitely had to learn object-oriented programming, I am also more competent with low level APIs, drivers, embedded machines, and things like that than OO exclusive C++ and Java programmers.

Sure, start with C++, but learn both.
K-Bal
ES Beta Backer
ES Beta Backer
Posts: 701
Joined: Sun Mar 15, 2009 3:21 pm
Location: Germany, Aachen
Contact:

Re: Cross Platform coding

Post by K-Bal »

I used the word "often" for a reason :D

Sorry, it's late (Germany) and I'm a bit drunk. I'll give a more decent answer on this tomorrow.

Cheers,
Marius
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Cross Platform coding

Post by dandymcgee »

GyroVorbis wrote:
K-Bal wrote: The worst C++ programmers are often the ones who have learned C before. They try to abuse C++ for procedural programming.

I would recommend a OOP language from the beginning. Not because I'm propagating OOP but because it makes software design for beginners more intuitive.
I resent this statement.

I came from a C background. While I definitely had to learn object-oriented programming, I am also more competent with low level APIs, drivers, embedded machines, and things like that than OO exclusive C++ and Java programmers.
Not everyone can be as talented as you Falco. :roll:

I know a few C programmers whose attempts at C++ are well.. not so pretty. I'm not arguing with your point that with enough practice a C programmer can become more competent with C++ than an "OOP Whore" (as you call 'em), but it does indeed take some practice. :)
GyroVorbis wrote: Sure, start with C++, but learn both.
Good advice.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply