C++ on Android, is it possible ?

Discussion in 'Game Development (Technical)' started by vbovio, Aug 18, 2011.

  1. vbovio

    vbovio New Member

    Joined:
    Jun 8, 2009
    Messages:
    87
    Likes Received:
    0
    what the title says..
    I want to know if it is possible to develop C++ OpenGL based games on Android, and if there is any penalty or cautions to consider..
    thanks!
     
  2. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    Fully possible, that's how we were able to port Great Little War Game so easily. You want to look into the NDK.

    No gotchas for me, certainly not the "you need java" gotcha that's finally dying off. :) The sound libs are a bit shit, but everything else is as you'd hope - a thin layer of java to get started and then you're off.
     
    #2 Applewood, Aug 18, 2011
    Last edited: Aug 18, 2011
  3. vbovio

    vbovio New Member

    Joined:
    Jun 8, 2009
    Messages:
    87
    Likes Received:
    0
    that's great to know, thanks a lot Applewood!
     
  4. Four

    Four New Member

    Joined:
    Aug 30, 2008
    Messages:
    30
    Likes Received:
    0
    Yes fully possible. And sound is in OpenAL, which you can do all in C++, as its OpenAL has been ported.

    Loading of assets would probably be done in Java with the data passed back into C++.
     
  5. Applewood

    Moderator Original Member Indie Author

    Joined:
    Jul 29, 2004
    Messages:
    3,859
    Likes Received:
    2
    But buggy - that's one of the options I was referring to. I'm sure they'll get it all fixed but we're aiming to release in a week or so, so we went under the hood ourselves. (Which all backs up my constant promotion of roll your own.)

    Loading sound assets on the java side took a ridiculously long time also. Not sure why, possibly user error but there's not much room for that given the options available. We loaded them as a chunk of binary and passed a pointer in the end.
     
  6. princec

    Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    4,873
    Likes Received:
    0
    I'm not surprised Oracle are so furious with Google for screwing Java over so badly with all this, though it is really their own fault for refusing to license it to them on half-reasonable terms.

    Cas :)
     
  7. jcottier

    jcottier New Member

    Joined:
    Jul 12, 2006
    Messages:
    1,385
    Likes Received:
    0
    It is such a good move... Allowing coders to port their existing code very quickly. It's very likely that I'll be porting my c++ lib to android this september. I hope, I won't pull the few remaining hair from my head to make this work :)

    I wish Microsoft was letting us to use c++ on their phones... What a dump mistake from them.

    JC
     
  8. barrygamer

    Original Member

    Joined:
    Apr 10, 2006
    Messages:
    490
    Likes Received:
    0
    Theres a c++ port of cocos2d which runs on ios and android - http://www.cocos2d-x.org/.
    I haven't used it myself, I still use the obj-c version.
     
  9. MadSage

    Original Member

    Joined:
    Sep 23, 2004
    Messages:
    72
    Likes Received:
    0
    I ported a C++/OpenGL game from iOS to Android in about 6 weeks - my first ever Android project! I was so glad I wrote an OpenGL renderer for the iOS version because it made the process much easier. Even most of the iPhone textures just worked (with the exception of pvrtc compressed textures). Most of the problems came from getting used to the crappy emulator and it's quirks, and learning how to write make files again. I also had to learn a bit of Java, but that was easy enough. The biggest piece of Java code was for sound. That worked fine for me. I've just started a second port, and it looks like it will be near complete in a few days, even though it's a massive project.
     
  10. gamayun

    gamayun New Member

    Joined:
    Apr 6, 2010
    Messages:
    3
    Likes Received:
    0
    JNI is definitely the way to go on android. I just ported the game engine DreamGame from www.dream-up.eu
    Once the core compiled successfully, I just had to add a wrapper to the main functions (init, gameLoop, playSound etc.) that'd "talk" to the main (and thin) Java skeletton.
    I had to compile also and link the openAL lib for 3D sounds (see this blog to do the same: http://pielot.org/2010/12/14/openal-on-android/ ) and zlib for zip files.
    The main problem was to play ogg files from openAL, I have to admit I still haven't figured out how to do (all my attempts with android.c in openAL failed) so I use Java and a MediaPlayer for background music.
    Except this, everything was quite easy. I am now publishing games using this game engine, 4 so far (You can have a glimpse at them on my blog: http://androidgamedeveloper.blogspot.com/
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer