protected static void frameStart() { fps.tick(); if (glProfiler && Cubes.getClient().renderer.guiRenderer.debugEnabled) { LastFrame.totalCalls = GLProfiler.calls; LastFrame.drawCalls = GLProfiler.drawCalls; LastFrame.textureBindings = GLProfiler.textureBindings; LastFrame.shaderSwitches = GLProfiler.shaderSwitches; LastFrame.vertexCount = GLProfiler.vertexCount.total; GLProfiler.calls = 0; GLProfiler.drawCalls = 0; GLProfiler.textureBindings = 0; GLProfiler.shaderSwitches = 0; GLProfiler.vertexCount.reset(); } }
@Override public void render() { if (!initted) init(); prepareWorldRender(); game.getWorld().render(); RadixAPI.instance.getEventManager().push(new EventPostWorldRender()); drawBlockSelection(); renderEntities(); curDC = GLProfiler.drawCalls - lastDC; curGLC = GLProfiler.calls - lastGLC; curVTCS = (int) GLProfiler.vertexCount.total - lastVTCS; curTB = GLProfiler.textureBindings - lastTB; curSS = GLProfiler.shaderSwitches - lastSS; lastDC = GLProfiler.drawCalls; lastGLC = GLProfiler.calls; lastVTCS = (int) GLProfiler.vertexCount.total; lastTB = GLProfiler.textureBindings; lastSS = GLProfiler.shaderSwitches; }
public void update() { accumulator += Gdx.graphics.getDeltaTime(); if (accumulator >= 0.25f){ accumulator = 0f; if (projectController.levelEditorScreen == null || projectController.levelEditorScreen.level == null) { fpsLabel.setText("..."); statusMemoryLabel.setText("..."); statusRenderablesLabel.setText("..."); mapCursorPositionLabel.setText("..."); statusTriangleCountLabel.setText("..."); } else { fpsLabel.setText("FPS: " + Gdx.graphics.getFramesPerSecond()); statusMemoryLabel.setText("Memory: " + FormatUtils.humanReadableByteCount(Gdx.app.getNativeHeap(), true) + "/" + FormatUtils.humanReadableByteCount(Gdx.app.getJavaHeap(), true)); statusRenderablesLabel.setText("Renderables: " + String.valueOf(projectController.levelEditorScreen.level.batch.renderablesPerFrame)); statusTriangleCountLabel.setText("Vertex avg: " + String.valueOf(Math.round(GLProfiler.vertexCount.average))); mapCursorPositionLabel.setText(projectController.levelEditorScreen.selectionSystem.voxelCursor.replace.toString()); } } }
@Override protected void onInitialize() { GLProfiler.enable(); this.overlay = new Overlay(); this.level = new Level(state, new DynamicGeometryProvider(state.terrainMap)); this.selectionSystem = new SelectionSystem(level); this.cameraController = new RTSCameraController(); this.decalBatch = new DecalBatch(new CameraGroupStrategy(level.camera)); level.camera.far = LEVEL_EDITOR_FAR_CAMERA; level.camera.near = 0.01f; level.camera.fieldOfView = 70; cameraController.setCenter(level.terrainMap.getWidth() / 2, level.terrainMap.getDepth() / 2); cameraController.setCamera(level.camera); cameraController.setOverlay(overlay); selectionSystem.setOverlay(overlay); level.entities.addSystem(selectionSystem); level.entities.psychics.disable(); this.fullScreenBuffer = new FullScreenFrameBufferResult(Fbo.FRAMEBUFFER_FINAL); // }
@Override public void show() { GameSave.unlockLevel(levelName); music = game.assets.manager.get(loader.level.music.first()); if(!resumed) music.setPosition(0); music.setLooping(true); MusicManager.play(music); if (debug) GLProfiler.enable(); if (!resumed || forceCheckEnter) { world.maryo.checkLevelEnter(entryName); forceCheckEnter = false; } Gdx.input.setCatchBackKey(true); Gdx.input.setInputProcessor(this); if (!resumed) { game.levelStart(levelName); } if (resumed) { cameraForceSnap = true; } }
protected static void setup() { glProfiler = Settings.getBooleanSettingValue(Settings.DEBUG_GL_PROFILER); if (glProfiler) { GLProfiler.enable(); } else { GLProfiler.disable(); } }
@Override public void render(float delta) { if (!pause) { ForgE.assets.loadPendingInChunks(); cameraController.update(delta); level.render(delta); for (int i = 0; i < afterRenderListenerArray.size; i++) { afterRenderListenerArray.get(i).forgeAfterRenderCallback(this); } } GLProfiler.reset(); }
@Override public void dispose() { GLProfiler.disable(); level.dispose(); changeManager.dispose(); decalBatch.dispose(); }
protected void getStatus (final StringBuilder stringBuilder) { stringBuilder.setLength(0); stringBuilder.append("GL calls: "); stringBuilder.append(GLProfiler.calls); glCallsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Draw calls: "); stringBuilder.append(GLProfiler.drawCalls); drawCallsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Shader switches: "); stringBuilder.append(GLProfiler.shaderSwitches); shaderSwitchesLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Texture bindings: "); stringBuilder.append(GLProfiler.textureBindings); textureBindsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Vertices: "); stringBuilder.append(GLProfiler.vertexCount.total); vertexCountLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Lights: "); stringBuilder.append(environment.directionalLights.size + environment.pointLights.size); stringBuilder.append(", Directional: "); stringBuilder.append(environment.directionalLights.size); stringBuilder.append(", Point: "); stringBuilder.append(environment.pointLights.size); lightsLabel.setText(stringBuilder); GLProfiler.reset(); stringBuilder.setLength(0); super.getStatus(stringBuilder); }
private String generateDebugMessage() { return "Level: width=" + world.level.width + ", height=" + world.level.height + "\n" + "Player: x=" + world.maryo.position.x + ", y=" + world.maryo.position.y + "\n" + "LevelName: " + levelName + "\n" + "Player Vel: x=" + world.maryo.velocity.x + ", y=" + world.maryo.velocity.y + "\n" + "World Camera: x=" + cam.position.x + ", y=" + cam.position.y + "\n" + "JavaHeap: " + Gdx.app.getJavaHeap() / 1000000 + "MB" + "\n" + "NativeHeap: " + Gdx.app.getNativeHeap() / 1000000 + "MB" + "\n" + "OGL Draw Calls: " + GLProfiler.drawCalls + "\n" + "OGL TextureBindings: " + GLProfiler.textureBindings + "\n" + "Screen w=" + width + "h=" + height + "\n" + "FPS: " + Gdx.graphics.getFramesPerSecond(); }
@Override public void dispose() { music.stop(); Gdx.input.setInputProcessor(null); game.assets.dispose(); exitDialog.dispose(); world.dispose(); if (globalEffect != null) { globalEffect.dispose(); } if (debug) GLProfiler.disable(); }
public static void tick() { if (instance == null) { instance = new Profiler(); } instance.drawCalls.add(GLProfiler.drawCalls); instance.calls.add(GLProfiler.calls); instance.shaderSwitches.add(GLProfiler.shaderSwitches); instance.textureBinds.add(GLProfiler.textureBindings); instance.vertices.add(GLProfiler.vertexCount.count); instance.fpsCounter.add(Gdx.graphics.getFramesPerSecond()); if (Main.frame % reportIntervalInFrames == 0) { Log.debug(instance.reportAverage()); } }
protected void getStatus (final StringBuilder stringBuilder) { stringBuilder.setLength(0); stringBuilder.append("GL calls: "); stringBuilder.append(GLProfiler.calls); glCallsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Draw calls: "); stringBuilder.append(GLProfiler.drawCalls); drawCallsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Shader switches: "); stringBuilder.append(GLProfiler.shaderSwitches); shaderSwitchesLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Texture bindings: "); stringBuilder.append(GLProfiler.textureBindings); textureBindsLabel.setText(stringBuilder); stringBuilder.setLength(0); stringBuilder.append("Vertices: "); stringBuilder.append((int)GLProfiler.vertexCount.total); vertexCountLabel.setText(stringBuilder); GLProfiler.reset(); stringBuilder.setLength(0); stringBuilder.append("FPS: ").append(Gdx.graphics.getFramesPerSecond()); }
@Override public void dispose () { super.dispose(); skin.dispose(); skin = null; GLProfiler.disable(); }
public void dispose() { GLProfiler.disable(); worldRenderer.dispose(); guiRenderer.dispose(); }
@Override public void dispose () { super.dispose(); GLProfiler.disable(); }
@Override public void render(float delta) { Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); //physics updateObjects(delta); //physics end moveCamera(cam, gameState == GAME_STATE.GAME_EDIT_MODE ? cameraEditModeTranslate : world.maryo.position, gameState == GAME_STATE.GAME_EDIT_MODE || (gameState != GAME_STATE.GAME_RUNNING && gameState != GAME_STATE.PLAYER_UPDATING && gameState != GAME_STATE.PLAYER_DEAD)); drawBackground(); spriteBatch.setProjectionMatrix(cam.combined); spriteBatch.begin(); drawObjects(); killPointsTextHandler.render(spriteBatch, delta); if(globalEffect != null) { globalEffect.setPosition(cam.position.x - Constants.CAMERA_WIDTH * 0.5f, cam.position.y + 0.5f * Constants.CAMERA_HEIGHT); globalEffect.draw(spriteBatch); if (gameState == GAME_STATE.GAME_RUNNING) globalEffect.update(delta); } spriteBatch.end(); spriteBatch.setProjectionMatrix(guiCam.combined); spriteBatch.begin(); if (debug) drawDebugText(); spriteBatch.end(); if (debug) drawDebug(); hud.render(gameState, delta); if (gameState == GAME_STATE.GAME_OVER) { handleGameOver(); } if (gameState == GAME_STATE.GAME_LEVEL_END) { handleLevelEnded(delta); } exitDialog.render(spriteBatch); //cleanup for (int i = 0; i < world.trashObjects.size; i++) { world.level.gameObjects.remove(world.trashObjects.get(i)); } world.trashObjects.clear(); //debug if (gameState == GAME_STATE.GAME_EDIT_MODE) { if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) { cameraEditModeTranslate.x += 0.2f; } else if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) { cameraEditModeTranslate.x -= 0.2f; } if (Gdx.input.isKeyPressed(Input.Keys.UP)) { cameraEditModeTranslate.y += 0.2f; } else if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) { cameraEditModeTranslate.y -= 0.2f; } } if (debug) GLProfiler.reset(); }
public static void enable() { instance = new Profiler(); GLProfiler.enable(); }
public static void disable() { instance = null; GLProfiler.disable(); }
public static void reset() { GLProfiler.reset(); }
@Override public void create() { GLProfiler.enable(); createHUD(); }