21 package com.arm.malideveloper.openglessdk;
23 import android.content.Context;
24 import android.opengl.GLSurfaceView;
25 import android.util.Log;
26 import javax.microedition.khronos.egl.EGL10;
27 import javax.microedition.khronos.egl.EGLConfig;
28 import javax.microedition.khronos.egl.EGLContext;
29 import javax.microedition.khronos.egl.EGLDisplay;
47 protected static String
LOG_TAG =
"MaliSamplesView";
105 public EGLContext
createContext(EGL10 egl, EGLDisplay display, EGLConfig config)
108 final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
111 while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS)
113 Log.e(
LOG_TAG, String.format(
"Before TheEGLContextFactory.createContext(): EGL error: 0x%x", error));
117 int[] attribs = {EGL_CONTEXT_CLIENT_VERSION, glesVersion.getValue(), EGL10.EGL_NONE };
119 EGLContext context = egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT, attribs);
121 while ((error = egl.eglGetError()) != EGL10.EGL_SUCCESS)
123 Log.e(
LOG_TAG, String.format(
"After TheEGLContextFactory.createContext(): EGL error: 0x%x", error));
133 egl.eglDestroyContext(display, context);
144 protected int getConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config,
int attribute,
int defaultValue)
146 int[] ret =
new int[1];
148 if (egl.eglGetConfigAttrib(display, config, attribute, ret))
159 for(EGLConfig cfg : configs)
178 final int EGL_OPENGL_ES2_BIT = 4;
185 EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
190 int[] num_config =
new int[1];
191 egl.eglChooseConfig(display, attribs, null, 0, num_config);
193 int numConfigs = num_config[0];
197 Log.e(
LOG_TAG,
"No EGL configs were found.");
201 EGLConfig[] configs =
new EGLConfig[numConfigs];
202 egl.eglChooseConfig(display, attribs, configs, numConfigs, num_config);
abstract void destroyContextCallback()
GLboolean GLboolean GLboolean GLboolean a
MaliSamplesView(Context context, GlesVersion version)
EGLConfig SelectAnEGLConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs)
void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context)
int getConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue)
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display)
MaliSamplesView(Context context)
EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config)
GLboolean GLboolean GLboolean b
abstract void setRendererCallback()