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:de.caffeineaddicted.sgl.ui.screens.SGLRootScreen.java
License:BEER-WARE LICENSE
/** * Renders all currently active screens. Lower index gets drawn to the background. *//* w ww . j a v a 2 s. co m*/ public void render(float delta, boolean forceRender) { Gdx.gl.glClearColor(.0f, .0f, .0f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); if (paused && !renderWhilePasued && !forceRender) { return; } for (ZINDEX zindex : ZINDEX.asSortedArray()) { renderIfNotNull(zindex, delta); } }
From source file:de.longri.cachebox3.CacheboxMain.java
License:Open Source License
@Override public void render() { {// calculate Memory Usage long maxMemory = runtime.maxMemory(); long allocatedMemory = runtime.totalMemory(); long freeMemory = runtime.freeMemory(); StringBuilder memoryStringBuilder = new StringBuilder(); memoryStringBuilder.append("f: " + format.format(freeMemory / 1048576)); memoryStringBuilder.append(" a: " + format.format(allocatedMemory / 1048576)); memoryStringBuilder.append(" m: " + format.format(maxMemory / 1048576)); memoryStringBuilder/*from w w w . j av a 2 s . c o m*/ .append(" tf: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1048576)); memoryUsage = memoryStringBuilder.toString(); } CB.stateTime += Gdx.graphics.getDeltaTime(); if (drawMap && mMapRenderer != null) { GLState.enableVertexArrays(-1, -1); // set map position and size gl.viewport(mapDrawX, mapDrawY, mapDrawWidth, mapDrawHeight); gl.frontFace(GL.CW); try { mMapRenderer.onDrawFrame(); } catch (Exception e) { e.printStackTrace(); } //release Buffers from map renderer GLState.bindVertexBuffer(0); GLState.bindElementBuffer(0); } else { // if MapRenderer not drawn, we must clear before draw stage Gdx.gl.glClearColor(CB.backgroundColor.r, CB.backgroundColor.g, CB.backgroundColor.b, CB.backgroundColor.a); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0)); } gl.flush(); gl.viewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); // MapRender sets the FrontFace to GL.CW, so we revert to GL.CCW gl.frontFace(GL.CCW); StageManager.draw(); if (CB.isTestVersion()) { float FpsInfoSize = CB.getScaledFloat(4f); if (FpsInfoSprite != null) { batch = StageManager.getBatch(); batch.begin(); Color lastColor = batch.getColor(); batch.setColor(1.0f, 0.0f, 0.0f, 1.0f); batch.draw(FpsInfoSprite, FpsInfoPos, 2, FpsInfoSize, FpsInfoSize); batch.setColor(lastColor); batch.end(); } else { Sprite sprite = CB.getSprite("color"); if (sprite != null) { FpsInfoSprite = new Sprite(sprite); FpsInfoSprite.setColor(1.0f, 0.0f, 0.0f, 1.0f); FpsInfoSprite.setSize(FpsInfoSize, FpsInfoSize); } } FpsInfoPos += FpsInfoSize; if (FpsInfoPos > 60 * FpsInfoSize) { FpsInfoPos = 0; } } }
From source file:dk.sidereal.lumm.architecture.LummSceneLayer.java
License:Apache License
/** Method that updates all objects in {@link #objects}. */ final void onRenderInternal() { try {/*from w ww .j a v a2s.c om*/ if (objects == null || scene == null) return; // batch's scene is not the same as the current scene. if (Lumm.getScene() != null && !this.scene.equals(Lumm.getScene())) { scene = null; return; } if (objects.size() == 0) return; if (sort) { try { Collections.sort(objects, objectComparator); } catch (Exception e) { Lumm.debug.logError("Unable to sort list of objects in the batch", e); e.printStackTrace(); } } updateRenderingArea(); if (shaderUniformValuesEvent != null && shaderType.equals(ShaderType.Update) && shaderProgram.isCompiled()) { shaderProgram.begin(); shaderUniformValuesEvent.run(shaderProgram); shaderProgram.end(); } Gdx.gl.glClearColor(0, 0, 0, 0); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); spriteBatch.setProjectionMatrix(camera.combined); spriteBatch.begin(); // update objects if (objects != null) { for (int i = 0; i < objects.size(); i++) { objects.get(i).onRenderInternal(); if (objects == null) return; } if (Lumm.debug.isEnabled()) { for (int i = 0; i < objects.size(); i++) { objects.get(i).onDebugInternal(); } } } spriteBatch.end(); } catch (Exception e) { Lumm.net.logThrowable(e); } }
From source file:fr.plafogaj.screens.Game.java
License:Open Source License
@Override public void render(float delta) { timeLevel += delta;/* w w w . j a v a 2 s.c om*/ // clear the screen Gdx.gl.glClearColor(0.7f, 0.7f, 1.0f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); this.renderBGDecorParallax(); this.renderMiddleDecorParallax(); m_mapRenderer.setView(m_camera); m_mapRenderer.render(TiledMapConfig.COLLISION_LAYER); gameBatch.begin(); m_player.render(delta, gameBatch); this.renderEnemies(delta); this.renderLifeArtifacts(); this.renderEndObject(); this.renderArcPersistent(delta); gameBatch.end(); this.renderFGDecorParallax(); this.drawInfoPlayer(); m_camera.updateScrolling(m_player); this.updateTimeFormatted(); if (this.isEndGame()) { ((BananaKnight) (Gdx.app.getApplicationListener())) .setScreen(new EndMenu(m_gameLevelConfig.getLevelFile(), m_player.isAlive(), m_timeFormatted)); this.dispose(); } }
From source file:graphics.CargoSpace3D.java
License:Apache License
@Override 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); modelBatch.begin(cam);//from w w w.j a v a 2 s.c o m for (ModelInstance instance : instances) { modelBatch.render(instance, lights); } modelBatch.end(); }
From source file:headmade.arttag.screens.ArtTagScreen.java
License:Apache License
@Override public void render(float delta) { fpsLogger.log();/*from w w w . j av a2 s . c om*/ // while (FlickrService.instance.getWebArtCount() == 0) { // // wait // return; // } if (gameOverDelta > 3f) { endLevel(); gameOverDelta = 0f; } if (Player.instance.body != null && Player.instance.isCaught) { final PooledEffect effect = smokeEffectPool.obtain(); effect.setPosition(Player.instance.body.getWorldCenter().x, Player.instance.body.getWorldCenter().y); effects.add(effect); Assets.instance.playSound(AssetSounds.smoke); Assets.instance.playSound(AssetSounds.cough); Player.instance.isCaught = false; Player.instance.destroyBody(this); isGameOver = true; } if (!isGameOver) { // isSpotted will be set by guards Player.instance.isSpotted = false; for (final Guard g : guards) { g.update(this, delta); } Player.instance.update(this, delta); world.step(ArtTag.TIME_STEP, ArtTag.VELOCITY_ITERS, ArtTag.POSITION_ITERS); } else { gameOverDelta += delta; } if (Player.instance.isTouchingWarp) { newRoom(); } // camera.position.x = camera.position.x * ArtTag.UNIT_SCALE; // camera.position.y = camera.position.y * ArtTag.UNIT_SCALE; if (Player.instance.body != null) { camera.position.x = Player.instance.body.getPosition().x; camera.position.y = Player.instance.body.getPosition().y; camera.update(); } Gdx.gl.glClearColor(0f, 0f, 0f, 1f); // Gdx.gl.glClearColor(1f, 1f, 1f, 1f); // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0)); final SpriteBatch batch = game.getBatch(); batch.setColor(Color.WHITE); batch.setProjectionMatrix(camera.combined); mapRenderer.setView((OrthographicCamera) camera); mapRenderer.render(MapUtils.MAP_LAYERS_LOW); { // player and goards batch.begin(); shapeRenderer.begin(ShapeType.Line); Box2DSprite.draw(batch, world); // for (final headmade.arttag.spriter.Player player : players) { // player.update(); // if (Player.instance.body != null) { // player.setPosition(Player.instance.body.getWorldCenter().x, Player.instance.body.getWorldCenter().y); // } // drawer.draw(player); // } batch.end(); shapeRenderer.end(); } mapRenderer.render(MapUtils.MAP_LAYERS_HIGH); { batch.begin(); { // final Matrix4 oldTransMat = batch.getTransformMatrix(); for (final Art art : currentRoom.getArtList()) { art.draw(batch); // art.drawFrame(batch); } for (int i = effects.size - 1; i >= 0; i--) { final PooledEffect effect = effects.get(i); effect.draw(batch, delta); if (effect.isComplete()) { effect.free(); effects.removeIndex(i); } } } batch.end(); } rayHandler.setCombinedMatrix((OrthographicCamera) camera); rayHandler.updateAndRender(); // UI update if (Player.instance.artInView.size == 0) { currentArt = null; } if (currentArt != null) { imageActor.setDrawable(currentArt.getDrawable()); rootTable.layout(); } else { imageActor.setDrawable(null); } // show scan result? if (Player.instance.isTouchingArt && (Player.instance.isScanning || currentArt != null && currentArt.isScanned())) { resultActor.setVisible(true); } else { resultActor.setVisible(false); } // render UI if (currentArt != null) { final float alpha = Player.instance.imageAlpha; imageActor.getColor().a = alpha; if (alpha > 0f) { instructionsActor.setVisible(true); jobDescActor.setVisible(true); } else { instructionsActor.setVisible(false); jobDescActor.setVisible(false); } if (alpha > 0.3f) { if (sumDeltaLookAtImage > 0.3f) { currentArt.setSeen(true); TagService.instance.tagNotMatched(currentArt, jobDescription); } else { sumDeltaLookAtImage += delta; } } else { sumDeltaLookAtImage = 0f; } } if (isHideJobDesc) { jobDescActor.setVisible(false); } if (Player.instance.inventory.size >= Player.instance.getCarryCacity()) { instructionsActor.setVisible(true); } stage.act(delta); stage.draw(); if (debugEnabled) { shapeRenderer.setProjectionMatrix(camera.combined); shapeRenderer.setAutoShapeType(true); shapeRenderer.begin(); for (final Guard g : guards) { { if (g.getBackToPath().size > 0) { final float[] vertices = new float[2 + g.getBackToPath().size * 2]; vertices[0] = g.body.getPosition().x; vertices[1] = g.body.getPosition().y; int index = 1; for (int i = g.getBackToPath().size - 1; i >= 0; i--) { vertices[index * 2] = g.getBackToPath().get(i).x; vertices[index * 2 + 1] = g.getBackToPath().get(i).y; index++; } shapeRenderer.polyline(vertices); } } { if (g.path.size > 0) { final float[] vertices = new float[2 + g.path.size * 2]; vertices[0] = g.body.getPosition().x; vertices[1] = g.body.getPosition().y; int index = 1; for (int i = g.path.size - 1; i >= 0; i--) { vertices[index * 2] = g.path.get(i).x; vertices[index * 2 + 1] = g.path.get(i).y; index++; } shapeRenderer.polyline(vertices); } } } shapeRenderer.end(); box2dDebugRenderer.render(world, camera.combined); } }
From source file:headmade.arttag.screens.StageScreen.java
License:Apache License
@Override public void render(float delta) { preAct(delta);//from w w w .j a va 2 s . co m stage.act(delta); preDraw(delta); Gdx.gl.glClearColor(1f, 1f, 1f, 1f); // Gdx.gl.glClearColor(0f, 0f, 0f, 1f); // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0)); stage.draw(); }
From source file:lpool.gui.DirectionalShadowLight.java
License:Apache License
public void begin() { final int w = fbo.getWidth(); final int h = fbo.getHeight(); fbo.begin();/*from ww w. ja v a2 s. c o m*/ Gdx.gl.glViewport(0, 0, w, h); 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); Gdx.gl.glScissor(1, 1, w - 2, h - 2); }
From source file:net.mwplay.cocostudio.ui.AMScreen.java
License:Apache License
@Override public void render(float delta) { super.render(delta); Gdx.gl.glClearColor(1, 1, 1, 1);//from w w w .j a v a 2 s . co m Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); if (!init) { if (assetManager.update()) { init = true; initUi(); } else { LogUtil.log(assetManager.getProgress()); stage.getBatch().begin(); font.draw(stage.getBatch(), "..." + (int) (assetManager.getProgress() * 100) + "%", 640 - layout.width / 2f, 360); stage.getBatch().end(); } } stage.act(); stage.draw(); }
From source file:nu.geeks.boxes.HowToScreen.java
License:Creative Commons License
public void mDraw() { Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); batch.begin();/* w ww . ja v a 2s.com*/ batch.draw(UTILS.bg3, 0, 0); fnt.getData().setScale(1); fntBig.draw(batch, "Welcome to boxes!", Gdx.graphics.getWidth() / 2 - 110, Gdx.graphics.getHeight() - 50); fnt.draw(batch, "The goal of this game is to get all the boxes the same color.\nSelect a box using the WASD keys.\nChange color of the selected box, and all connected boxes \nof the same color, to the current color displayed\n in the top right corner by hitting ENTER.\nHit ENTER again to skip animation.\nPress R to restart game.\n\nTry to get through all 19 levels in as few moves as possible.\nHit ESC at any time to go back to main menu.", Gdx.graphics.getWidth() / 2 - 300, Gdx.graphics.getHeight() - 120); fnt.getData().setScale(0.5f); fnt.draw(batch, "Music:\n\"Monkeys Spinning Monkeys\" Kevin MacLeod (incompetech.com)\n" + "Licensed under Creative Commons: By Attribution 3.0\n" + "http://creativecommons.org/licenses/by/3.0/", Gdx.graphics.getWidth() / 2, 100); batch.end(); }