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

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

Introduction

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

Prototype

EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window,
            int[] attrib_list);

Source Link

Usage

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

public static boolean createEGLSurface() {
    if (SDLActivity.mEGLDisplay != null && SDLActivity.mEGLConfig != null) {
        EGL10 egl = (EGL10) EGLContext.getEGL();
        if (SDLActivity.mEGLContext == null)
            createEGLContext();//from  ww w.j  a  v  a 2 s. c om

        Log.v("SDL", "Creating new EGL Surface");
        EGLSurface surface = egl.eglCreateWindowSurface(SDLActivity.mEGLDisplay, SDLActivity.mEGLConfig,
                SDLActivity.mSurface, null);
        if (surface == EGL10.EGL_NO_SURFACE) {
            Log.e("SDL", "Couldn't create surface");
            return false;
        }

        if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, surface, surface, SDLActivity.mEGLContext)) {
            Log.e("SDL", "Old EGL Context doesnt work, trying with a new one");
            createEGLContext();
            if (!egl.eglMakeCurrent(SDLActivity.mEGLDisplay, surface, surface, SDLActivity.mEGLContext)) {
                Log.e("SDL", "Failed making EGL Context current");
                return false;
            }
        }
        SDLActivity.mEGLSurface = surface;
        return true;
    }
    return false;
}