javax.microedition.khronos.egl.EGL10 Java Examples

The following examples show how to use javax.microedition.khronos.egl.EGL10. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GLTextureView.java    From VideoRecorder with Apache License 2.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
        EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                     EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                      EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #2
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #3
Source File: GLTextureView.java    From MD360Player4Android with Apache License 2.0 6 votes vote down vote up
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
    int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, mConfigSpec, null, 0,
            num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }

    int numConfigs = num_config[0];

    if (numConfigs <= 0) {
        throw new IllegalArgumentException(
                "No configs match configSpec");
    }

    EGLConfig[] configs = new EGLConfig[numConfigs];
    if (!egl.eglChooseConfig(display, mConfigSpec, configs, numConfigs,
            num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #4
Source File: PixelBuffer.java    From Fatigue-Detection with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig() {
    int[] attribList = new int[] {
            EGL_DEPTH_SIZE, 0,
            EGL_STENCIL_SIZE, 0,
            EGL_RED_SIZE, 8,
            EGL_GREEN_SIZE, 8,
            EGL_BLUE_SIZE, 8,
            EGL_ALPHA_SIZE, 8,
            EGL10.EGL_RENDERABLE_TYPE, 4,
            EGL_NONE
    };

    // 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);

    if (LIST_CONFIGS) {
        listConfig();
    }

    return mEGLConfigs[0]; // Best match is probably the first configuration
}
 
Example #5
Source File: EGL.java    From BambooPlayer with Apache License 2.0 6 votes vote down vote up
public void start() {
  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");
  }
  mEglConfig = mEGLConfigChooser.chooseConfig(mEgl, mEglDisplay);

  mEglContext = mEGLContextFactory.createContext(mEgl, mEglDisplay, mEglConfig);
  if (mEglContext == null || mEglContext == EGL10.EGL_NO_CONTEXT) {
    mEglContext = null;
    throwEglException("createContext");
  }

  mEglSurface = null;
}
 
Example #6
Source File: OutputSurface.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public void release() {
    if (mEGL != null) {
        if (mEGL.eglGetCurrentContext().equals(mEGLContext)) {
            mEGL.eglMakeCurrent(mEGLDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
        }
        mEGL.eglDestroySurface(mEGLDisplay, mEGLSurface);
        mEGL.eglDestroyContext(mEGLDisplay, mEGLContext);
    }
    if (mTextureRender != null) {
        mTextureRender.release();
    }
    mSurface.release();
    mEGLDisplay = null;
    mEGLContext = null;
    mEGLSurface = null;
    mEGL = null;
    mTextureRender = null;
    mSurface = null;
    mSurfaceTexture = null;
}
 
Example #7
Source File: GLThread.java    From android-openGL-canvas with Apache License 2.0 6 votes vote down vote up
private int[] filterConfigSpec(int[] configSpec) {
    if (contextClientVersion != 2 && contextClientVersion != 3) {
        return configSpec;
    }
    /* We know none of the subclasses define EGL_RENDERABLE_TYPE.
     * And we know the configSpec is well formed.
     */
    int len = configSpec.length;
    int[] newConfigSpec = new int[len + 2];
    System.arraycopy(configSpec, 0, newConfigSpec, 0, len - 1);
    newConfigSpec[len - 1] = EGL10.EGL_RENDERABLE_TYPE;
    if (contextClientVersion == 2) {
        newConfigSpec[len] = EGL14.EGL_OPENGL_ES2_BIT;  /* EGL_OPENGL_ES2_BIT */
    } else {
        newConfigSpec[len] = EGLExt.EGL_OPENGL_ES3_BIT_KHR; /* EGL_OPENGL_ES3_BIT_KHR */
    }
    newConfigSpec[len + 1] = EGL10.EGL_NONE;
    return newConfigSpec;
}
 
Example #8
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #9
Source File: GLTextureView.java    From EZFilter with MIT License 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #10
Source File: DefaultConfigChooser.java    From GPUVideo-android with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {
    // 要求されている仕様から使用可能な構成の数を抽出します。
    final int[] num_config = new int[1];
    if (!egl.eglChooseConfig(display, configSpec, null, 0, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig failed");
    }
    final int config_size = num_config[0];
    if (config_size <= 0) {
        throw new IllegalArgumentException("No configs match configSpec");
    }

    // 実際の構成を抽出します。
    final EGLConfig[] configs = new EGLConfig[config_size];
    if (!egl.eglChooseConfig(display, configSpec, configs, config_size, num_config)) {
        throw new IllegalArgumentException("eglChooseConfig#2 failed");
    }
    final EGLConfig config = chooseConfig(egl, display, configs);
    if (config == null) {
        throw new IllegalArgumentException("No config chosen");
    }
    return config;
}
 
Example #11
Source File: DefaultConfigChooser.java    From GPUVideo-android with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display, final EGLConfig[] configs) {
    for (final EGLConfig config : configs) {
        final int d = findConfigAttrib(egl, display, config, EGL_DEPTH_SIZE, 0);
        final int s = findConfigAttrib(egl, display, config, EGL_STENCIL_SIZE, 0);
        if ((d >= depthSize) && (s >= stencilSize)) {
            final int r = findConfigAttrib(egl, display, config, EGL_RED_SIZE, 0);
            final int g = findConfigAttrib(egl, display, config, EGL_GREEN_SIZE, 0);
            final int b = findConfigAttrib(egl, display, config, EGL_BLUE_SIZE, 0);
            final int a = findConfigAttrib(egl, display, config, EGL_ALPHA_SIZE, 0);
            if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #12
Source File: GLTextureView.java    From alpha-movie with Apache License 2.0 6 votes vote down vote up
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, null);
    } catch (IllegalArgumentException e) {
        // This exception indicates that the surface flinger surface
        // is not valid. This can happen if the surface flinger surface has
        // been torn down, but the application has not yet been
        // notified via SurfaceHolder.Callback.surfaceDestroyed.
        // In theory the application should be notified first,
        // but in practice sometimes it is not. See b/4588890
        Log.e(TAG, "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #13
Source File: DefaultConfigChooser.java    From CameraRecorder-android with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display, final EGLConfig[] configs) {
    for (final EGLConfig config : configs) {
        final int d = findConfigAttrib(egl, display, config, EGL_DEPTH_SIZE, 0);
        final int s = findConfigAttrib(egl, display, config, EGL_STENCIL_SIZE, 0);
        if ((d >= depthSize) && (s >= stencilSize)) {
            final int r = findConfigAttrib(egl, display, config, EGL_RED_SIZE, 0);
            final int g = findConfigAttrib(egl, display, config, EGL_GREEN_SIZE, 0);
            final int b = findConfigAttrib(egl, display, config, EGL_BLUE_SIZE, 0);
            final int a = findConfigAttrib(egl, display, config, EGL_ALPHA_SIZE, 0);
            if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #14
Source File: GPU.java    From DeviceInfo with Apache License 2.0 6 votes vote down vote up
@Override
            public EGLConfig chooseConfig(final EGL10 egl, final EGLDisplay display) {

                //Querying number of configurations
                final int[] num_conf = new int[1];
//                egl.eglGetConfigs(display, null, 0, num_conf); //if configuration array is null it still returns the number of configurations
                final int configurations = num_conf[0];

                //Querying actual configurations
                final EGLConfig[] conf = new EGLConfig[configurations];
//                egl.eglGetConfigs(display, conf, configurations, num_conf);

                EGLConfig result = null;

                for (int i = 0; i < configurations; i++) {
                    result = better(result, conf[i], egl, display);

                    /*final Egl config = new Egl(egl, display, conf[i]);
                    if (config.EGL_RED_SIZE + config.EGL_BLUE_SIZE + config.EGL_GREEN_SIZE + config.EGL_ALPHA_SIZE >= 16)
                        info.eglconfigs.add(config);*/
                }

                return result;
            }
 
Example #15
Source File: GLTextureView.java    From EZFilter with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display,
                              EGLConfig[] configs) {
    for (EGLConfig config : configs) {
        int d = findConfigAttrib(egl, display, config,
                EGL10.EGL_DEPTH_SIZE, 0);
        int s = findConfigAttrib(egl, display, config,
                EGL10.EGL_STENCIL_SIZE, 0);
        if ((d >= mDepthSize) && (s >= mStencilSize)) {
            int r = findConfigAttrib(egl, display, config,
                    EGL10.EGL_RED_SIZE, 0);
            int g = findConfigAttrib(egl, display, config,
                    EGL10.EGL_GREEN_SIZE, 0);
            int b = findConfigAttrib(egl, display, config,
                    EGL10.EGL_BLUE_SIZE, 0);
            int a = findConfigAttrib(egl, display, config,
                    EGL10.EGL_ALPHA_SIZE, 0);
            if ((r == mRedSize) && (g == mGreenSize)
                    && (b == mBlueSize) && (a == mAlphaSize)) {
                return config;
            }
        }
    }
    return null;
}
 
Example #16
Source File: ConfigChooser.java    From tilt-game-android with MIT License 6 votes vote down vote up
private EGLConfig chooseConfig(final EGL10 pEGL, final EGLDisplay pEGLDisplay, final ConfigChooserMatcher pConfigChooserMatcher) throws IllegalArgumentException {
	ConfigChooser.BUFFER[0] = 0;

	int eglConfigCount;

	if (this.mRequestedMultiSampling) {
		eglConfigCount = this.getEGLConfigCount(pEGL, pEGLDisplay, this.mMultiSampleEGLConfig);
		if (eglConfigCount > 0) {
			this.mActualMultiSampling = true;
			return this.findEGLConfig(pEGL, pEGLDisplay, this.mMultiSampleEGLConfig, eglConfigCount, pConfigChooserMatcher);
		}

		eglConfigCount = this.getEGLConfigCount(pEGL, pEGLDisplay, this.mNvidiaCoverageMultiSampleEGLConfig);
		if (eglConfigCount > 0) {
			this.mActualCoverageMultiSampling = true;
			return this.findEGLConfig(pEGL, pEGLDisplay, this.mNvidiaCoverageMultiSampleEGLConfig, eglConfigCount, pConfigChooserMatcher);
		}
	}

	eglConfigCount = this.getEGLConfigCount(pEGL, pEGLDisplay, this.mDefaultEGLConfig);
	if (eglConfigCount > 0) {
		return this.findEGLConfig(pEGL, pEGLDisplay, this.mDefaultEGLConfig, eglConfigCount, pConfigChooserMatcher);
	} else {
		throw new IllegalArgumentException("No " + EGLConfig.class.getSimpleName() + " found!");
	}
}
 
Example #17
Source File: EGL.java    From video-player with MIT License 6 votes vote down vote up
@Override
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display, EGLConfig[] configs) {
  for (EGLConfig config : configs) {
    int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
    int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
    if ((d >= mDepthSize) && (s >= mStencilSize)) {
      int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
      int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
      int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
      int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
      if ((r == mRedSize) && (g == mGreenSize) && (b == mBlueSize) && (a == mAlphaSize)) {
        return config;
      }
    }
  }
  return null;
}
 
Example #18
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #19
Source File: GLSurfaceView.java    From NewsMe with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #20
Source File: ViEAndroidGLES20.java    From LiveVideo with Apache License 2.0 5 votes vote down vote up
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig eglConfig) {
	Log.w(TAG, "creating OpenGL ES 2.0 context");
	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);
	checkEglError("After eglCreateContext", egl);
	return context;
}
 
Example #21
Source File: EGLLogWrapper.java    From android-openGL-canvas with Apache License 2.0 5 votes vote down vote up
private void arg(String name, EGLContext object) {
    if (object == EGL10.EGL_NO_CONTEXT) {
        arg(name, "EGL10.EGL_NO_CONTEXT");
    } else {
        arg(name, toString(object));
    }
}
 
Example #22
Source File: EGLBase10.java    From libcommon with Apache License 2.0 5 votes vote down vote up
/**
 * eglGetCurrentSurfaceで取得したEGLSurfaceをラップする
 * @param eglBase
 */
private EglSurface(@NonNull final EGLBase10 eglBase) {
	mEglBase = eglBase;
	mEglSurface = eglBase.mEgl.eglGetCurrentSurface(EGL10.EGL_DRAW);
	mOwnSurface = false;
	setViewPort(0, 0, getWidth(), getHeight());
}
 
Example #23
Source File: PixelBuffer.java    From In77Camera with MIT License 5 votes vote down vote up
public PixelBuffer(final int width, final int height) {
    mWidth = width;
    mHeight = height;

    int[] version = new int[2];
    int[] attribList = new int[] {
            EGL_WIDTH, mWidth,
            EGL_HEIGHT, mHeight,
            EGL_NONE
    };

    // No error checking performed, minimum required code to elucidate logic
    mEGL = (EGL10) EGLContext.getEGL();
    mEGLDisplay = mEGL.eglGetDisplay(EGL_DEFAULT_DISPLAY);
    mEGL.eglInitialize(mEGLDisplay, version);
    mEGLConfig = chooseConfig(); // Choosing a config is a little more
                                 // complicated

    // mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig,
    // EGL_NO_CONTEXT, null);
    int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, 2,
            EGL10.EGL_NONE
    };
    mEGLContext = mEGL.eglCreateContext(mEGLDisplay, mEGLConfig, EGL_NO_CONTEXT, attrib_list);

    mEGLSurface = mEGL.eglCreatePbufferSurface(mEGLDisplay, mEGLConfig, attribList);
    mEGL.eglMakeCurrent(mEGLDisplay, mEGLSurface, mEGLSurface, mEGLContext);

    mGL = (GL10) mEGLContext.getGL();

    // Record thread owner of OpenGL context
    mThreadOwner = Thread.currentThread().getName();
}
 
Example #24
Source File: EGL.java    From BambooPlayer with Apache License 2.0 5 votes vote down vote up
public void destroySurface() {
  if (mEglSurface != null && mEglSurface != EGL10.EGL_NO_SURFACE) {
    mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
    mEGLWindowSurfaceFactory.destroySurface(mEgl, mEglDisplay, mEglSurface);
    mEglSurface = null;
  }
}
 
Example #25
Source File: PhotoFilterView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    if (!initied) {
        return;
    }

    if (!eglContext.equals(egl10.eglGetCurrentContext()) || !eglSurface.equals(egl10.eglGetCurrentSurface(EGL10.EGL_DRAW))) {
        if (!egl10.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
            if (BuildVars.LOGS_ENABLED) {
                FileLog.e("eglMakeCurrent failed " + GLUtils.getEGLErrorString(egl10.eglGetError()));
            }
            return;
        }
    }

    GLES20.glViewport(0, 0, renderBufferWidth, renderBufferHeight);
    drawEnhancePass();
    drawSharpenPass();
    drawCustomParamsPass();
    blured = drawBlurPass();

    //onscreen draw
    GLES20.glViewport(0, 0, surfaceWidth, surfaceHeight);
    GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
    GLES20.glClear(0);

    GLES20.glUseProgram(simpleShaderProgram);
    GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, renderTexture[blured ? 0 : 1]);
    GLES20.glUniform1i(simpleSourceImageHandle, 0);
    GLES20.glEnableVertexAttribArray(simpleInputTexCoordHandle);
    GLES20.glVertexAttribPointer(simpleInputTexCoordHandle, 2, GLES20.GL_FLOAT, false, 8, textureBuffer);
    GLES20.glEnableVertexAttribArray(simplePositionHandle);
    GLES20.glVertexAttribPointer(simplePositionHandle, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
    GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
    egl10.eglSwapBuffers(eglDisplay, eglSurface);
}
 
Example #26
Source File: BlockingGLTextureView.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
private static 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
    };
}
 
Example #27
Source File: PhotoFilterView.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void finish() {
    if (eglSurface != null) {
        egl10.eglMakeCurrent(eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
        egl10.eglDestroySurface(eglDisplay, eglSurface);
        eglSurface = null;
    }
    if (eglContext != null) {
        egl10.eglDestroyContext(eglDisplay, eglContext);
        eglContext = null;
    }
    if (eglDisplay != null) {
        egl10.eglTerminate(eglDisplay);
        eglDisplay = null;
    }
}
 
Example #28
Source File: GlTextureView.java    From ParticleView with Apache License 2.0 5 votes vote down vote up
/**
 * Display the current render surface.
 * @return the EGL error code from eglSwapBuffers.
 */
public int swap() {
    if (! mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
        return mEgl.eglGetError();
    }
    return EGL10.EGL_SUCCESS;
}
 
Example #29
Source File: EConfigChooser.java    From SimpleVideoEdit with Apache License 2.0 5 votes vote down vote up
private int findConfigAttrib(final EGL10 egl, final EGLDisplay display, final EGLConfig config, final int attribute, final int defaultValue) {
    final int[] value = new int[1];
    if (egl.eglGetConfigAttrib(display, config, attribute, value)) {
        return value[0];
    }
    return defaultValue;
}
 
Example #30
Source File: myGLTextureView.java    From opengl with Apache License 2.0 5 votes vote down vote up
private void checkCurrent() {
    if (!mEglContext.equals(mEgl.eglGetCurrentContext())
            || !mEglSurface.equals(mEgl
            .eglGetCurrentSurface(EGL10.EGL_DRAW))) {
        checkEglError();
        if (!mEgl.eglMakeCurrent(mEglDisplay, mEglSurface,
                mEglSurface, mEglContext)) {
            throw new RuntimeException(
                    "eglMakeCurrent failed "
                            + GLUtils.getEGLErrorString(mEgl
                            .eglGetError()));
        }
        checkEglError();
    }
}