4

If I create a game in C++ on a mac using a library which is the same for both windows and osx, will the game be playable on both windows and os x or it will only work in os x because I done it in Xcode?

Is SDL a great library to do your first game after learning the basics and syntax of C++ (I found syntax to be close to Java)?

closed as unclear what you're asking by gnat, GlenH7, Wayne Molina, Ampt, user40980 Jul 30 '14 at 2:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

7

Yes, C++ is a cross-platform language in the sense that there exist compilers for many platforms.

Not all features/versions/libraries are implemented in every compiler or available on all platforms, so in that sense: No, C++ is not a cross-platform language.

Now to your implicit question: "Can I develop a game with SDL for graphics and sound abstraction on Mac OS X and compile the game for Windows?"

Yes, that is in fact possible, provided you are sticking to a defined subset of features and libraries that are available on both platforms. Using MXE, you can compile your Windows version on Linux/BSD/Mac OS X for Windows, and MXE includes SDL.

4

C++ is a multi-platform language in the sense that the source code can often be successfully compiled for multiple, distinct, platforms. The binaries you create are generally not portable between platforms.

When targeting multiple platforms, you need to take care that you stay away from platform-specific and compiler-specific code. Also all third-party libraries you use should be documented to support all relevant targets.

1

As long as you stay away from low-level (i.e. platform specific) operations and platform-specific system calls (i.e. only call lib functions in your cross-platform lib) you should be fine. There may be some minor compiler issues requiring you to modify a bit of syntax here and there (porting code is rarely a matter of copy-and-recompile, there are usually one or two minor wrinkles to iron out) but that should be trivial.

1

Yes. C++ is a cross-platform programming language. You can compile C++ code in many platforms, there exist compilers for most of the platforms. Having said that, the code you write should be cross-platform, you should keep yourself away from platform-dependent features, if you want your code to be platform-independent. For example, you should not use COM if you want to be able to compiler your code on MAC or Linux. And otherwise C++ and the libraries like STL, boost are available from any platform.

0

I don't really think of C++ as being "cross-platform" because you have to compile a different version for each platform. Sure, there's a compiler for every platform, but that doesn't mean it's as simple as "port code then hit the compile button". It's not remotely that simple.

If you want to do indie game programming, you probably don't want to reinvent the wheel: there are already free licence physics engines built upon game engines built upon graphics renderers. Why try to build all that on your own?

I recommend JMonkeyEngine. I don't think you need C++ or DirectX to make fast graphics games anymore unless you are trying for cutting-edge games like Skyrim; and even then you could still do most of the work in Java and add patches from other languages.

EDIT: Also, if you understand "basics and syntax of C++" this is not an indication that you understand C++ as well as you understand Java. C++ has a large number of nuances to it. Like, if you declare and assign a variable on one line vs. two lines this may change whether an overloaded assignment operator vs. a copy constructor gets called. For this reason, C++ programmers usually need to know a lot more about the language than Java programmers in order to program safely in the language.

None of this is dissing C++, but you need to know what to expect if you want to use it. Also, if you use DirectX rather than OpenGL, and if you want to do it on your own without using an open-license rendering engine, then god help you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.