Changing OpenGL Android to LibGDX OpenGL - android

I have a project which has a native android OpenGL implementation. MyView extends GLSurfaceView and MyRenderer implements GLSurfaceView.Renderer. I'm not satisfied with the implementation, because it was done in a hurry and is improper. I'd like to change it to a LibGDX implementation. A couple of questions, is it worth it? I'm not using any native code for my existing opengl implementation, I'm not really familiar with C/C++ code. So will I see a performance improvement by changing over to LibGDX. Second, how hard is it to do. I'm just starting out with LibGDX, got the app to run on my device. Am I better off investing time in NDK or LibGDX?

If you're not really familiar with C/C++, then it's probably not going to help your project to switch to the NDK. You're going to slow down your progress to make any framework change, and adding a new language is only going to compound the delay.
As for moving to libgdx, that might be a worthwhile investment of time. The main advantage I found when switch from native android to libgdx was that you could run your app straight on your desktop. The emulator is too slow to run games, so normally all your testing has to be on your phone, which is slow and aggravating. With libgdx, it runs right away, and all you have to do is export a different project to get an apk. I found that was also a good way to test screen sizes: you can just resize the window instead of creating a bunch of virtual devices.
I guess the main disadvantage to running libgdx is that you don't get direct access to the android framework. I worked around this (using different Activities for menus, for example) by adding those to the android project. The libgdx project was essentially just the core of the game.

Related

SDL2 cross-platform OpenGL 3+ and OpenGL ES 2.0 or 3.0

Is there some super-easy basic hello world cube project (with setup tutorial) for SDL2 that builds and runs easily across (Windows, Linux eg Ubuntu, Mac OS X, Android, iOS), using modern OpenGL as in OpenGL 3.x or 4.x and OpenGLES 2.0 or 3.0?
I downloaded SDL2 and it was pretty easy to get their example testgles.cpp and testgl.cpp to build...
However, the testgl.cpp one is horribly old (gl2 style), so I tried the testgles.cpp. Unfortunately, even this is full of old style fixed function calls like glMatrixMode(GL_MODELVIEW). And it's annoyingly over-integrated with SDLTest_Common code.
Is there a better simple clean hello world project (eg colored cube, textured cube) that I can start from?
Or is there some reason why they don't include such an example starting project or tutorial?
Or should I be using a different library instead of SDL2 that is simpler & cleaner to setup? Basically I want to write OpenGL / OpenGLES (and maybe DirectX) cross-platform C++ code. But setting up SDL2 has been a lot messier and more painful than I expected.
So far I just made an svn repository with SDL2 code and got testgl.cpp and testgles.cpp to build on those five platforms. But that used a lot of old style OpenGL/OpenGLES code, so now I am slowly hacking it to use newer stuff... It's been quite a pain. I don't get why SDL2 doesn't just include a basic hello world cross-platform starting project (eg textured cube) using modern OpenGL/OpenGLES (and DirectX).
SDL2 is a good way to start. I could even say, that SDL is the most popular and yet multiplatform lib for that, especially is you think about using joystics or going steam later on. There is no need to look for any other lib. But please remember, that it's just low level layer for providing media access. It's not their job to provide high quality Opengl 3.0 projects to users. What you need is to learn some modern OGL basics - and you have to do it somewhere else. As simple as that.
A good place to start is http://www.open.gl. There is a couple of very straightforward and simple tutorials written in C++ with some SDL and SFML approach.
Lazy Foo also cover some of the topic http://lazyfoo.net/tutorials/SDL/
http://openme.gl/ is also nice, maybe http://openme.gl/opengl-4-x-example-using-sdl2-and-glm/ is something for you. It seems to be a quite good quality code.
http://www.opengl-tutorial.org/ is also a great place to learn OpenGL 3.3+. It's recomended in many places.
You can always come with some kind of project like this and link to official SDL wiki. ;) SDL community will be greatfull for that.
And by the way. DirectX is "Microsoft's non-opensource SDL" - and it's very non-crossplatform.
If you want to write cross platform OpenGL, you might take a look at GLFW for setting up your OpenGL context. It handles simple window and context creation as well as user input.
I have a method to render a colored cube in some of my example code here. It's pretty enmeshed in my library though as it makes lots of calls out to my wrapper classes. They're also available in the same library, or you can take a look at the latest version of them here.

Libgdx with android xml?

