public void draw (float deltaTime) { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT); renderer.render(); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.enableBlending(); batcher.begin(); switch (state) { case GAME_READY: presentReady(); break; case GAME_RUNNING: presentRunning(); break; case GAME_PAUSED: presentPaused(); break; case GAME_LEVEL_END: presentLevelEnd(); break; case GAME_OVER: presentGameOver(); break; } batcher.end(); }
private void renderGridLines() { GLCommon gl = Gdx.graphics.getGLCommon(); gl.glEnable(GL10.GL_BLEND); shapeRenderer.begin(ShapeType.Line); shapeRenderer.setColor(1f, 1f, 1f, 0.15f); for (int i = 0; i <= gameGrid.getGridSize().x; i++) { shapeRenderer.line(i * GRID_UNIT_SIZE, 0, i * GRID_UNIT_SIZE, gameGrid.getGridSize().y * GRID_UNIT_SIZE); } for (int i = 0; i <= gameGrid.getGridSize().y; i++) { shapeRenderer.line(0, i * GRID_UNIT_SIZE, gameGrid.getGridSize().x * GRID_UNIT_SIZE, i * GRID_UNIT_SIZE); } shapeRenderer.end(); gl.glDisable(GL10.GL_BLEND); }
public void draw (float deltaTime) { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(helpRegion, 0, 0, 320, 480); batcher.end(); batcher.enableBlending(); batcher.begin(); batcher.draw(Assets.arrow, 320, 0, -64, 64); batcher.end(); gl.glDisable(GL10.GL_BLEND); }
public void draw (float deltaTime) { GLCommon gl = Gdx.gl; gl.glClearColor(1, 0, 0, 1); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480); batcher.end(); batcher.enableBlending(); batcher.begin(); batcher.draw(Assets.logo, 160 - 274 / 2, 480 - 10 - 142, 274, 142); batcher.draw(Assets.mainMenu, 10, 200 - 110 / 2, 300, 110); batcher.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64); batcher.end(); }
public void draw (float deltaTime) { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.disableBlending(); batcher.begin(); batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480); batcher.end(); batcher.enableBlending(); batcher.begin(); batcher.draw(Assets.highScoresRegion, 10, 360 - 16, 300, 33); float y = 230; for (int i = 4; i >= 0; i--) { Assets.font.draw(batcher, highScores[i], xOffset, y); y += Assets.font.getLineHeight(); } batcher.draw(Assets.arrow, 0, 0, 64, 64); batcher.end(); }
public void draw(ShapeRenderer shapeRender) { if (mTable != null) { Cell c = getSelectedCell(x, y); if (c != null) { Actor selected = (Actor) (c.getWidget()); if (selected != null) { shapeRender.setColor(Blob.colors(mPlayer.id%Blob.COLORS.length)); GLCommon gl = Gdx.graphics.getGLCommon(); shapeRender.begin(ShapeType.Line); shapeRender.box(mTable.getX()+selected.getX(), mTable.getY()+selected.getY(), 0, selected.getWidth(), selected.getHeight(), 0); gl.glLineWidth(3); shapeRender.end(); gl.glLineWidth(1); } } } }
public void enableBlending() { renderMesh(); this.blendingDisabled = false; if (this.drawing) { GLCommon localGLCommon = Gdx.gl; localGLCommon.glEnable(3042); localGLCommon.glBlendFunc(this.blendSrcFunc, this.blendDstFunc); } }
public void end() { if (!this.drawing) throw new IllegalStateException("SpriteBatch.begin must be called before end."); if (this.idx > 0) renderMesh(); this.lastTexture = null; this.idx = 0; this.drawing = false; this.indexBuffer.unbind(); GLCommon localGLCommon = Gdx.gl; localGLCommon.glDepthMask(true); if (isBlendingEnabled()) localGLCommon.glDisable(3042); if (Gdx.graphics.isGL20Available()) { if (this.customShader != null) { this.customShader.end(); return; } this.shader.end(); return; } localGLCommon.glDisable(3553); }
public void end() { if (!this.drawing) throw new IllegalStateException("PolygonSpriteBatch.begin must be called before end."); if (this.idx > 0) renderMesh(); this.lastTexture = null; this.idx = 0; this.drawing = false; GLCommon localGLCommon = Gdx.gl; localGLCommon.glDepthMask(true); if (isBlendingEnabled()) localGLCommon.glDisable(3042); if (Gdx.graphics.isGL20Available()) { if (this.customShader != null) { this.customShader.end(); return; } this.shader.end(); return; } localGLCommon.glDisable(3553); }
@Override public void renderGL2(float gameTime) { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); SpriteBatch batch = getSpriteBatch(); viewMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.setProjectionMatrix(viewMatrix); batch.begin(); batch.disableBlending(); batch.setColor(Color.WHITE); //begin render background renderBackground(gameTime); batch.enableBlending(); batch.end(); gl.glEnable(GL10.GL_DEPTH_TEST); gl.glEnable(GL10.GL_CULL_FACE); camera.update(); for(IDrawable3D obj : collection) if(obj.isVisible()) { obj.renderGL2(gameTime); } gl.glDisable(GL10.GL_CULL_FACE); gl.glDisable(GL10.GL_DEPTH_TEST); batch.setProjectionMatrix(viewMatrix); batch.begin(); //begin render foreground renderForeground(gameTime); //batch.enableBlending(); //batch.setBlendFunction(GL10.GL_ONE, GL10.GL_ONE_MINUS_SRC_ALPHA); batch.end(); }
private static void generateMipMapCPU(Pixmap paramPixmap, int paramInt1, int paramInt2, boolean paramBoolean) { Gdx.gl.glTexImage2D(3553, 0, paramPixmap.getGLInternalFormat(), paramPixmap.getWidth(), paramPixmap.getHeight(), 0, paramPixmap.getGLFormat(), paramPixmap.getGLType(), paramPixmap.getPixels()); if ((Gdx.gl20 == null) && (paramInt1 != paramInt2)) throw new GdxRuntimeException("texture width and height must be square when using mipmapping."); int i = paramPixmap.getWidth() / 2; int j = paramPixmap.getHeight() / 2; Pixmap.Blending localBlending = Pixmap.getBlending(); Pixmap.setBlending(Pixmap.Blending.None); int k = 1; Pixmap localPixmap; for (Object localObject = paramPixmap; (i > 0) && (j > 0); localObject = localPixmap) { localPixmap = new Pixmap(i, j, ((Pixmap)localObject).getFormat()); localPixmap.drawPixmap((Pixmap)localObject, 0, 0, ((Pixmap)localObject).getWidth(), ((Pixmap)localObject).getHeight(), 0, 0, i, j); if ((k > 1) || (paramBoolean)) ((Pixmap)localObject).dispose(); GLCommon localGLCommon = Gdx.gl; int m = localPixmap.getGLInternalFormat(); int n = localPixmap.getWidth(); int i1 = localPixmap.getHeight(); int i2 = localPixmap.getGLFormat(); int i3 = localPixmap.getGLType(); ByteBuffer localByteBuffer = localPixmap.getPixels(); localGLCommon.glTexImage2D(3553, k, m, n, i1, 0, i2, i3, localByteBuffer); i = localPixmap.getWidth() / 2; j = localPixmap.getHeight() / 2; k++; } Pixmap.setBlending(localBlending); }
/** * Constructor */ public LevelView() { int w = Gdx.graphics.getWidth(); int h = Gdx.graphics.getHeight(); // Fullscreen toggle parameters mFullScreenEnabled = false; // Set virtual scale (it never changes) mVScale = vHEIGHT / MIN_HEIGHT; mOldWidth = w; mOldHeight = h; // Create Camera and SpriteBatch mCamera = new OrthographicCamera(); mOldCamera = new OrthographicCamera(); mBatch = new SpriteBatch(); mShapeRenderer = new ShapeRenderer(); mDebug = new Box2DDebugRenderer(); if (mUseLights) { mRayHandler = new RayHandler(null, w / 8, h / 8); } // Set width and height mWidth = MIN_WIDTH; mHeight = MIN_HEIGHT; mClip = new Rectangle(); GLCommon gl10 = Gdx.graphics.getGLCommon(); gl10.glEnable(GL10.GL_LINE_SMOOTH); gl10.glHint(GL10.GL_LINE_SMOOTH_HINT, GL10.GL_NICEST); // Call onResize, so scale information is available in Game.create() onResize(w, h); mOldScale = mScale; String vertexShader = "attribute vec4 a_position;\n" + "attribute vec4 a_color;\n" + "uniform mat4 u_worldView;\n" + "varying vec4 v_color; \n" + "void main(){\n" + "v_color = a_color;\n" + "gl_Position = u_worldView * a_position;\n" + "}\n"; String fragmentShader = "#ifdef GL_ES \n" + "precision mediump float; \n" + "#endif \n" + "varying vec4 v_color; \n" + "void main() \n" + "{ \n" + " gl_FragColor = v_color; \n" + "} \n"; if (Gdx.graphics.isGL20Available()) { mDefaultShaderProgram = new ShaderProgram(vertexShader, fragmentShader); if (!mDefaultShaderProgram.isCompiled()) throw new IllegalStateException(mDefaultShaderProgram.getLog()); } }
@Override public GLCommon getGLCommon() { throw new ServerGraphicsException(); }
public void draw () { GLCommon gl = Gdx.gl; gl.glClear(GL10.GL_COLOR_BUFFER_BIT); renderer.render(); guiCam.update(); batcher.setProjectionMatrix(guiCam.combined); batcher.enableBlending(); batcher.begin(); switch (state) { case GAME_READY: presentReady(); break; case GAME_RUNNING: presentRunning(); break; case GAME_PAUSED: presentPaused(); break; case GAME_LEVEL_END: presentLevelEnd(); break; case GAME_OVER: presentGameOver(); break; } batcher.end(); }
@Override public void render () { GLCommon gl = Gdx.gl; long startPhysics = TimeUtils.nanoTime(); field.tick((long)(Gdx.graphics.getDeltaTime() * 3000), 4); physicsMean.addValue((TimeUtils.nanoTime() - startPhysics) / 1000000000.0f); gl.glClear(GL10.GL_COLOR_BUFFER_BIT); cam.viewportWidth = field.getWidth(); cam.viewportHeight = field.getHeight(); cam.position.set(field.getWidth() / 2, field.getHeight() / 2, 0); cam.update(); renderer.setProjectionMatrix(cam.combined); long startRender = TimeUtils.nanoTime(); renderer.begin(); int len = field.getFieldElements().size(); for (int i = 0; i < len; i++) { FieldElement element = field.getFieldElements().get(i); element.draw(renderer); } renderer.end(); field.flock.removeBalls(); renderer.begin(); field.flock.run(renderer); field.player.update(Gdx.graphics.getDeltaTime()); field.player.render(); renderer.end(); renderMean.addValue((TimeUtils.nanoTime() - startRender) / 1000000000.0f); score = String.valueOf(field.player.score); spriteBatch.begin(); font.draw(spriteBatch, scoreText, 0, Gdx.graphics.getHeight()); font.draw(spriteBatch, score, 0 + font.getBounds(scoreText).width + 5, Gdx.graphics.getHeight()); spriteBatch.end(); if (TimeUtils.nanoTime() - startTime > 1000000000) { Gdx.app.log("Bouncy", "fps: " + Gdx.graphics.getFramesPerSecond() + ", physics: " + physicsMean.getMean() * 1000 + ", rendering: " + renderMean.getMean() * 1000); startTime = TimeUtils.nanoTime(); } }
@Override public GLCommon getGLCommon() { // TODO Auto-generated method stub return null; }
public final GLCommon getGLCommon() { return Gdx.gl; }
public abstract GLCommon getGLCommon();