javax.microedition.khronos.egl.EGLConfig Java Examples

The following examples show how to use javax.microedition.khronos.egl.EGLConfig. 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: PixelBuffer.java    From SimpleVideoEditor with Apache License 2.0 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 #2
Source File: EglBase10Impl.java    From webrtc_android with MIT License 6 votes vote down vote up
private EGLContext createEglContext(
      EGLContext sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
  if (sharedContext != null && sharedContext == EGL10.EGL_NO_CONTEXT) {
    throw new RuntimeException("Invalid sharedContext");
  }
  int[] contextAttributes = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE};
  EGLContext rootContext = sharedContext == null ? EGL10.EGL_NO_CONTEXT : sharedContext;
  final EGLContext eglContext;
  synchronized (EglBase.lock) {
    eglContext = egl.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes);
  }
  if (eglContext == EGL10.EGL_NO_CONTEXT) {
    throw new RuntimeException(
        "Failed to create EGL context: 0x" + Integer.toHexString(egl.eglGetError()));
  }
  return eglContext;
}
 
Example #3
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 #4
Source File: GLTextureView.java    From PhotoMovie 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 #5
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public EGLSurface createWindowSurface(EGL10 egl, EGLDisplay display,
                                      EGLConfig config, Object nativeWindow) {

    int[] surfaceAttribs = {
            EGL10.EGL_NONE
    };
    EGLSurface result = null;
    try {
        result = egl.eglCreateWindowSurface(display, config, nativeWindow, surfaceAttribs);
    } 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("DefaultWindow", "eglCreateWindowSurface", e);
    }
    return result;
}
 
Example #6
Source File: GlCameraPreview.java    From Lassi-Android with MIT License 6 votes vote down vote up
@RendererThread
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    mOutputViewport = new EglViewport();
    mOutputTextureId = mOutputViewport.createTexture();
    mInputSurfaceTexture = new SurfaceTexture(mOutputTextureId);
    getView().queueEvent(new Runnable() {
        @Override
        public void run() {
            for (RendererFrameCallback callback : mRendererFrameCallbacks) {
                callback.onRendererTextureCreated(mOutputTextureId);
            }
        }
    });

    // Since we are using GLSurfaceView.RENDERMODE_WHEN_DIRTY, we must notify the SurfaceView
    // of dirtyness, so that it draws again. This is how it's done.
    mInputSurfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
        @Override
        public void onFrameAvailable(SurfaceTexture surfaceTexture) {
            getView().requestRender(); // requestRender is thread-safe.
        }
    });
}
 
Example #7
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 #8
Source File: GLTextureView.java    From PhotoMovie 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 #9
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 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 #10
Source File: PixelBuffer.java    From In77Camera with MIT License 6 votes vote down vote up
private void listConfig() {
    Log.i(TAG, "Config List {");

    for (EGLConfig config : mEGLConfigs) {
        int d, s, r, g, b, a;

        // Expand on this logic to dump other attributes
        d = getConfigAttrib(config, EGL_DEPTH_SIZE);
        s = getConfigAttrib(config, EGL_STENCIL_SIZE);
        r = getConfigAttrib(config, EGL_RED_SIZE);
        g = getConfigAttrib(config, EGL_GREEN_SIZE);
        b = getConfigAttrib(config, EGL_BLUE_SIZE);
        a = getConfigAttrib(config, EGL_ALPHA_SIZE);
        Log.i(TAG, "    <d,s,r,g,b,a> = <" + d + "," + s + "," +
                r + "," + g + "," + b + "," + a + ">");
    }

    Log.i(TAG, "}");
}
 
Example #11
Source File: ViewStars.java    From YCAudioPlayer with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
	GLES20.glGetBooleanv(GLES20.GL_SHADER_COMPILER, mShaderCompilerSupport, 0);
	if (!mShaderCompilerSupport[0]) {
		String msg = "OpenGL error; GLSL shader compiler not supported.";
		showError(msg);
		return;
	}

	try {
		String vertexSource = loadRawString(R.raw.star_vs);
		String fragmentSource = loadRawString(R.raw.star_fs);
		mShaderStar.setProgram(vertexSource, fragmentSource);
	} catch (Exception ex) {
		showError(ex.getMessage());
	}
}
 
