Java 8 EGL10 - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 EGL10 class.

This code example shows how to use the following methods:eglDestroyContext, eglDestroySurface, eglMakeCurrent, eglTerminate
This code example shows how to use the following methods:eglCreateWindowSurface, eglDestroySurface, eglMakeCurrent
	 */ 
	public GL createSurface(final SurfaceHolder pSurfaceHolder) {
		/* The window size has changed, so we need to create a new surface. */ 
		if (this.mEGLSurface != null && this.mEGLSurface != EGL10.EGL_NO_SURFACE) {
			/* Unbind and destroy the old EGL surface, if there is one. */ 
			this.mEGL.eglMakeCurrent(this.mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
			this.mEGL.eglDestroySurface(this.mEGLDisplay, this.mEGLSurface);
		} 
 
		/* Create an EGL surface we can render into. */ 
		this.mEGLSurface = this.mEGL.eglCreateWindowSurface(this.mEGLDisplay, this.mEGLConfig, pSurfaceHolder, null);
 
		if (this.mEGLSurface == null || this.mEGLSurface == EGL10.EGL_NO_SURFACE) {
			throw new RuntimeException("createSurface failed");
		} 
 
		/* Before we can issue GL commands, we need to make sure the context is current and bound to a surface. */ 
		if (!this.mEGL.eglMakeCurrent(this.mEGLDisplay, this.mEGLSurface, this.mEGLSurface, this.mEGLContext)) {
			throw new RuntimeException("eglMakeCurrent failed.");
		} 

8
CodeRank
This code example shows how to use the following methods:eglChooseConfig, eglCreateContext, eglCreateWindowSurface, eglGetDisplay, eglGetError
        } 
         
        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");

7
CodeRank
This code example shows how to use the following methods:eglCreateContext
	private static String TAG = "GL2JNIView";
	private static int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
 
	public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
		Log.w(TAG, "creating OpenGL ES 2.0 context");
		GL2JNIView.checkEglError("Before eglCreateContext", egl);
		int[] attrib_list = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
		EGLContext context = egl.eglCreateContext(display, eglConfig, EGL10.EGL_NO_CONTEXT, attrib_list);
		GL2JNIView.checkEglError("After eglCreateContext", egl);
		return context;
	} 
 
	public void destroyContext(EGL10 egl, EGLDisplay display, EGLContext context) {
		egl.eglDestroyContext(display, context);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:eglChooseConfig, eglCreateContext, eglCreateWindowSurface, eglGetDisplay, eglInitialize
        } 
 
        private void doInitGL() { 
            // These are copied from GLSurfaceView 
            mEgl = (EGL10) EGLContext.getEGL();
            mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
            if (mEglDisplay == EGL10.EGL_NO_DISPLAY) {
                throw new RuntimeException("eglGetDisplay failed");
            } 
            int[] version = new int[2];
            if (!mEgl.eglInitialize(mEglDisplay, version)) {
                throw new RuntimeException("eglInitialize failed");
            } else { 
                Log.v(TAG, "EGL version: " + version[0] + '.' + version[1]);
            } 
            int[] attribList = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
            mEglConfig = chooseConfig(mEgl, mEglDisplay);
            mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig, EGL10.EGL_NO_CONTEXT,
                                                attribList);
 

7
CodeRank
This code example shows how to use the following methods:eglChooseConfig, eglGetError
        }; 
 
        // No error checking performed, minimum required code to elucidate logic 
        // Expand on this logic to be more selective in choosing a configuration 
        int[] numConfig = new int[1];
        mEGL.eglChooseConfig(mEGLDisplay, attribList, null, 0, numConfig);
        int configSize = numConfig[0];
        mEGLConfigs = new EGLConfig[configSize];
        mEGL.eglChooseConfig(mEGLDisplay, attribList, mEGLConfigs, configSize, numConfig);
 
        int error = mEGL.eglGetError();
        if (error != EGL_SUCCESS) {
            Log.e(TAG, "eglChooseConfig: " + error);
        } 
 
        if (LIST_CONFIGS) {
            listConfig(); 
        } 
 
        return mEGLConfigs[0];  // Best match is probably the first configuration
7
CodeRank
This code example shows how to use the following methods:eglGetDisplay, eglInitialize
		this.mEgl = (EGL10) EGLContext.getEGL();
 
		/* 
		 * Get to the default display. 
		 */ 
		this.mEglDisplay = this.mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
 
		/* 
		 * We can now initialize EGL for that display 
		 */ 
		final int[] version = new int[2];
		this.mEgl.eglInitialize(this.mEglDisplay, version);
		this.mEglConfig = this.mEGLConfigChooser.chooseConfig(this.mEgl, this.mEglDisplay);
 
		/* 
		 * Create an OpenGL ES context. This must be done only once, an OpenGL 
		 * context is a somewhat heavy object. 
		 */ 
		this.mEglContext = this.mEGLContextFactory.createContext(this.mEgl, this.mEglDisplay, this.mEglConfig);
		if (this.mEglContext == null || this.mEglContext == EGL10.EGL_NO_CONTEXT) {
7
CodeRank
This code example shows how to use the following methods:eglDestroyContext, eglDestroySurface, eglMakeCurrent, eglTerminate
         
        void stopAnimation() { 
            /* 
             * clean-up everything... 
             */ 
            egl.eglMakeCurrent(dpy, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE,
                    EGL10.EGL_NO_CONTEXT);
            egl.eglDestroySurface(dpy, surface);
            egl.eglDestroyContext(dpy, context);
            egl.eglTerminate(dpy);
        } 
         
        private void drawFrame(GL10 gl) {
        	/* 
             * Usually, the first thing one might want to do is to clear 
             * the screen. The most efficient way of doing this is to use 
             * glClear(). 
             */ 
 
            gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
7
CodeRank
This code example shows how to use the following methods:eglGetConfigAttrib
		else 
			return safe;
	} 
 
	private int findConfigAttrib (EGL10 egl, EGLDisplay display, EGLConfig config, int attribute, int defaultValue) {
		if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
			return mValue[0];
		} 
		return defaultValue;
	} 
 
	private void printConfigs (EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
		int numConfigs = configs.length;
		Log.w(TAG, String.format("%d configurations", numConfigs));
		for (int i = 0; i < numConfigs; i++) {
			Log.w(TAG, String.format("Configuration %d:\n", i));
			printConfig(egl, display, configs[i]);
		} 
	} 
 
7
CodeRank
This code example shows how to use the following methods:eglDestroyContext, eglDestroySurface, eglTerminate
	 public void destroyContext() 
	 { 
		 if(surface != null && context != null)
		 { 
			 EGL10 egl = (EGL10)EGLContext.getEGL();
			 egl.eglDestroySurface(display, surface);
			 egl.eglDestroyContext(display, context);
			 egl.eglTerminate(display);
		 } 
	     	      
	     context = null;
	     configs = null;
	     display = null;
	     surface = null;
	 } 
	  
	 protected void finalize() throws Throwable 
	 { 
		 this.destroyContext();
		 super.finalize(); 
7
CodeRank