How to use OpenGL ES 2.0 in Android SDK ( not NDK)?
I cannot find reference to this. All And开发者_JAVA技巧roid 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 ?
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/
This link shows the distribution of Android devices that support the different OpenGL ES versions: http://developer.android.com/resources/dashboard/opengl.html
You should check out this video http://www.youtube.com/watch?v=7-62tRHLcHk. The guy goes over device support for different OpenGL ES versions and shows you how to get started with OpenGL on the Android. He also talks about the fragmentation of devices and how you can support them. Basically most "2nd generation" devices support 2.0 and have been shipping since late 2009. If you're going to target just 2.0 devices then you'll obviously have to do a system check to make sure device X has the proper hardware specs.
If you want to see how to setup a basic OpenGL renderer in the SDK jump to 21:00 in that video.
精彩评论