Example #12
Source File: EglBase10.java    From UltraGpuImage with MIT License 6 votes vote down vote up
private EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
  EGLConfig[] configs = new EGLConfig[1];
  int[] numConfigs = new int[1];
  if (!egl.eglChooseConfig(eglDisplay, configAttributes, configs, configs.length, numConfigs)) {
    throw new RuntimeException(
        "eglChooseConfig failed: 0x" + Integer.toHexString(egl.eglGetError()));
  }
  if (numConfigs[0] <= 0) {
    throw new RuntimeException("Unable to find any matching EGL config");
  }
  final EGLConfig eglConfig = configs[0];
  if (eglConfig == null) {
    throw new RuntimeException("eglChooseConfig returned null");
  }
  return eglConfig;
}
 
Example #13
Source File: GLTextureView.java    From VideoRecorder 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 #14
Source File: DefaultConfigChooser.java    From CameraRecorder-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 #15
Source File: PixelBuffer.java    From SimpleVideoEditor with Apache License 2.0 6 votes vote down vote up
private void listConfig() {
    Log.i(TAG, "Config List {");

    for (EGLConfig config : mEGLConfigs) {
        int d, s, r, g, b, a;

        // Expand on this logic to dump other attributes
        d = getConfigAttrib(config, EGL_DEPTH_SIZE);
        s = getConfigAttrib(config, EGL_STENCIL_SIZE);
        r = getConfigAttrib(config, EGL_RED_SIZE);
        g = getConfigAttrib(config, EGL_GREEN_SIZE);
        b = getConfigAttrib(config, EGL_BLUE_SIZE);
        a = getConfigAttrib(config, EGL_ALPHA_SIZE);
        Log.i(TAG, "    <d,s,r,g,b,a> = <" + d + "," + s + "," +
                r + "," + g + "," + b + "," + a + ">");
    }

    Log.i(TAG, "}");
}
 
Example #16
Source File: GLThread.java    From DanDanPlayForAndroid 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 #17
Source File: EGLLogWrapper.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
public boolean eglChooseConfig(EGLDisplay display, int[] attrib_list,
                               EGLConfig[] configs, int config_size, int[] num_config) {
    begin("eglChooseConfig");
    arg("display", display);
    arg("attrib_list", attrib_list);
    arg("config_size", config_size);
    end();

    boolean result = mEgl10.eglChooseConfig(display, attrib_list, configs,
            config_size, num_config);
    arg("configs", configs);
    arg("num_config", num_config);
    returns(result);
    checkError();
    return result;
}
 
Example #18
Source File: GLTextureView.java    From VideoRecorder 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 #19
Source File: GLTextureView.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.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 #20
Source File: VideoDecoderRenderer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
  program = GlUtil.compileProgram(VERTEX_SHADER, FRAGMENT_SHADER);
  GLES20.glUseProgram(program);
  int posLocation = GLES20.glGetAttribLocation(program, "in_pos");
  GLES20.glEnableVertexAttribArray(posLocation);
  GLES20.glVertexAttribPointer(posLocation, 2, GLES20.GL_FLOAT, false, 0, TEXTURE_VERTICES);
  texLocations[0] = GLES20.glGetAttribLocation(program, "in_tc_y");
  GLES20.glEnableVertexAttribArray(texLocations[0]);
  texLocations[1] = GLES20.glGetAttribLocation(program, "in_tc_u");
  GLES20.glEnableVertexAttribArray(texLocations[1]);
  texLocations[2] = GLES20.glGetAttribLocation(program, "in_tc_v");
  GLES20.glEnableVertexAttribArray(texLocations[2]);
  GlUtil.checkGlError();
  colorMatrixLocation = GLES20.glGetUniformLocation(program, "mColorConversion");
  GlUtil.checkGlError();
  setupTextures();
  GlUtil.checkGlError();
}
 
