Java Code Examples for android.opengl.GLES20#glDepthFunc()

The following examples show how to use android.opengl.GLES20#glDepthFunc() . 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: CubeRenderer.java    From HoloKilo with GNU General Public License v3.0 6 votes vote down vote up
public static void setStates(boolean state) {
    if (state) {
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glEnable(GLES20.GL_DEPTH_TEST);
        GLES20.glDepthFunc(GLES20.GL_LESS);
        GLES20.glFrontFace(GLES20.GL_CCW);
        GLES20.glEnable(GLES20.GL_CULL_FACE);
        GLES20.glCullFace(GLES20.GL_FRONT);
        GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT);
    } else {
        GLES20.glDisable(GLES20.GL_DEPTH_TEST);
        GLES20.glDisable(GLES20.GL_CULL_FACE);
        GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
        GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
        GLES20.glUseProgram(0);
    }
}
 
Example 2
Source File: Renderer.java    From Tanks with MIT License 6 votes vote down vote up
@Override
public void onSurfaceChanged(GL10 gl, int w, int h)
{
  width = w;
  height = h;

  GLES20.glEnable(GLES20.GL_CULL_FACE);
  GLES20.glEnable(GLES20.GL_BLEND);
  GLES20.glEnable(GLES20.GL_DEPTH_TEST);
  GLES20.glDepthFunc(GLES20.GL_LEQUAL);
  GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
  GLES20.glViewport(0, 0, w, h);

  Shader.initShaders();

  GameContext.resources.reloadCache();
  GameContext.resources.preload();

  initialized = true;

  GameContext.content.start();
}
 
Example 3
Source File: ARSurfaceViewRenderer.java    From geoar-app with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) {
	/** Set the background clear color to "black" and transparent */
	GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	/** set up the view matrix */
	GLESCamera.resetViewMatrix();

	/** Enable depth testing */
	GLES20.glEnable(GLES20.GL_DEPTH_TEST);
	GLES20.glClearDepthf(1.0f);
	GLES20.glDepthFunc(GLES20.GL_LESS);
	GLES20.glDepthMask(true);

	/** Enable texture mapping */
	GLES20.glEnable(GLES20.GL_TEXTURE_2D);

	/** Enable blending */
	GLES20.glEnable(GLES20.GL_BLEND);
	GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
	// GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE);

	/**
	 * Backface culling - here back-facing facets are culled when facet
	 * culling is enabled
	 */
	GLES20.glEnable(GLES20.GL_CULL_FACE);
	GLES20.glCullFace(GLES20.GL_BACK); // GL_FRONT_AND_BACK for no facets

	// Resets all cached handlers because the context was lost so that they
	// are recreated later on demand.
	FeatureShader.resetShaders();
	Texture.resetTextures();
	initScene();
}
 
Example 4
Source File: CubeRenderer.java    From gdk-apidemo-sample with Apache License 2.0 5 votes vote down vote up
@Override
public void onSurfaceCreated(EGLConfig config) {
    // Set the background frame color
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClearDepthf(1.0f);
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glDepthFunc(GLES20.GL_LEQUAL);
    mCube = new Cube();
}
 
Example 5
Source File: CubeRenderer.java    From PTVGlass with MIT License 5 votes vote down vote up
@Override
public void onSurfaceCreated(EGLConfig config) {
    // Set the background frame color
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClearDepthf(1.0f);
    GLES20.glEnable(GLES20.GL_DEPTH_TEST);
    GLES20.glDepthFunc(GLES20.GL_LEQUAL);
    mCube = new Cube();
}
 
Example 6
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void depthFunc(int func) {
    GLES20.glDepthFunc(func);

}