Java Code Examples for org.andengine.opengl.util.GLState#popModelViewGLMatrix()
The following examples show how to use
org.andengine.opengl.util.GLState#popModelViewGLMatrix() .
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: ParallaxBackground.java From tilt-game-android with MIT License | 6 votes |
public void onDraw(final GLState pGLState, final Camera pCamera, final float pParallaxValue) { pGLState.pushModelViewGLMatrix(); { final float cameraWidth = pCamera.getWidth(); final float entityWidthScaled = this.mEntity.getWidth() * this.mEntity.getScaleX(); float baseOffset = (pParallaxValue * this.mParallaxFactor) % entityWidthScaled; while (baseOffset > 0) { baseOffset -= entityWidthScaled; } pGLState.translateModelViewGLMatrixf(baseOffset, 0, 0); float currentMaxX = baseOffset; do { this.mEntity.onDraw(pGLState, pCamera); pGLState.translateModelViewGLMatrixf(entityWidthScaled, 0, 0); currentMaxX += entityWidthScaled; } while (currentMaxX < cameraWidth); } pGLState.popModelViewGLMatrix(); }
Example 2
Source File: TextureWarmUpVertexBufferObject.java From tilt-game-android with MIT License | 6 votes |
public void warmup(final GLState pGLState, final ITexture pTexture) { pTexture.bind(pGLState); this.bind(pGLState, PositionTextureCoordinatesShaderProgram.getInstance()); pGLState.pushModelViewGLMatrix(); { /* Far far away and really small. */ pGLState.loadModelViewGLMatrixIdentity(); pGLState.translateModelViewGLMatrixf(1000000, 1000000, 0); pGLState.scaleModelViewGLMatrixf(0.0001f, 0.0001f, 0); this.draw(GLES20.GL_TRIANGLES, TextureWarmUpVertexBufferObject.VERTICES_PER_VERTEXBUFFEROBJECT_SIZE); } pGLState.popModelViewGLMatrix(); this.unbind(pGLState, PositionTextureCoordinatesShaderProgram.getInstance()); }
Example 3
Source File: RenderTexture.java From tilt-game-android with MIT License | 6 votes |
/** * @param pGLState * @param pFlush {@link GLState#flush()} has lower preference than pFinish. * @param pFinish {@link GLState#finish()} had higher preference than pFlush. * * @see {@link #begin(GLState)}, * {@link #begin(GLState, boolean, boolean)}, * {@link #begin(GLState, Color)}, * {@link #begin(GLState, float, float, float, float)}, * {@link #begin(GLState, boolean, boolean, Color)}. * {@link #begin(GLState, boolean, boolean, float, float, float, float)}. */ public void end(final GLState pGLState, final boolean pFlush, final boolean pFinish) { if (pFinish) { this.finish(pGLState); } else if (pFlush) { this.flush(pGLState); } pGLState.popModelViewGLMatrix(); this.restorePreviousFramebufferObjectID(pGLState); pGLState.popProjectionGLMatrix(); this.resotorePreviousViewport(); }
Example 4
Source File: ParallaxBackground.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public void onDraw(final GLState pGLState, final Camera pCamera, final float pParallaxValue) { pGLState.pushModelViewGLMatrix(); { final float cameraWidth = pCamera.getWidth(); final float shapeWidthScaled = this.mAreaShape.getWidthScaled(); float baseOffset = (pParallaxValue * this.mParallaxFactor) % shapeWidthScaled; while(baseOffset > 0) { baseOffset -= shapeWidthScaled; } pGLState.translateModelViewGLMatrixf(baseOffset, 0, 0); float currentMaxX = baseOffset; do { this.mAreaShape.onDraw(pGLState, pCamera); pGLState.translateModelViewGLMatrixf(shapeWidthScaled, 0, 0); currentMaxX += shapeWidthScaled; } while(currentMaxX < cameraWidth); } pGLState.popModelViewGLMatrix(); }
Example 5
Source File: TextureWarmUpVertexBufferObject.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
public void warmup(final GLState pGLState, final ITexture pTexture) { pTexture.bind(pGLState); this.bind(pGLState, PositionTextureCoordinatesShaderProgram.getInstance()); pGLState.pushModelViewGLMatrix(); { /* Far far away and really small. */ pGLState.loadModelViewGLMatrixIdentity(); pGLState.translateModelViewGLMatrixf(1000000, 1000000, 0); pGLState.scaleModelViewGLMatrixf(0.0001f, 0.0001f, 0); this.draw(GLES20.GL_TRIANGLES, VERTICES_PER_VERTEXBUFFEROBJECT_SIZE); } pGLState.popModelViewGLMatrix(); this.unbind(pGLState, PositionTextureCoordinatesShaderProgram.getInstance()); }
Example 6
Source File: RenderTexture.java From 30-android-libraries-in-30-days with Apache License 2.0 | 6 votes |
/** * @param pGLState * @param pFlush {@link GLState#flush()} has lower preference than pFinish. * @param pFinish {@link GLState#finish()} had higher preference than pFlush. * * @see {@link RenderTexture#begin(GLState)}, * {@link RenderTexture#begin(GLState, boolean, boolean)}, * {@link RenderTexture#begin(GLState, Color)}, * {@link RenderTexture#begin(GLState, float, float, float, float)}, * {@link RenderTexture#begin(GLState, boolean, boolean, Color)}. * {@link RenderTexture#begin(GLState, boolean, boolean, float, float, float, float)}. */ public void end(final GLState pGLState, final boolean pFlush, final boolean pFinish) { if(pFinish) { this.finish(pGLState); } else if(pFlush) { this.flush(pGLState); } pGLState.popModelViewGLMatrix(); this.restorePreviousFramebufferObjectID(pGLState); pGLState.popProjectionGLMatrix(); this.resotorePreviousViewport(); }
Example 7
Source File: Entity.java From tilt-game-android with MIT License | 4 votes |
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) { pGLState.pushModelViewGLMatrix(); { this.onApplyTransformations(pGLState); final SmartList<IEntity> children = this.mChildren; if ((children == null) || !this.mChildrenVisible) { /* Draw only self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); } else { if (this.mChildrenSortPending) { ZIndexSorter.getInstance().sort(this.mChildren); this.mChildrenSortPending = false; } final int childCount = children.size(); int i = 0; { /* Draw children behind this Entity. */ for (; i < childCount; i++) { final IEntity child = children.get(i); if (child.getZIndex() < 0) { child.onDraw(pGLState, pCamera); } else { break; } } } /* Draw self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); { /* Draw children in front of this Entity. */ for (; i < childCount; i++) { children.get(i).onDraw(pGLState, pCamera); } } } } pGLState.popModelViewGLMatrix(); }
Example 8
Source File: Entity.java From 30-android-libraries-in-30-days with Apache License 2.0 | 4 votes |
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) { pGLState.pushModelViewGLMatrix(); { this.onApplyTransformations(pGLState); final SmartList<IEntity> children = this.mChildren; if((children == null) || !this.mChildrenVisible) { /* Draw only self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); } else { if(this.mChildrenSortPending) { ZIndexSorter.getInstance().sort(this.mChildren); this.mChildrenSortPending = false; } final int childCount = children.size(); int i = 0; { /* Draw children behind this Entity. */ for(; i < childCount; i++) { final IEntity child = children.get(i); if(child.getZIndex() < 0) { child.onDraw(pGLState, pCamera); } else { break; } } } /* Draw self. */ this.preDraw(pGLState, pCamera); this.draw(pGLState, pCamera); this.postDraw(pGLState, pCamera); { /* Draw children in front of this Entity. */ for(; i < childCount; i++) { children.get(i).onDraw(pGLState, pCamera); } } } } pGLState.popModelViewGLMatrix(); }