Example usage for javax.microedition.khronos.egl EGL10 EGL_RENDERABLE_TYPE

List of usage examples for javax.microedition.khronos.egl EGL10 EGL_RENDERABLE_TYPE

Introduction

In this page you can find the example usage for javax.microedition.khronos.egl EGL10 EGL_RENDERABLE_TYPE.

Prototype

int EGL_RENDERABLE_TYPE

To view the source code for javax.microedition.khronos.egl EGL10 EGL_RENDERABLE_TYPE.

Click Source Link

Usage

From source file:uk.co.armedpineapple.cth.SDLActivity.java

public static boolean initEGL(int majorVersion, int minorVersion) {
    if (SDLActivity.mEGLDisplay == null) {
        Log.v(SDLActivity.class.getSimpleName(), "Starting up OpenGL ES " + majorVersion + "." + minorVersion);

        try {//w ww. java  2 s .c  o m
            EGL10 egl = (EGL10) EGLContext.getEGL();

            EGLDisplay dpy = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);

            int[] version = new int[2];
            egl.eglInitialize(dpy, version);

            int EGL_OPENGL_ES_BIT = 1;
            int EGL_OPENGL_ES2_BIT = 4;
            int renderableType = 0;
            if (majorVersion == 2) {
                renderableType = EGL_OPENGL_ES2_BIT;
            } else if (majorVersion == 1) {
                renderableType = EGL_OPENGL_ES_BIT;
            }

            int[] configSpec = {
                    // EGL10.EGL_DEPTH_SIZE, 16,
                    EGL10.EGL_RENDERABLE_TYPE, renderableType, EGL10.EGL_NONE };
            EGLConfig[] configs = new EGLConfig[1];
            int[] num_config = new int[1];
            if (!egl.eglChooseConfig(dpy, configSpec, configs, 1, num_config) || num_config[0] == 0) {
                Log.e(SDLActivity.class.getSimpleName(), "No EGL config available");
                return false;
            }
            EGLConfig config = configs[0];

            SDLActivity.mEGLDisplay = dpy;
            SDLActivity.mEGLConfig = config;
            SDLActivity.mGLMajor = majorVersion;
            SDLActivity.mGLMinor = minorVersion;

            SDLActivity.createEGLSurface();
        } catch (Exception e) {
            Log.v("SDL", e + "");
            for (StackTraceElement s : e.getStackTrace()) {
                Log.v("SDL", s.toString());
            }
        }
    } else
        SDLActivity.createEGLSurface();

    return true;
}