List of usage examples for com.badlogic.gdx.graphics GL20 GL_DEPTH_BUFFER_BIT
int GL_DEPTH_BUFFER_BIT
To view the source code for com.badlogic.gdx.graphics GL20 GL_DEPTH_BUFFER_BIT.
Click Source Link
From source file:br.com.raphaelbruno.game.zombieinvaders.vr.model.ScreenBase.java
License:Apache License
public void onDrawEye(Eye paramEye) { Gdx.gl.glClearColor(BACKGROUND_COLOR.r, BACKGROUND_COLOR.g, BACKGROUND_COLOR.b, BACKGROUND_COLOR.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); camera.setEyeViewAdjustMatrix(new Matrix4(paramEye.getEyeView())); float[] perspective = paramEye.getPerspective(Z_NEAR, Z_FAR); camera.setEyeProjection(new Matrix4(perspective)); camera.update();//from ww w.j a v a2s . co m game.modelBatch.begin(camera); game.modelBatch.render(instances, environment); game.modelBatch.end(); game.spriteBatch.begin(); if (showTarget) game.spriteBatch.draw(target, (Gdx.graphics.getWidth() - target.getWidth()) / 2, (Gdx.graphics.getHeight() - target.getHeight()) / 2); if (visibleUI) { score.draw(game.spriteBatch, HudUtils.formattedScore(scoreValue), (Gdx.graphics.getWidth() - (score.getSpaceWidth() * HudUtils.formattedScore(scoreValue).length())) / 2, Gdx.graphics.getHeight() - MARGIN_SCREEN); if (life.size() > 0) { int size = (life.size() * life.get(0).getWidth()) + ((life.size() - 1) * MARGIN_HEART); float center = (Gdx.graphics.getWidth() - size) / 2; for (int i = 0; i < life.size(); i++) { Texture item = life.get(i); game.spriteBatch.draw(item, center + ((item.getWidth() + MARGIN_HEART) * i), MARGIN_SCREEN); } } } renderSprite(Gdx.graphics.getDeltaTime()); game.spriteBatch.end(); if (endFade.isPlaying) endFade.shows(Gdx.graphics.getDeltaTime()); if (laser.isPlaying) laser.shows(Gdx.graphics.getDeltaTime()); }
From source file:CB_UI_Base.graphics.Images.VectorDrawable.java
License:Open Source License
private void drawFbo(Batch batch, float x, float y, final float width, final float height, final Matrix4 oriMatrix, Matrix4 thisDrawMatrix) { final int fboScalerWidth = (int) (this.DEFAULT_WIDTH * FBO_SCALER); final int fboScalerHeight = (int) (this.DEFAULT_HEIGHT * FBO_SCALER); if (!RunOnGlSetted && m_fboEnabled && m_fboRegion == null) { RunOnGlSetted = true;/*from w w w . j a v a 2 s . c om*/ GL.that.RunOnGL(new IRenderFBO() { @Override public void run() { synchronized (isDisposed) { if (isDisposed.get()) { return; } try { Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST); long start = System.currentTimeMillis(); m_fbo = new FrameBuffer(Format.RGBA8888, fboScalerWidth, fboScalerHeight, false); m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture()); m_fboRegion.flip(flipX, flipY); m_fbo.begin(); // clear screen Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); GL.batch.setColor(new Color(Color.WHITE)); GL.batch.begin(); Matrix4 matrix = new Matrix4().setToOrtho2D(0, 0, width, height); matrix.scale(FBO_SCALER, FBO_SCALER, 1); GL.batch.setProjectionMatrix(matrix); // draw Background GL.batch.disableBlending(); background.draw(GL.batch, 0, 0, fboScalerWidth, fboScalerHeight); GL.batch.enableBlending(); int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (count++ > 2500) { GL.batch.flush(); count = 0; } matrix = new Matrix4().setToOrtho2D(0, 0, width, height); if (drw.matrix != null) { matrix.mul(drw.matrix.getMatrix4()); } GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } if (m_fbo != null) { GL.batch.end(); m_fbo.end(); m_fboEnabled = false; } FBOisDrawed = true; FBO_DrawingTime = System.currentTimeMillis() - start; Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); GL.batch.setProjectionMatrix(oriMatrix); m_fboEnabled = false; } catch (Exception e) { e.printStackTrace(); } } } }); } if (m_fboRegion != null) { // TODO clear and release the drawables that drawed on m_fboRegion // if first drawing of m_fboRegion batch.draw(m_fboRegion, x, y, width, height); } else { int count = 0; for (int i = 0, n = drawableList.size(); i < n; i++) { MatrixDrawable drw = drawableList.get(i); if (!drw.reaelDraw) continue; if (count++ > 2500) { GL.batch.flush(); count = 0; } Matrix4 matrix = thisDrawMatrix.cpy(); if (drw.matrix != null) matrix.mul(drw.matrix.getMatrix4()); GL.batch.setProjectionMatrix(matrix); drw.drawable.draw(GL.batch, 0, 0, width, height, 0); } } }
From source file:com.andgate.ikou.view.GameScreen.java
License:Open Source License
private void renderSetup() { Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); }
From source file:com.andgate.ikou.view.LevelSelectScreen.java
License:Open Source License
@Override public void render(float delta) { Color bg = Constants.BACKGROUND_COLOR; Gdx.gl.glClearColor(bg.r, bg.g, bg.b, bg.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); levelPreview.render(delta);//from w w w. ja v a 2 s . c o m previewContainer.setBackground(levelPreview.getDrawable()); stage.draw(); Gdx.gl.glFinish(); if (Gdx.input.isKeyPressed(Input.Keys.BACK)) { gotoMainMenu(); } stage.act(); }
From source file:com.badlogic.gdx.tests.dragome.examples.GearsDemo.java
@Override public void render() { Gdx.gl.glClearColor(0, 0, 0, 1);//w w w . j a v a2 s .c om Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); cam.update(); if (modelBatch != null) { angle += 1.0f; gear1.transform.setToTranslation(-3.0f, -2.0f, 0.0f); gear2.transform.setToTranslation(3.1f, -2.0f, 0.0f); gear3.transform.setToTranslation(-3.1f, 4.2f, 0.0f); gear1.transform.rotate(Vector3.Z, angle); gear2.transform.rotate(Vector3.Z, -2.0f * angle - 9.0f); gear3.transform.rotate(Vector3.Z, -2.0f * angle - 25.0f); final float delta = Gdx.graphics.getDeltaTime(); sl.position.sub(transformedCenter); sl.position.rotate(Vector3.X, delta * 50f); sl.position.rotate(Vector3.Y, delta * 13f); sl.position.rotate(Vector3.Z, delta * 3f); sl.position.add(transformedCenter.set(center).mul(transform)); modelBatch.begin(cam); modelBatch.render(gear1, environment); modelBatch.render(gear2, environment); modelBatch.render(gear3, environment); pLight.worldTransform.setTranslation(sl.position); modelBatch.render(pLight); modelBatch.end(); float timeSec = TimeUtils.millis() - time; if (timeSec > 1000) { time = TimeUtils.millis(); fps = Gdx.graphics.getFramesPerSecond(); } batch.begin(); font.draw(batch, "FPS: " + fps, 15, Gdx.graphics.getHeight() - 15); batch.end(); } }
From source file:com.badlogic.gdx.tests.g3d.shadows.system.classical.ClassicalShadowSystem.java
License:Apache License
protected void beginPass2() { Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); firstCallPass2 = true; nbCall = 0; }
From source file:com.badlogic.gdx.tests.g3d.shadows.system.FirstPassBaseShadowSystem.java
License:Apache License
protected void beginPass1() { allocator.begin(); Gdx.gl.glClearColor(1, 1, 1, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST); }
From source file:com.badlogic.gdx.tests.ViewportTest3.java
License:Apache License
public void render() { Gdx.gl.glClearColor(0, 0, 0, 1);/*from w ww.j a v a 2s . c o m*/ Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); modelBatch.begin(camera); modelBatch.render(boxInstance, environment); modelBatch.end(); }
From source file:com.badlogic.invaders.Renderer.java
License:Apache License
public void render(Simulation simulation, float delta) { // We explicitly require GL10, otherwise we could've used the GLCommon // interface via Gdx.gl GL20 gl = Gdx.gl;/*ww w .j ava 2 s .c o m*/ gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); renderBackground(); gl.glEnable(GL20.GL_DEPTH_TEST); gl.glEnable(GL20.GL_CULL_FACE); setProjectionAndCamera(simulation.ship); modelBatch.begin(camera); modelBatch.render(simulation.explosions); if (!simulation.ship.isExploding) modelBatch.render(simulation.ship, lights); modelBatch.render(simulation.invaders, lights); modelBatch.render(simulation.blocks); modelBatch.render(simulation.shots); modelBatch.end(); gl.glDisable(GL20.GL_CULL_FACE); gl.glDisable(GL20.GL_DEPTH_TEST); spriteBatch.setProjectionMatrix(viewMatrix); spriteBatch.begin(); if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) { status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: " + simulation.score; lastLives = simulation.ship.lives; lastScore = simulation.score; lastWave = simulation.wave; } spriteBatch.enableBlending(); font.draw(spriteBatch, status, 0, 320); spriteBatch.end(); invaderAngle += delta * 90; if (invaderAngle > 360) invaderAngle -= 360; }
From source file:com.barconr.games.marblegame.Maze3Drenderer.java
License:Apache License
public void render() { Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl20.glEnable(Gdx.gl20.GL_POLYGON_OFFSET_FILL); Gdx.gl20.glPolygonOffset(0.1f, 0.1f); modelBatch.begin(cam);//from w w w .j av a 2s . c o m for (ModelInstance mi : instances) { modelBatch.render(mi, environment); } moveCamera(); modelBatch.end(); }