Cross Platform coding
Moderator: Coders of Rage
Cross Platform coding
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.)
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."
- JaxDragon
- 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
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.
- Falco Girgis
- 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
If you see yourself doing something like:
or
punch yourself in the face, and you'll be fine. :D
Code: Select all
#include <windows>
Code: Select all
#include <unistd>
Re: Cross Platform coding
Haha, I'll keep that in mind.GyroVorbis wrote:If you see yourself doing something like:
orCode: Select all
#include <windows>
punch yourself in the face, and you'll be fine. :DCode: Select all
#include <unistd>
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."
Re: Cross Platform coding
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.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: Cross Platform coding
<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".
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.
- Falco Girgis
- 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
I resent this statement.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 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.
Re: Cross Platform coding
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
Sorry, it's late (Germany) and I'm a bit drunk. I'll give a more decent answer on this tomorrow.
Cheers,
Marius
- dandymcgee
- 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
Not everyone can be as talented as you Falco.GyroVorbis wrote:I resent this statement.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 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.
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.
Good advice.GyroVorbis wrote: Sure, start with C++, but learn both.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!