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

The following examples show how to use android.opengl.GLES20#glCullFace() . 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: PanoRender.java    From Pano360 with MIT License 6 votes vote down vote up
@Override
public void onDrawFrame(GL10 glUnused) {
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    GLES20.glClear( GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    GLES20.glFrontFace(GLES20.GL_CW);
    GLES20.glCullFace(GLES20.GL_BACK);
    GLES20.glEnable(GLES20.GL_CULL_FACE);

    if(!imageMode){
        panoMediaPlayerWrapper.doTextureUpdate(((OESFilter)firstPassFilter).getSTMatrix());
    }
    filterGroup.drawToFBO(0,fbo);
    if(fbo!=null)
        screenDrawer.onDrawFrame(fbo.getFrameBufferTextureId());

    if (saveImg){
        BitmapUtils.sendImage(surfaceWidth, surfaceHeight,statusHelper.getContext());
        saveImg=false;
    }

    GLES20.glDisable(GLES20.GL_CULL_FACE);
    //GLES20.glFinish();
}
 
Example 2
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 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: EPlayerRenderer.java    From SimpleVideoEdit with Apache License 2.0 4 votes vote down vote up
/**
 * onSurfaceCreated(): The system calls this method once, when creating the GLSurfaceView. Use this method to perform
 * actions that need to happen only once, such as setting OpenGL environment parameters or initializing OpenGL graphic objects.
 */
@Override
public void onSurfaceCreated(final EGLConfig config) {
    // Set the background frame color, these params are red, green, blue and alpha
    GLES20.glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    // enable face culling feature
    GLES20.glEnable(GL_CULL_FACE);
    // specify which faces to not draw
    GLES20.glCullFace(GL_FRONT);

    final int[] args = new int[1];

    GLES20.glGenTextures(args.length, args, 0);
    texName = args[0];


    previewTexture = new SurfaceTexture(texName);
    previewTexture.setOnFrameAvailableListener(this);


    GLES20.glBindTexture(GlPreviewFilter.GL_TEXTURE_EXTERNAL_OES, texName);
    // GL_TEXTURE_EXTERNAL_OES
    EglUtil.setupSampler(GlPreviewFilter.GL_TEXTURE_EXTERNAL_OES, GL_LINEAR, GL_NEAREST);
    GLES20.glBindTexture(GL_TEXTURE_2D, 0);

    filterFramebufferObject = new EFramebufferObject();
    // GL_TEXTURE_EXTERNAL_OES
    previewFilter = new GlPreviewFilter(GlPreviewFilter.GL_TEXTURE_EXTERNAL_OES);
    //initialize shapes
    previewFilter.setup();

    Surface surface = new Surface(previewTexture);
    this.simplePlayer.setSurface(surface);

    /*
    * Projection and camera view in OpenGL ES 2.0: Second Step:
    * First Step is in GlPreviewFilter.java where we declare the vertex shader with uMVPMatrix
    * Create a camera view matrix
    * */
    Matrix.setLookAtM(VMatrix, 0,
            0.0f, 0.0f, 5.0f,
            0.0f, 0.0f, 0.0f,
            0.0f, 1.0f, 0.0f
    );

    synchronized (this) {
        updateSurface = false;
    }

    if (glFilter != null) {
        isNewFilter = true;
    }

    GLES20.glGetIntegerv(GL_MAX_TEXTURE_SIZE, args, 0);

}
 
Example 5
Source File: ImageTargetRenderer.java    From cordova-plugin-vuforia with MIT License 4 votes vote down vote up
private void renderFrame()
{
    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    State state = mRenderer.begin();
    mRenderer.drawVideoBackground();

    GLES20.glEnable(GLES20.GL_DEPTH_TEST);

    // handle face culling, we need to detect if we are using reflection
    // to determine the direction of the culling
    GLES20.glEnable(GLES20.GL_CULL_FACE);
    GLES20.glCullFace(GLES20.GL_BACK);
    if (Renderer.getInstance().getVideoBackgroundConfig().getReflection() == VIDEO_BACKGROUND_REFLECTION.VIDEO_BACKGROUND_REFLECTION_ON)
        GLES20.glFrontFace(GLES20.GL_CW); // Front camera
    else
        GLES20.glFrontFace(GLES20.GL_CCW); // Back camera

    // did we find any trackables this frame?
    for (int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
    {
        TrackableResult result = state.getTrackableResult(tIdx);
        Trackable trackable = result.getTrackable();

        String obj_name = trackable.getName();

        Log.d(LOGTAG, "MRAY :: Found: " + obj_name);

        /**
         * Our targets array has been flattened to a string so will equal something like: ["one", "two"]
         * So, to stop weak matches such as 'two' within ["onetwothree", "two"] we wrap the term in
         * speech marks such as '"two"'
         **/
        Boolean looking_for = mTargets.toLowerCase().contains("\"" + obj_name.toLowerCase() + "\"");

        if (looking_for)
        {
            mActivity.imageFound(obj_name);
        }
    }

    GLES20.glDisable(GLES20.GL_DEPTH_TEST);

    mRenderer.end();
}
 
Example 6
Source File: AndroidGL.java    From trekarta with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void cullFace(int mode) {
    GLES20.glCullFace(mode);

}