Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use OpenGL ES 2.0 in Android SDK ( not NDK)?

I cannot find reference to this. All Android developer docs are focused on OpenGL ES 1.0. How can I start using OpenGL 2.0 in Android SDK using API level 8? If level 8 is not supported then what level I need to use?

What percentage of android phones that are out there in the market currently support OpenGL ES 2.0 ?

like image 473
ace Avatar asked Feb 08 '11 18:02

ace


People also ask

Can I use OpenGL in Android?

While Vulkan is available only on devices running Android 7.0 or higher, OpenGL ES is supported by all Android versions.

Is OpenGL ES better than OpenGL?

The main difference between the two is that OpenGL ES is made for embedded systems like smartphones, while OpenGL is the one on desktops. On the coding level, OpenGL ES does not support fixed-function functions like glBegin/glEnd etc... OpenGL can support fixed-function pipeline (using a compatibility profile).

What is the latest version of OpenGL ES?

OpenGL ES 3.2 - Additional OpenGL functionality The latest in the series, OpenGL ES 3.2 added additional functionality based on the Android Extension Pack for OpenGL ES 3.1, which brought the mobile API's functionality significantly closer to it's desktop counterpart - OpenGL.


1 Answers

The problem is that you need to implement three methods in the GLSurfaceView that take at GL10 from the OS.

public void onDrawFrame(GL10 gl)
public void onSurfaceChanged(GL10 gl, int width, int height)
public void onSurfaceCreated(GL10 gl, EGLConfig config)

It looks like the solution is to ignore the GL10 entirely in your Renderer and just use all the GLES20 class's static methods.

public void onDrawFrame(GL10 glUnused) {
        GLES20.glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
        GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);
        GLES20.glUseProgram(mProgram);
        ...
}

All of the GLES20 static members are listed here: http://developer.android.com/reference/android/opengl/GLES20.html

Better documentation on those are in the Khronos docs. http://www.khronos.org/opengles/sdk/docs/man/

like image 149
Krylez Avatar answered Oct 13 '22 22:10

Krylez