Search in sources :

Example 41 with EGLSurface

use of javax.microedition.khronos.egl.EGLSurface in project android_frameworks_base by DirtyUnicorns.

the class EGLLogWrapper method eglCreateWindowSurface.

public EGLSurface eglCreateWindowSurface(EGLDisplay display, EGLConfig config, Object native_window, int[] attrib_list) {
    begin("eglCreateWindowSurface");
    arg("display", display);
    arg("config", config);
    arg("native_window", native_window);
    arg("attrib_list", attrib_list);
    end();
    EGLSurface result = mEgl10.eglCreateWindowSurface(display, config, native_window, attrib_list);
    returns(result);
    checkError();
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface)

Example 42 with EGLSurface

use of javax.microedition.khronos.egl.EGLSurface in project android_frameworks_base by ResurrectionRemix.

the class RenderTarget method newTarget.

public static RenderTarget newTarget(int width, int height) {
    EGL10 egl = (EGL10) EGLContext.getEGL();
    EGLDisplay eglDisplay = createDefaultDisplay(egl);
    EGLConfig eglConfig = chooseEglConfig(egl, eglDisplay);
    EGLContext eglContext = createContext(egl, eglDisplay, eglConfig);
    EGLSurface eglSurface = createSurface(egl, eglDisplay, width, height);
    RenderTarget result = new RenderTarget(eglDisplay, eglContext, eglSurface, 0, true, true);
    result.addReferenceTo(eglSurface);
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLContext(javax.microedition.khronos.egl.EGLContext) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Example 43 with EGLSurface

use of javax.microedition.khronos.egl.EGLSurface in project android_frameworks_base by crdroidandroid.

the class EGLLogWrapper method eglCreatePbufferSurface.

public EGLSurface eglCreatePbufferSurface(EGLDisplay display, EGLConfig config, int[] attrib_list) {
    begin("eglCreatePbufferSurface");
    arg("display", display);
    arg("config", config);
    arg("attrib_list", attrib_list);
    end();
    EGLSurface result = mEgl10.eglCreatePbufferSurface(display, config, attrib_list);
    returns(result);
    checkError();
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface)

Example 44 with EGLSurface

use of javax.microedition.khronos.egl.EGLSurface in project android_frameworks_base by crdroidandroid.

the class EGLLogWrapper method eglCreatePixmapSurface.

public EGLSurface eglCreatePixmapSurface(EGLDisplay display, EGLConfig config, Object native_pixmap, int[] attrib_list) {
    begin("eglCreatePixmapSurface");
    arg("display", display);
    arg("config", config);
    arg("native_pixmap", native_pixmap);
    arg("attrib_list", attrib_list);
    end();
    EGLSurface result = mEgl10.eglCreatePixmapSurface(display, config, native_pixmap, attrib_list);
    returns(result);
    checkError();
    return result;
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface)

Example 45 with EGLSurface

use of javax.microedition.khronos.egl.EGLSurface in project android_frameworks_base by crdroidandroid.

the class SingleFrameTextureViewTestActivity method onSurfaceTextureAvailable.

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
    Log.d(LOG_TAG, "onSurfaceAvailable");
    mGLThread = new Thread() {

        static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;

        static final int EGL_OPENGL_ES2_BIT = 4;

        private EGL10 mEgl;

        private EGLDisplay mEglDisplay;

        private EGLConfig mEglConfig;

        private EGLContext mEglContext;

        private EGLSurface mEglSurface;

        @Override
        public void run() {
            initGL();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
            }
            for (int i = 0; i < 2; i++) {
                if (i == 0) {
                    glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
                } else {
                    glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
                }
                glClear(GL_COLOR_BUFFER_BIT);
                Log.d(LOG_TAG, "eglSwapBuffers");
                if (!mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
                    throw new RuntimeException("Cannot swap buffers");
                }
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                }
            }
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
            }
            finishGL();
        }

        private void finishGL() {
            mEgl.eglDestroyContext(mEglDisplay, mEglContext);
            mEgl.eglDestroySurface(mEglDisplay, mEglSurface);
        }

        private void initGL() {
            mEgl = (EGL10) EGLContext.getEGL();
            mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
            if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
                throw new RuntimeException("eglGetDisplay failed " + GLUtils.getEGLErrorString(mEgl.eglGetError()));
            }
            int[] version = new int[2];
            if (!mEgl.eglInitialize(mEglDisplay, version)) {
                throw new RuntimeException("eglInitialize failed " + GLUtils.getEGLErrorString(mEgl.eglGetError()));
            }
            mEglConfig = chooseEglConfig();
            if (mEglConfig == null) {
                throw new RuntimeException("eglConfig not initialized");
            }
            mEglContext = createContext(mEgl, mEglDisplay, mEglConfig);
            mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay, mEglConfig, surface, null);
            if (mEglSurface == null || mEglSurface == EGL10.EGL_NO_SURFACE) {
                int error = mEgl.eglGetError();
                if (error == EGL10.EGL_BAD_NATIVE_WINDOW) {
                    Log.e(LOG_TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW.");
                    return;
                }
                throw new RuntimeException("createWindowSurface failed " + GLUtils.getEGLErrorString(error));
            }
            if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext)) {
                throw new RuntimeException("eglMakeCurrent failed " + GLUtils.getEGLErrorString(mEgl.eglGetError()));
            }
        }

        EGLContext createContext(EGL10 egl, EGLDisplay eglDisplay, EGLConfig eglConfig) {
            int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
            return egl.eglCreateContext(eglDisplay, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
        }

        private EGLConfig chooseEglConfig() {
            int[] configsCount = new int[1];
            EGLConfig[] configs = new EGLConfig[1];
            int[] configSpec = getConfig();
            if (!mEgl.eglChooseConfig(mEglDisplay, configSpec, configs, 1, configsCount)) {
                throw new IllegalArgumentException("eglChooseConfig failed " + GLUtils.getEGLErrorString(mEgl.eglGetError()));
            } else if (configsCount[0] > 0) {
                return configs[0];
            }
            return null;
        }

        private int[] getConfig() {
            return new int[] { EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL10.EGL_RED_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_DEPTH_SIZE, 0, EGL10.EGL_STENCIL_SIZE, 0, EGL10.EGL_NONE };
        }
    };
    mGLThread.start();
}
Also used : EGLSurface(javax.microedition.khronos.egl.EGLSurface) EGL10(javax.microedition.khronos.egl.EGL10) EGLDisplay(javax.microedition.khronos.egl.EGLDisplay) EGLContext(javax.microedition.khronos.egl.EGLContext) EGLConfig(javax.microedition.khronos.egl.EGLConfig)

Aggregations

EGLSurface (javax.microedition.khronos.egl.EGLSurface)48 EGLConfig (javax.microedition.khronos.egl.EGLConfig)20 TargetApi (android.annotation.TargetApi)8 EGL10 (javax.microedition.khronos.egl.EGL10)8 EGLContext (javax.microedition.khronos.egl.EGLContext)8 EGLDisplay (javax.microedition.khronos.egl.EGLDisplay)8