diff options
author | Jack Palevich <jackpal@google.com> | 2009-09-25 19:07:31 -0700 |
---|---|---|
committer | Jack Palevich <jackpal@google.com> | 2009-09-25 19:07:31 -0700 |
commit | aa3b0bee51e9e7c0d46f93bcdcfee62b004b3a78 (patch) | |
tree | 323772d6bf00f988ac0305f1862bcde2ce6312e5 /opengl | |
parent | 2e26fc08aa1939c19e939d983bd608cdec050024 (diff) | |
download | frameworks_base-aa3b0bee51e9e7c0d46f93bcdcfee62b004b3a78.zip frameworks_base-aa3b0bee51e9e7c0d46f93bcdcfee62b004b3a78.tar.gz frameworks_base-aa3b0bee51e9e7c0d46f93bcdcfee62b004b3a78.tar.bz2 |
Tighten up sample code.
- Still fails to work; don't know why.
Diffstat (limited to 'opengl')
-rw-r--r-- | opengl/tests/gl2_jni/Android.mk | 2 | ||||
-rw-r--r-- | opengl/tests/gl2_jni/jni/gl_code.cpp | 26 | ||||
-rw-r--r-- | opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java | 19 |
3 files changed, 25 insertions, 22 deletions
diff --git a/opengl/tests/gl2_jni/Android.mk b/opengl/tests/gl2_jni/Android.mk index ff15814..81247df 100644 --- a/opengl/tests/gl2_jni/Android.mk +++ b/opengl/tests/gl2_jni/Android.mk @@ -44,8 +44,6 @@ LOCAL_SHARED_LIBRARIES := \ LOCAL_MODULE := libgl2jni -LOCAL_ARM_MODE := arm - LOCAL_PRELINK_MODULE := false include $(BUILD_SHARED_LIBRARY) diff --git a/opengl/tests/gl2_jni/jni/gl_code.cpp b/opengl/tests/gl2_jni/jni/gl_code.cpp index 146d52a..c2fabe6 100644 --- a/opengl/tests/gl2_jni/jni/gl_code.cpp +++ b/opengl/tests/gl2_jni/jni/gl_code.cpp @@ -3,12 +3,12 @@ #include <nativehelper/jni.h> #define LOG_TAG "GL2JNI gl_code.cpp" #include <utils/Log.h> -
+ #include <EGL/egl.h> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> -#include <stdio.h>
+#include <stdio.h> #include <stdlib.h> #include <math.h> @@ -23,7 +23,7 @@ static void checkGlError(const char* op) { LOGI("after %s() glError (0x%x)\n", op, error); } } -
+ static const char gVertexShader[] = "attribute vec4 vPosition;\n" "void main() {\n" " gl_Position = vPosition;\n" @@ -151,15 +151,15 @@ void renderFrame() { extern "C" { JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_init(JNIEnv * env, jobject obj, jint width, jint height); JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj); -};
-
+}; + JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_init(JNIEnv * env, jobject obj, jint width, jint height)
-{
- setupGraphics(width, height);
-}
- -JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj)
-{
- renderFrame();
-}
+{ + setupGraphics(width, height); +} + +JNIEXPORT void JNICALL Java_com_android_gl2jni_GL2JNILib_step(JNIEnv * env, jobject obj) +{ + renderFrame(); +} diff --git a/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java b/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java index baa10af..8b94dec 100644 --- a/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java +++ b/opengl/tests/gl2_jni/src/com/android/gl2jni/GL2JNIView.java @@ -44,6 +44,7 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; import javax.microedition.khronos.opengles.GL10; + /** * An implementation of SurfaceView that uses the dedicated surface for * displaying an OpenGL animation. This allows the animation to run in a @@ -67,13 +68,14 @@ class GL2JNIView extends GLSurfaceView { private void init() { setEGLContextFactory(new ContextFactory()); - // setEGLConfigChooser(new ConfigChooser()); + setEGLConfigChooser(new ConfigChooser()); setRenderer(new Renderer()); } private static class ContextFactory implements GLSurfaceView.EGLContextFactory { private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098; public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) { + Log.w(TAG, "creating OpenGL ES 2.0 context"); checkEglError("Before eglCreateContext", egl); int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE }; EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list); @@ -83,7 +85,7 @@ class GL2JNIView extends GLSurfaceView { public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) { egl.eglDestroyContext(display, context); - } + } } private static void checkEglError(String prompt, EGL10 egl) { @@ -95,11 +97,13 @@ class GL2JNIView extends GLSurfaceView { private static class ConfigChooser implements GLSurfaceView.EGLConfigChooser { private static int EGL_OPENGL_ES2_BIT = 4; - private static int[] s_configAttribs2 = + private static int[] s_configAttribs2 = { - EGL10.EGL_DEPTH_SIZE, 16, - // EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL10.EGL_NONE + EGL10.EGL_RED_SIZE, 4, + EGL10.EGL_GREEN_SIZE, 4, + EGL10.EGL_BLUE_SIZE, 4, + EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL10.EGL_NONE }; public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) { @@ -108,12 +112,13 @@ class GL2JNIView extends GLSurfaceView { int numConfigs = num_config[0]; + Log.w(TAG, String.format("Found %d configurations", numConfigs)); if (numConfigs <= 0) { throw new IllegalArgumentException("No configs match configSpec"); } EGLConfig[] configs = new EGLConfig[numConfigs]; egl.eglChooseConfig(display, s_configAttribs2, configs, numConfigs, num_config); - return configs[0]; + return configs[0s]; } } |