21 package com.arm.malideveloper.openglessdk.projectedLights;
23 import android.content.Context;
24 import android.opengl.GLSurfaceView;
25 import javax.microedition.khronos.egl.EGL10;
26 import javax.microedition.khronos.egl.EGLConfig;
27 import javax.microedition.khronos.egl.EGLContext;
28 import javax.microedition.khronos.egl.EGLDisplay;
29 import javax.microedition.khronos.opengles.GL10;
31 class TutorialView
extends GLSurfaceView
33 protected int redSize = 5;
34 protected int greenSize = 6;
35 protected int blueSize = 5 ;
36 protected int alphaSize = 0;
37 protected int depthSize = 16;
38 protected int sampleSize = 4;
39 protected int stencilSize = 0;
41 public TutorialView(Context context)
44 setEGLContextFactory(
new ContextFactory());
45 setEGLConfigChooser(
new ConfigChooser());
46 setRenderer(
new Renderer());
49 private static class ContextFactory
implements GLSurfaceView.EGLContextFactory
51 public EGLContext
createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig)
53 final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
54 int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION,
57 EGLContext context = egl.eglCreateContext(display,
65 public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context)
67 NativeLibrary.uninit();
68 egl.eglDestroyContext(display, context);
72 protected class ConfigChooser
implements GLSurfaceView.EGLConfigChooser
76 final int EGL_OPENGL_ES2_BIT = 4;
78 EGL10.EGL_GREEN_SIZE, greenSize,
79 EGL10.EGL_BLUE_SIZE, blueSize,
80 EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
81 EGL10.EGL_SAMPLES, sampleSize,
82 EGL10.EGL_DEPTH_SIZE, depthSize,
83 EGL10.EGL_STENCIL_SIZE, stencilSize,
85 int num_config[] =
new int[1];
89 int numConfigs = num_config[0];
90 EGLConfig configs[] =
new EGLConfig[numConfigs];
92 egl.eglChooseConfig(display,
configAttributes, configs, numConfigs, num_config);
97 private static class Renderer
implements GLSurfaceView.Renderer
101 NativeLibrary.step();
GLint GLsizei GLsizei height
void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context)
void onSurfaceChanged(GL10 gl, int width, int height)
void onSurfaceCreated(GL10 gl, EGLConfig config)
EGLint configAttributes[]
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig)
void onDrawFrame(GL10 gl)