Example #21
Source File: CameraSurfaceRenderer.java    From Tok-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    LogUtil.i(TAG, "onSurfaceCreated:");
    // This renderer required OES_EGL_image_external extension
    final String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);    // API >= 8
    if (!extensions.contains("OES_EGL_image_external")) {
        throw new RuntimeException("This system does not support OES_EGL_image_external.");
    }
    // create textur ID
    hTex = GLDrawer2D.initTex();
    // create SurfaceTexture with texture ID.
    mSTexture = new SurfaceTexture(hTex);
    mSTexture.setOnFrameAvailableListener(this);
    // clear screen with yellow color so that you can see rendering rectangle
    GLES20.glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
    final CameraGLView parent = mWeakParent.get();
    if (parent != null) {
        parent.mHasSurface = true;
    }
    // create object for preview display
    mDrawer = new GLDrawer2D();
    mDrawer.setMatrix(mMvpMatrix, 0);
}
 
Example #22
Source File: GLThread.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config, EGLContext eglContext) {
    int[] attrib_list = {
            EGL_CONTEXT_CLIENT_VERSION, contextClientVersion,
            EGL10.EGL_NONE};

    return egl.eglCreateContext(display, config, eglContext,
            contextClientVersion != 0 ? attrib_list : null);
}
 
Example #23
Source File: CameraSurfaceView.java    From Paddle-Lite-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    // Create OES texture for storing camera preview data(YUV format)
    GLES20.glGenTextures(1, camTextureId, 0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, camTextureId[0]);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    surfaceTexture = new SurfaceTexture(camTextureId[0]);
    surfaceTexture.setOnFrameAvailableListener(this);

    // Prepare vertex and texture coordinates
    int bytes = vertexCoords.length * Float.SIZE / Byte.SIZE;
    vertexCoordsBuffer = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
    textureCoordsBuffer = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
    vertexCoordsBuffer.put(vertexCoords).position(0);
    textureCoordsBuffer.put(textureCoords).position(0);

    // Create vertex and fragment shaders
    // camTextureId->fboTexureId
    progCam2FBO = Utils.createShaderProgram(vss, fssCam2FBO);
    vcCam2FBO = GLES20.glGetAttribLocation(progCam2FBO, "vPosition");
    tcCam2FBO = GLES20.glGetAttribLocation(progCam2FBO, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vcCam2FBO);
    GLES20.glEnableVertexAttribArray(tcCam2FBO);
    // fboTexureId/drawTexureId -> screen
    progTex2Screen = Utils.createShaderProgram(vss, fssTex2Screen);
    vcTex2Screen = GLES20.glGetAttribLocation(progTex2Screen, "vPosition");
    tcTex2Screen = GLES20.glGetAttribLocation(progTex2Screen, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vcTex2Screen);
    GLES20.glEnableVertexAttribArray(tcTex2Screen);
}
 
Example #24
Source File: GLTextureView.java    From PhotoMovie 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 #25
Source File: GLTextureView.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
public EGLContext createContext(EGL10 egl, EGLDisplay display, EGLConfig config) {
    int[] attrib_list = {EGL_CONTEXT_CLIENT_VERSION, mEGLContextClientVersion,
            EGL10.EGL_NONE};

    return egl.eglCreateContext(display, config, EGL10.EGL_NO_CONTEXT,
            mEGLContextClientVersion != 0 ? attrib_list : null);
}
 
Example #26
Source File: MD360Renderer.java    From Beginner-Level-Android-Studio-Apps with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config){
	// set the background clear color to black.
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	
	// use culling to remove back faces.
	GLES20.glEnable(GLES20.GL_CULL_FACE);

	// enable depth testing
	// GLES20.glEnable(GLES20.GL_DEPTH_TEST);
}
 