I'm using the libraries LIBGDX to make an application and be able to run on both Android as a computer. I'd like to introduce a new library to create graphs in android, but do not know if I can add libraries that are for use with Android and libgdx and also running on the computer.
Nor if you can work in a similar way to how you normally program in android, and I want to do the designs from the GUI of android that I'm used to and I find it more comfortable. Also when the xml type strings.xml for example, I wonder if I can use them or not. Thank you.
There are two ways to build libraries (really, any code at all) that runs with libGDX:
Use only the libGDX-provided APIs. For example, if you render your graphs with the OpenGL wrapper provided by libGDX, it will work everywhere. Or if you use the "scene2d" UI APIs, it will work everywhere.
Implement a generic front-end library that uses libGDX APIs, and then calls out to backend-specific libraries that implement platform-specific bits. For your example, that would entail building an Android-based backend that perhaps used Android-specific UI rendering, and then building a separate desktop-based backend that perhaps used Swing or some other Java-desktop-specific APIs.
If all of your code is using the second approach, you're not really getting much benefit from libGDX.

Android Animations?

I would like to create an android game but one thing I do not understand is what I should use to create the graphics for it,
It is going to be a 2d game with movable images but would I use OpenGL ES or something else?
You should use OpenGl ES to get the best performance. Alternatively you could use Canvas drawing which is the default way of drawing in Android...
But the easiest way of creating an Android game probably by using Unity 3D...
Not Java development thoe :)
Try it via libgdx
it is easy to use.
Thanks
LibGDX is a fast library that is essentially a wrapper around OpenGL, saving you a lot of time. Unfortunately the documentation around it is severely lacking, so there is quite a steep learning curve, but once you are used to the library development is very fast.
It also gives you the option to run your code as a java application instead of the android emulator, which saves a lot of time.
There are a few good tutorials on the wiki to help you get started, but you will ultimately have to rely on the Java Docs and the test code to see how to use the library properly.
There are other options such as AndEngine, which is easier to learn but has less flexbility and runs slower, so ultimately you are better off with LibGDX.

Porting a game developed in Qt (for KDE) to Android

I have game (of cards based on Contract Bridge) written in Qt (QML) for KDE, now I'm supposed to port the entire game to Android (with Android apapted UI of course). At first I considered to use Necessitas (a Qt port for Android) but found that it is still under development and is currently in 3rd Alpha. I'm new to Android development (as well as game development), while I have experience working in Java, C++ and web technologies like HTML5, JavaScript.
Hence based on my skills, I considered using MoSync. But I'm not sure if I'll be able to use any existing modules of game already developed in Qt (while in MoSync its possible to invoke C++ code from JavaScript and vice-versa), and since I didn't worked on the Qt version of the game, I'll first have to refer to that code and then I'll be working on Android version of the same. So I need suggestion that from where should I start. Also, I have 1.5 months of duration to complete the project (without any working hour constraints), so also suggest me if its a good idea to work from scratch using Android APIs.
Please let me know if I need to elaborate the question even further.
Thanks.
I recommend taking a look at V-Play (v-play.net). It's a cross platform game engine based on Qt/QML .
If your game is already written in QML, you have the least porting effort because you can use almost all of your existing code, and use V-Play QML game components for handling multiple display resolutions & aspect ratios, animations, particles, physics, multi-touch, gestures, path finding and more (API reference).
You can also take a look at Benefits to find out if V-Play satisfies your demands.
Qt is more cross-platform than ever now. instead of porting, just modify it a little and continue with Qt, then compile for iOS, Android, etc.

How well does Unity 3d work for both Android and iPhone?

I'm not sure if this is the best place to ask this question so if it isn't please let me know and I will move it. I am looking to create a game for both Android and iPhone platform. I know Unity is a great game engine and my question is how well does it work for creating one code base to build for both Android and iPhone platforms? Time is a constraint on this project so I am very interested in how smoothly the process usually is when trying to build both applications and how much custom code must be written for each specific application. Any insite that people have on this topic would be much appreciated thanks.
Unity, as implied by it's very name, is designed explicitly to facilitate such multi-platform development in little time. You can for example define for each platform what the max size of each texture is, and it will automatically resize them for you when you build for that target platform - the build process really simple too. Since both your platforms are touch devices, it should be easy to have just one code base working seamlessly for both platforms (and more if needed), with very few custom code for each platform.
Unity has a no-questions-asked 30 day trial of the Android and (I think) iOS versions - I encourage you to try them and see for yourself how little time it will take you to have a proof of concept build for both platforms.

Categories

Resources