Java Code Examples for org.andengine.opengl.util.GLState#enableScissorTest()
The following examples show how to use
org.andengine.opengl.util.GLState#enableScissorTest() .
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: SingleSceneSplitScreenEngine.java From tilt-game-android with MIT License | 5 votes |
@Override protected void onDrawScene(final GLState pGLState, final Camera pFirstCamera) { if (super.mScene != null) { final Camera secondCamera = this.getSecondCamera(); final int surfaceWidth = this.mSurfaceWidth; final int surfaceWidthHalf = surfaceWidth >> 1; final int surfaceHeight = this.mSurfaceHeight; pGLState.enableScissorTest(); /* First Screen. With first camera, on the left half of the screens width. */ { GLES20.glScissor(0, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(0, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, pFirstCamera); pFirstCamera.onDrawHUD(pGLState); } /* Second Screen. With second camera, on the right half of the screens width. */ { GLES20.glScissor(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, secondCamera); secondCamera.onDrawHUD(pGLState); } pGLState.disableScissorTest(); } }
Example 2
Source File: DoubleSceneSplitScreenEngine.java From tilt-game-android with MIT License | 5 votes |
@Override protected void onDrawScene(final GLState pGLState, final Camera pFirstCamera) { final Camera secondCamera = this.getSecondCamera(); final int surfaceWidth = this.mSurfaceWidth; final int surfaceWidthHalf = surfaceWidth >> 1; final int surfaceHeight = this.mSurfaceHeight; pGLState.enableScissorTest(); /* First Screen. With first camera, on the left half of the screens width. */ if (super.mScene != null) { GLES20.glScissor(0, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(0, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, pFirstCamera); pFirstCamera.onDrawHUD(pGLState); } /* Second Screen. With second camera, on the right half of the screens width. */ if (this.mSecondScene != null) { GLES20.glScissor(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); this.mSecondScene.onDraw(pGLState, secondCamera); secondCamera.onDrawHUD(pGLState); } pGLState.disableScissorTest(); }
Example 3
Source File: SingleSceneSplitScreenEngine.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override protected void onDrawScene(final GLState pGLState, final Camera pFirstCamera) { if(super.mScene != null) { final Camera secondCamera = this.getSecondCamera(); final int surfaceWidth = this.mSurfaceWidth; final int surfaceWidthHalf = surfaceWidth >> 1; final int surfaceHeight = this.mSurfaceHeight; pGLState.enableScissorTest(); /* First Screen. With first camera, on the left half of the screens width. */ { GLES20.glScissor(0, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(0, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, pFirstCamera); pFirstCamera.onDrawHUD(pGLState); } /* Second Screen. With second camera, on the right half of the screens width. */ { GLES20.glScissor(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, secondCamera); secondCamera.onDrawHUD(pGLState); } pGLState.disableScissorTest(); } }
Example 4
Source File: DoubleSceneSplitScreenEngine.java From 30-android-libraries-in-30-days with Apache License 2.0 | 5 votes |
@Override protected void onDrawScene(final GLState pGLState, final Camera pFirstCamera) { final Camera secondCamera = this.getSecondCamera(); final int surfaceWidth = this.mSurfaceWidth; final int surfaceWidthHalf = surfaceWidth >> 1; final int surfaceHeight = this.mSurfaceHeight; pGLState.enableScissorTest(); /* First Screen. With first camera, on the left half of the screens width. */ if(super.mScene != null) { GLES20.glScissor(0, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(0, 0, surfaceWidthHalf, surfaceHeight); super.mScene.onDraw(pGLState, pFirstCamera); pFirstCamera.onDrawHUD(pGLState); } /* Second Screen. With second camera, on the right half of the screens width. */ if(this.mSecondScene != null) { GLES20.glScissor(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); GLES20.glViewport(surfaceWidthHalf, 0, surfaceWidthHalf, surfaceHeight); this.mSecondScene.onDraw(pGLState, secondCamera); secondCamera.onDrawHUD(pGLState); } pGLState.disableScissorTest(); }
Example 5
Source File: ClipEntity.java From tilt-game-android with MIT License | 4 votes |
@Override protected void onManagedDraw(final GLState pGLState, final Camera pCamera) { if (this.mClippingEnabled) { /* Enable scissor test, while remembering previous state. */ final boolean wasScissorTestEnabled = pGLState.enableScissorTest(); final int surfaceHeight = pCamera.getSurfaceHeight(); /* In order to apply clipping, we need to determine the the axis aligned bounds in OpenGL coordinates. */ /* Determine clipping coordinates of each corner in surface coordinates. */ final float[] lowerLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, 0)); final int lowerLeftX = (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]); final int lowerLeftY = surfaceHeight - (int) Math.round(lowerLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]); final float[] upperLeftSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(0, this.mHeight)); final int upperLeftX = (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_X]); final int upperLeftY = surfaceHeight - (int) Math.round(upperLeftSurfaceCoordinates[Constants.VERTEX_INDEX_Y]); final float[] upperRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, this.mHeight)); final int upperRightX = (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]); final int upperRightY = surfaceHeight - (int) Math.round(upperRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]); final float[] lowerRightSurfaceCoordinates = pCamera.getSurfaceCoordinatesFromSceneCoordinates(this.convertLocalCoordinatesToSceneCoordinates(this.mWidth, 0)); final int lowerRightX = (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_X]); final int lowerRightY = surfaceHeight - (int) Math.round(lowerRightSurfaceCoordinates[Constants.VERTEX_INDEX_Y]); /* Determine minimum and maximum x clipping coordinates. */ final int minClippingX = MathUtils.min(lowerLeftX, upperLeftX, upperRightX, lowerRightX); final int maxClippingX = MathUtils.max(lowerLeftX, upperLeftX, upperRightX, lowerRightX); /* Determine minimum and maximum y clipping coordinates. */ final int minClippingY = MathUtils.min(lowerLeftY, upperLeftY, upperRightY, lowerRightY); final int maxClippingY = MathUtils.max(lowerLeftY, upperLeftY, upperRightY, lowerRightY); /* Determine clipping width and height. */ final int clippingWidth = maxClippingX - minClippingX; final int clippingHeight = maxClippingY - minClippingY; /* Finally apply the clipping. */ pGLState.glPushScissor(minClippingX, minClippingY, clippingWidth, clippingHeight); /* Draw children, etc... */ super.onManagedDraw(pGLState, pCamera); /* Revert scissor test to previous state. */ pGLState.glPopScissor(); pGLState.setScissorTestEnabled(wasScissorTestEnabled); } else { super.onManagedDraw(pGLState, pCamera); } }