@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); ui.act(Gdx.graphics.getDeltaTime()); ui.draw(); }
@Override public void postRunnable (Runnable runnable) { synchronized (runnables) { runnables.add(runnable); Gdx.graphics.requestRendering(); } }
@Override public void clicked (InputEvent event, float x, float y) { super.clicked(event, x, y); if (isWindowed) { isWindowed = false; changeModeButton.setText(fullScreenInstructions); Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode()); } else { isWindowed = true; changeModeButton.setText(windowedInstructions); Gdx.graphics.setWindowedMode(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); } } });
/** @return the current viewport in OpenGL ES window coordinates based on the currently applied scissor */ public static Rectangle getViewport () { if (scissors.size == 0) { viewport.set(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); return viewport; } else { Rectangle scissor = scissors.peek(); viewport.set(scissor); return viewport; } } }
public void render () { spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); float delta = Gdx.graphics.getDeltaTime(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); spriteBatch.begin(); effect.draw(spriteBatch, delta); spriteBatch.end(); fpsCounter += delta; if (fpsCounter > 3) { fpsCounter = 0; Gdx.app.log("libgdx", "current sprite: " + currentSprite + ", FPS: " + Gdx.graphics.getFramesPerSecond()); } }
@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); int size = Math.min(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); int quarterSize = (int) (size/4f); batch.begin(); batch.draw(textureRegions.get(pageToShow), 0, 0, size, size); ninePatch.draw(batch, 10, 10, quarterSize, quarterSize); officialPatch.draw(batch, (int)(size * 0.25f + 20), 10, quarterSize, quarterSize); batch.end(); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setColor(Color.GREEN); shapeRenderer.rect(0, 0, size, size); shapeRenderer.end(); }
/** Calls {@link GL20#glViewport(int, int, int, int)}, expecting the coordinates and sizes given in logical coordinates and * automatically converts them to backbuffer coordinates, which may be bigger on HDPI screens. */ public static void glViewport (int x, int y, int width, int height) { if (mode == HdpiMode.Logical && (Gdx.graphics.getWidth() != Gdx.graphics.getBackBufferWidth() || Gdx.graphics.getHeight() != Gdx.graphics.getBackBufferHeight())) { Gdx.gl.glViewport(toBackBufferX(x), toBackBufferY(y), toBackBufferX(width), toBackBufferY(height)); } else { Gdx.gl.glViewport(x, y, width, height); } }
public void addAction (Action action) { action.setActor(this); actions.add(action); if (stage != null && stage.getActionsRequestRendering()) Gdx.graphics.requestRendering(); }
public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.draw(); // check how many actors are visible. Array<Actor> actors = stage.getActors(); int numVisible = 0; for (int i = 0; i < actors.size; i++) { numVisible += ((CullableActor)actors.get(i)).visible ? 1 : 0; } batch.begin(); font.draw(batch, "Visible: " + numVisible + ", fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30); batch.end(); }
@Override public void render () { inputController.update(); if ((time += Gdx.graphics.getDeltaTime()) >= 1f) { time -= 1f; index = (index + 1) % regions.size; attribute.set(regions.get(index)); Gdx.app.log("TextureRegion3DTest", "Current region = "+regions.get(index).name); } Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight()); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); modelBatch.begin(cam); modelBatch.render(instance, environment); modelBatch.end(); }
@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); fpsLabel.setText("fps: " + Gdx.graphics.getFramesPerSecond()); stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f)); stage.draw(); }
@Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); batch.draw(img2, -100, 0); batch.draw(img1, 0, 0); batch.end(); batch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.begin(); font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 0, 30); batch.end(); }
@Override public void render () { Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.draw(); Gdx.app.log("X", "FPS: " + Gdx.graphics.getFramesPerSecond()); SpriteBatch spriteBatch = (SpriteBatch)stage.getBatch(); Gdx.app.log("X", "render calls: " + spriteBatch.totalRenderCalls); spriteBatch.totalRenderCalls = 0; }
@Override public void render () { long frameTime = TimeUtils.nanoTime(); float deltaTime = (frameTime - lastFrameTime) / 1000000000.0f; lastFrameTime = frameTime; Gdx.app.log("DeltaTimeTest", "delta: " + deltaTime + ", gdx delta: " + Gdx.graphics.getDeltaTime()); } }
public void run () { cursorOn = !cursorOn; Gdx.graphics.requestRendering(); } };
public void render (boolean update) { fpsCounter.put(Gdx.graphics.getFramesPerSecond()); if (update) update(); beginRender(true); renderWorld(); Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); if (debugMode != DebugDrawModes.DBG_NoDebug) world.setDebugMode(debugMode); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); performance.setLength(0); performance.append("FPS: ").append(fpsCounter.value).append(", Bullet: ") .append((int)(performanceCounter.load.value * 100f)).append("%"); }