Example #27
Source File: TestFilterRenderer.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    mCanvas = new GLES20Canvas();
    mMovieFilter.init();
    mInputTexture = new FboTexture();
    mOutputTexture = new FboTexture();
    mBitmapTexture = new BitmapTexture(mBitmap);
}
 
Example #28
Source File: GLSurfaceMovieRenderer.java    From PhotoMovie with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    mSurfaceCreated = true;
    mNeedRelease.set(false);
    //资源起其实已经销毁了,这里只是告知其保存的纹理已经不可用,需要重建
    if (mMovieFilter != null) {
        mMovieFilter.release();
    }
    if(mCoverSegment!=null){
        mCoverSegment.release();
    }
    releaseTextures();
    prepare();
}
 
Example #29
Source File: CameraSurfaceView.java    From Paddle-Lite-Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
    // Create OES texture for storing camera preview data(YUV format)
    GLES20.glGenTextures(1, camTextureId, 0);
    GLES20.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, camTextureId[0]);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
    GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
    surfaceTexture = new SurfaceTexture(camTextureId[0]);
    surfaceTexture.setOnFrameAvailableListener(this);

    // Prepare vertex and texture coordinates
    int bytes = vertexCoords.length * Float.SIZE / Byte.SIZE;
    vertexCoordsBuffer = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
    textureCoordsBuffer = ByteBuffer.allocateDirect(bytes).order(ByteOrder.nativeOrder()).asFloatBuffer();
    vertexCoordsBuffer.put(vertexCoords).position(0);
    textureCoordsBuffer.put(textureCoords).position(0);

    // Create vertex and fragment shaders
    // camTextureId->fboTexureId
    progCam2FBO = Utils.createShaderProgram(vss, fssCam2FBO);
    vcCam2FBO = GLES20.glGetAttribLocation(progCam2FBO, "vPosition");
    tcCam2FBO = GLES20.glGetAttribLocation(progCam2FBO, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vcCam2FBO);
    GLES20.glEnableVertexAttribArray(tcCam2FBO);
    // fboTexureId/drawTexureId -> screen
    progTex2Screen = Utils.createShaderProgram(vss, fssTex2Screen);
    vcTex2Screen = GLES20.glGetAttribLocation(progTex2Screen, "vPosition");
    tcTex2Screen = GLES20.glGetAttribLocation(progTex2Screen, "vTexCoord");
    GLES20.glEnableVertexAttribArray(vcTex2Screen);
    GLES20.glEnableVertexAttribArray(tcTex2Screen);
}
 
Example #30
Source File: CameraCaptureActivity.java    From mobile-ar-sensor-logger with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 unused, EGLConfig config) {
    Log.d(TAG, "onSurfaceCreated");

    // We're starting up or coming back.  Either way we've got a new EGLContext that will
    // need to be shared with the video encoder, so figure out if a recording is already
    // in progress.
    mRecordingEnabled = mVideoEncoder.isRecording();
    if (mRecordingEnabled) {
        mRecordingStatus = RECORDING_RESUMED;
    } else {
        mRecordingStatus = RECORDING_OFF;
    }

    // Set up the texture blitter that will be used for on-screen display.  This
    // is *not* applied to the recording, because that uses a separate shader.
    mFullScreen = new FullFrameRect(
            new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));

    mTextureId = mFullScreen.createTextureObject();

    // Create a SurfaceTexture, with an external texture, in this EGL context.  We don't
    // have a Looper in this thread -- GLSurfaceView doesn't create one -- so the frame
    // available messages will arrive on the main thread.
    mSurfaceTexture = new SurfaceTexture(mTextureId);

    // Tell the UI thread to enable the camera preview.
    mCameraHandler.sendMessage(mCameraHandler.obtainMessage(
            CameraCaptureActivity.CameraHandler.MSG_SET_SURFACE_TEXTURE, mSurfaceTexture));
}