Cross Platform using C and Opengl

Nibbie
Posts: 4
Joined: 2012.01
Post: #1
I'd like to hear some thoughts about cross platform programming. I want to run programs on Android, iPad, iPhone, Mac, and yes, Windows. I need intense hardware accelerated graphics, so I use Opengl and C. I have found that code to be portable to everything and I use a wrapper for each platform. The wrapper is needed only to give me an opengl window, internet access ala geturl or equivalent, and of course, user touches. GUI is also entirely in Opengl since I don't want to recreate a different GUI for every platform.

Anyone have a better idea for cross platform? ( I am ducking now... ) Rasp
Quote this message in a reply
Member
Posts: 312
Joined: 2006.10
Post: #2
You described generically what I believe most developers do.

Another option to consider is using a 3rd party software stack that does all of the abstraction for you. A popular example of this is Unity (which can build applications for all of the platforms you mentioned).
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #3
What you describe is exactly what I do, and I'm quite happy with it. In case you want to use any of my stuff for reference, it's all open source: http://libstem.org/
Quote this message in a reply
Member
Posts: 104
Joined: 2007.01
Post: #4
Ditto. Except that I'll add that I use SDL for audio, input, etc. SDL and auxiliary libs like SDL_mixer provide a great cross-platform solution for non-graphics parts of my games. Also, some of my games use OpenGL for graphics and some use the SDL graphics capability.

SDL 1.3 supports iPad, iPhone, and Android. I'm still using SDL 1.2.14, but I plan to port my custom game engine to SDL 1.3 later this year when I port one of my games over to IOS for the first time. You'll find SDL 1.3 over at the Galaxy Gameworks site: http://www.galaxygameworks.com/products.html

My Game Company
Creator of Dirk Dashing, Rick Rocket, and Fashion Cents Deluxe
Quote this message in a reply
Member
Posts: 339
Joined: 2004.07
Post: #5
This is essentially what I use as well: SDL for application level stuff, SDL_mixer for sound, SDL_image for texture loading, OpenGL for graphics, written in C++. It's worked phenomenally for me, and I've been using this combo since 2004.

(Jan 12, 2012 10:31 PM)GolfHacker Wrote:  You'll find SDL 1.3 over at the Galaxy Gameworks site: http://www.galaxygameworks.com/products.html

OMG. You just made my day. How did I never see that site? I know it's pre-release but I want to work 1.3 into my engine asap.

Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
Do people really still use SDL_image for texture loading? In my experience getting SDL to load textures correctly so that it supports more than just formats that SDL decides to decompress directly to 32bit RGBA is a real PITA. Certainly more so than using libPNG and libJPEG directly, and certainly a lot slower if you load a lot of large textures.

The libPNG bundled is probably pretty ancient, but this will load palleted or grayscale PNGs with no trouble, will load them correctly for OpenGL (SDL_image makes them upside down), and can easily be changed to load alpha or luminance textures:
http://files.slembcke.net/misc/PNGTexture.tar.gz

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 339
Joined: 2004.07
Post: #7
(Jan 13, 2012 02:28 PM)Skorche Wrote:  Do people really still use SDL_image for texture loading? In my experience getting SDL to load textures correctly so that it supports more than just formats that SDL decides to decompress directly to 32bit RGBA is a real PITA.

I've actually never had a problem with it. I don't do anything crazy with it, just use the one line call to load pngs and jpegs. But it's never misbehaved on me.

Justin Ficarrotta
http://www.justinfic.com
"It is better to be The Man than to work for The Man." - Alexander Seropian
Quote this message in a reply
Member
Posts: 104
Joined: 2007.01
Post: #8
(Jan 13, 2012 01:57 PM)JustinFic Wrote:  OMG. You just made my day. How did I never see that site? I know it's pre-release but I want to work 1.3 into my engine asap.

Heh! You're welcome!
I use FreeImage to load the various graphic file formats for my game. It's nice to be able to load any image format with the same small block of code (versus dealing with all the individual libraries for the various file formats), and the performance is decent.

My Game Company
Creator of Dirk Dashing, Rick Rocket, and Fashion Cents Deluxe
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cross-platform vectorization. Skorche 9 5,281 Feb 8, 2007 04:09 PM
Last Post: Skorche