Jump to content
  • Advertisement
Sign in to follow this  
_OskaR

OpenGL OpenGL ES 2.0, Android - beginner

This topic is 2989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to start GL ES 2.0 programming for Android (earlier I've written few programs using Visual C++, GL 3.2 and older). I found http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES2xSGX.asp and tested few examples on cellphone. Also I chcecked http://developer.android.com/resources/tutorials/hello-world.html and created simple application. Now the questions:
1. Which language? C++ or java? Do I need to know java to create games?
2. Which IDE for Windows? I suppose Eclipse is good for java but what if is possible to create full project using C++? In GL ES SDK for Android I found examples with C++ files - what to do co connect all parts? Command line only?
3. Do I need libraries etc. like GLEW, gl3.h for normal OpenGL?
4. Is possible to run GL application by AVD or better to use sth like GL emulator?
5. Any good tutorials?

Share this post


Link to post
Share on other sites
Advertisement
You can not make Android program entirely in C++ currently. Offical SDK supports applications only written in Java language (compiled to Dalvik bytecode). But nevertheless you can write parts of your application/game (rendering code, game objects, etc..) in C++. In Java you need to write only app startup and some touch input events, pause/resume code.

You don't need Glew or Glee, or any GL heeaders - everything for that is included in Android NDK. Android NDK apps can be build from any IDE that supports make command calling on command line.

I'm not sure, but I think ES 2.0 runs on Android Emulator in software mode (no hardware acceleration).

Android NDK includes san-angeles application that uses C++ for rendering with some parts of Java code to connect it to Android application.

Share this post


Link to post
Share on other sites
I'm not sure about not needing gl headers... I have:
#include <GLES/gl.h>

and I'm pretty sure it is indeed necessary. I'm using C, not C++ and having a great time with it. As bubu LV said, you can't do the whole thing in C/C++ but since we're talking about OpenGL you can do tons from the native side. For me, I follow the Java example of setting up a GLSurfaceView and GLSurfaceView.Renderer as well as starting a 3rd thread for the game loop. I have very little Java code so far (though will probably have more when I get to more UI coding).

Learning JNI (Java Native Interface) is a little tricky at first, but I find that I didn't need to learn very much of for OpenGL it as I don't care to pull information from Java to the Native side much if at all. For example, early on in init code I locate the sd card directory in through Java Android API and pass it as a jstring through JNI to the native environment, and once there can call standard C i/o functions on files on the sd card using that path. I don't recommend trying to get at files packaged in the apk, through native code though, that's substantially more difficult (though possible). Search the NDK google group if you want to do that.

I went with Eclipse because there's very easy to follow setup for the SDK for it. Also, I'm used to coding in C without an IDE and didn't know any Java. Having Eclipse baby-sit my Java code has been a life saver.

OpenGL runs in emulator BUT the supported extensions is really limited, as far as I only OpenGL ES 1.0 commands work so testing on hardware is a necessity. This may have changed, though as I have not upgraded my NDK to R4.

As for tutorials, Google for JNI Sucks and you'll hit how to properly setup a JNI_OnLoad function.... it's ragging on it, but it has all the right information. Go to StackOverflow for questions... I've had far better luck there then in the Google NDK group I'm afraid. I'm not aware of too many other tutorials... but the examples have a wealth of information. Best of luck to you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!