C++ Multi-Platform (Windows, Linux, Android) OpenGL(ES) Solutions or Tutorials?

Started by
4 comments, last by 21st Century Moose 8 years, 3 months ago

I'm sorry if this has been asked recently and I'm not Googling it right, but I've been digging all week for something.

I've got a game prototype I made in Unity, and I have some decent experience with SDL (1.2 I believe, but the 2.0 stuff is familiar) so I thought I'd take a crack at SDL 2.x + OpenGL while I've got a simple "sprite" based game that could take advantage of some of the blending features OpenGL offers, if nothing else but to practice with it so I'll be more prepared when trying to make a 3D game down the road. Honestly I'd probably be half done with it by now if multi-platform wasn't an issue.

I really want to put this game on Android, I think it's perfect as a mobile app. But nearly every tutorial I can find on SDL+OpenGL seems to include something like GLEW or freeglut or bucks SDL altogether for something like GLFW (which I actually kind of liked). All of these seem like great tools, but they typically don't have much in the way of tutorials or guides on how to get things over to the mobile side... and I'm not quite at the level where I know anything about porting these kinds of tools to Android unless it's a pre-existing build, honestly I don't really feel confident even building development libraries for Windows.

So I'm in some serious need of somebody who maybe has experience with at least Windows+Android or Linux+Android multiplatform development or can at least point me in the right direction for a tutorial/guide/tool/idc that can better explain the porting or cross-development from desktop to Android. Honestly I'd probably even shell out for a good book recommendation or fairly priced paid utility at this point. Heck, I'd probably try a Python or Lua type scripting solution (like that could bind to C/C++ and Java) if it's viable, my only problem there is a limited knowledge of embedding scripting languages into native code.

To clarify: I'm well aware there's not really a write once, deploy everywhere solution for native code like C++. What I'm looking for is some sort of reference how to handle- at least -one of these desktop platforms and Android in OpenGL, whatever windowing/input/etc. tool can be layered with it in a semi-platform independent way. Because, to me at least, it seems to be well under documented or my wheelhouse of SDL experience is crippling me from actually taking advantage of OpenGL and learning it properly.

Thanks for any help you can give, cheers~!

AniMerrill, a.k.a. Ethan Merrill

Advertisement

If you already have the prototype in Unity, what is preventing you from using Unity as your solution ? Last time I checked Unity supports Android and other platforms. I also see you have cross-talk between a few issues. OpenGL is a 3D API (if one can call it that ) that gives HW accelerated access to the GPU on supported platforms. Windowing, input handling etc. are not the domain of OpenGL and are separate entities. Yes OpenGL requires some type of window to render in, but OpenGL itself does not provide any means to create the window.

If you already have the prototype in Unity, what is preventing you from using Unity as your solution ? Last time I checked Unity supports Android and other platforms. I also see you have cross-talk between a few issues. OpenGL is a 3D API (if one can call it that ) that gives HW accelerated access to the GPU on supported platforms. Windowing, input handling etc. are not the domain of OpenGL and are separate entities. Yes OpenGL requires some type of window to render in, but OpenGL itself does not provide any means to create the window.

Because, IMHO, Unity is a mess... at the very least for the scope of project I'm doing and the way I'm doing it, I got to the point where I was more hacking Unity to be like native code. It's good for dragging and dropping things in a visual way- and as an artist I do appreciate that -but years of C++ indoctrination have me always wanting to be able to do everything programmatically which becomes more and more difficult with Unity, in my experience anyway.

And yes, I probably worded myself badly, it was like the moment before I went to bed after four hours of Googling I posted this lol. The reason I was fixated on the OpenGL issue is because SDL, by itself, has been proven to be portable on pretty much everything. My problem was finding an SDL+OpenGL example, or an example of any window managing OpenGL wrapper, that didn't include things that are only proven or documented to work on desktops. Somebody actually did share a github of an SDL example they did over here which uses platform abstraction (a term I wasn't familiar with that will probably make this go a lot smoother from now on, plus a suggestion to learn the low level APIs like Win32 a bit from another user) to make SDL+OpenGL+GLEW and a couple other libraries all work together on Windows and Android- which was basically what I was looking for.

Even though it's a tad over my head, its still new stuff I can read up on or Google properly now.

AniMerrill, a.k.a. Ethan Merrill

Have you looked at Marmalade? https://www.madewithmarmalade.com

You can code in c++ and there tools do all the work to deploy on different platforms.

Have you looked at Marmalade? https://www.madewithmarmalade.com

You can code in c++ and there tools do all the work to deploy on different platforms.

I never actually downloaded it, but I did see it. Honestly from the sound of it, it's very much like Java with the whole WORA philosophy but with proprietary limiters on the features of the SDK... and I guess the fact you can use native code with it instead of it just being it's own language. I probably wouldn't even mind paying for it actually but their SDK doesn't support Linux.

AniMerrill, a.k.a. Ethan Merrill

The reality is that the kind of multiplatform development - desktop OS + mobile OS - that you're looking for doesn't actually exist: there is no single API that will cover everything you need. OpenGL, which is often touted as covering all platforms, actually doesn't. In your specific scenario - desktop OS + Android - we're talking about OpenGL (on the desktop OS) and OpenGL|ES (on Android). Despite the names, and despite other similarities, these are actually not the same API; nor is ES a subset of desktop OpenGL (with the exception of more recent versions of desktop GL; see below).

What that means is that there is functionality in each that is not available in the other, and you'll need to restrict yourself even further to a common subset.

Things get even worse if you want to target older platforms. Maybe you want to target budget PCs or laptops with Intel integrated graphics? Not unreasonable for a game focussed on mobile, but you'll find that these may not support the GL version or extensions for full ES compatibility. Then you get to deal with hardware differences, driver bugs, etc.

That's why you generally get recommended to use an engine like Unity, or UE4. All of that horrible work has already been done for you, and you get to focus on the things that are important for your game. I used to recommend to anyone starting out that they had enough to be worrying about without taking on cross-platform as well, but with so many free engines available nowadays that's probably no longer valid. Bottom-line is - as your first post indicates you're discovering - the fabled nirvana of "use this API or library and you get to hit all platforms" doesn't work out so cleanly in practice.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement