2
\$\begingroup\$

I have a game written in C++ (using STL and c++11 extensively).

I would like to do the following things:

  • Attach graphics to this game -> Think chessboard of some kind. I just need some pictures and simple status bars, no movement necessary, even though it would be nice I guess. It's a turn based game.
  • Port the game across Windows / Android / iOS

So, all in all, I need a tool that would provide a portable, simple, 2D graphical interface. A tool that would allow me to "bind" my c++ code to portable graphical representation.

How would I go about making this idea come true?

\$\endgroup\$
3
  • \$\begingroup\$ Are you making a game, or a game engine? Also, are you asking for us to suggest a 2D graphics interface you could use, or are you asking for something else? Please be clearer. \$\endgroup\$ Commented May 8, 2012 at 0:43
  • \$\begingroup\$ Edited my question. Yes, i basically want to take my code, stitch some 2D representation to it and port it :) \$\endgroup\$ Commented May 8, 2012 at 0:49
  • \$\begingroup\$ Best bet would be cocos2d-x \$\endgroup\$
    – Coyote
    Commented May 10, 2012 at 15:07

5 Answers 5

2
\$\begingroup\$

Since the customary language for ios is objective-c and android is java, you should add to your question that you need a kit that also supports C++ across those platforms.

http://www.madewithmarmalade.com/ is one, it's probably stronger than what you're looking for and it's not free... but there is a trial version.

I have not tried it personally, your mileage may vary.

\$\endgroup\$
3
  • \$\begingroup\$ This is not fully true. Android supports native C++ if you're able to configure the NDK. There's also a version of SDL that uses NDK to run on android. The only problem I see is that it doesnt support all the STL lib yet, maybe C++11 set may be out. Just a guess, but you can try to replace it with BOOST or other implementation of the TR1. It may work or not. \$\endgroup\$ Commented May 8, 2012 at 2:11
  • \$\begingroup\$ Yes, but unfortunately none of those options answer the question of being portable to all the platforms and with 2D graphics. That being said, I'm going to have to check out android and C++ because I'm most familiar with that language and it might be fun \$\endgroup\$ Commented May 8, 2012 at 2:22
  • \$\begingroup\$ cocos2d-x works great on android and iOS... it's C++ and is supported natively on both. \$\endgroup\$
    – Coyote
    Commented May 8, 2012 at 22:04
3
\$\begingroup\$

No need to hook to HTML5 or native iOS/Android graphics functions when you have native OpenGL ES support on both platforms. On android binding native graphics Java functions to your C++ code would give you horrendous results.

I think your problem can be solved with a little help from a friend... I would safely bet cocos2d-x does what you need. It is mainly a 2D graphics engine. It's a cross platform C++ OpenGL (ES) based library.

It's a port of cocos2d which is a very successful Objective-C game framework. But don't reject it on the basis of it's framework status. You don't have to use everything.

Of course you will have to take the time to get to know the library, the features and optimizations it offers. But I believe you will find a lasting friendship with this one.

To run your C++ code on android you will have to go with the Android NDK. You will have to compile most of your game as a library and bridge calls to the native Android functions.

\$\endgroup\$
1
\$\begingroup\$

You've really started backwards in some respects. Even if your only goal was to add "simple" graphics for one platform, you would find yourself spending much more time on the graphics than on the underlying game implementation.

I would look at using a browser to display the pictures you need, which would be platform independent; and put your game logic on a web server. I would guess that a turn based game wants a web server in the loop anyway.

\$\endgroup\$
1
\$\begingroup\$

Have you considered using the Qt framework? It has the UI and simple 2D graphics capability all in one package. Works on Windows, Apple, and phones.

\$\endgroup\$
0
\$\begingroup\$
  • Portable C++0x is not quite there yet, depending on what features you use.
  • As for cross platform input, graphics, etc SDL2 is stable enough these days.
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .