com.badlogic.gdx.graphics.profiling.GLProfiler Java Examples

The following examples show how to use com.badlogic.gdx.graphics.profiling.GLProfiler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Unlucky.java    From Unlucky with MIT License 6 votes vote down vote up
public void dispose() {
       batch.dispose();
       super.dispose();

       rm.dispose();
       menuScreen.dispose();
       gameScreen.dispose();
       worldSelectScreen.dispose();
       levelSelectScreen.dispose();
       inventoryScreen.dispose();
       shopScreen.dispose();
       statisticsScreen.dispose();
       inventoryUI.dispose();
       victoryScreen.dispose();
       settingsScreen.dispose();

       GLProfiler.disable();
}
 
Example #2
Source File: GameRenderer.java    From Radix with MIT License 6 votes vote down vote up
@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;
}
 
Example #3
Source File: Graphics.java    From Cubes with MIT License 6 votes vote down vote up
public static void init() {
  if (init) return;
  init = true;

  modelBatch = new CubesModelBatch();

  for (Block block : IDManager.getBlocks()) {
    block.loadGraphics();
  }
  for (ItemBlock itemBlock : IDManager.getItemBlocks()) {
    itemBlock.loadGraphics();
  }
  for (Item item : IDManager.getItems()) {
    item.loadGraphics();
  }
  WorldGraphicsPools.init();
  BlockIcons.renderIcons();

  glProfiler = new GLProfiler(Gdx.graphics);
}
 
Example #4
Source File: PlayScreen.java    From xibalba with MIT License 5 votes vote down vote up
/**
 * Play Screen.
 *
 * @param main Instance of Main class
 */
public PlayScreen(Main main) {
  glProfiler = new GLProfiler(Gdx.graphics);

  autoTimer = 0;
  keyHoldTimerDelay = 0;
  keyHoldTimer = 0;
  batch = new SpriteBatch();

  // Setup camera;
  OrthographicCamera worldCamera = new OrthographicCamera();

  // Setup renderers
  worldRenderer = new WorldRenderer(worldCamera, batch);
  hudRenderer = new HudRenderer(main, batch);

  // Debug console
  console = new GUIConsole(Main.skin, false);
  console.setCommandExecutor(new ConsoleCommandExecutor());
  console.setSizePercent(100, 50);

  // Setup input
  multiplexer = new InputMultiplexer();
  playerInput = new PlayerInput(worldCamera);
  multiplexer.addProcessor(hudRenderer.stage);
  multiplexer.addProcessor(playerInput);

  // Player attributes & their god
  playerAttributes = ComponentMappers.attributes.get(WorldManager.player);
  god = ComponentMappers.god.get(WorldManager.god);

  // Generate all dijkstra maps
  WorldManager.world.getCurrentMap().dijkstra.updateAll();

  // Change state to playing
  WorldManager.state = WorldManager.State.PLAYING;
}
 
Example #5
Source File: GLTFDemo.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
@Override
public void create() {
	
	GLProfiler profiler = new GLProfiler(Gdx.graphics);
	profiler.setListener(new GLErrorListener() {
		@Override
		public void onError(int error) {
			Gdx.app.error("OpenGL", String.valueOf(error));
		}
	});
	profiler.enable();
	
	assetManager = new AssetManager();
	Texture.setAssetManager(assetManager);
	
	assetManager.setLoader(SceneAsset.class, ".gltf", new GLTFAssetLoader());
	assetManager.setLoader(SceneAsset.class, ".glb", new GLBAssetLoader());
	
	shapeRenderer = new ShapeRenderer();
	
	spriteBatch = new SpriteBatch();
	
	createSceneManager();
	
	createUI();
	
	loadModelIndex();
}
 
Example #6
Source File: Unlucky.java    From Unlucky with MIT License 5 votes vote down vote up
/**
    * Logs profile for SpriteBatch calls
    */
public void profile(String source) {
       System.out.println("Profiling " + source + "..." + "\n" +
           "  Drawcalls: " + GLProfiler.drawCalls +
           ", Calls: " + GLProfiler.calls +
           ", TextureBindings: " + GLProfiler.textureBindings +
           ", ShaderSwitches:  " + GLProfiler.shaderSwitches +
           " vertexCount: " + GLProfiler.vertexCount.value);
       GLProfiler.reset();
   }
 
Example #7
Source File: Profiler.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
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());
	}
}
 
Example #8
Source File: PreviewWidget.java    From talos with Apache License 2.0 4 votes vote down vote up
public GLProfiler getGLProfiler() {
    return glProfiler;
}
 
Example #9
Source File: Unlucky.java    From Unlucky with MIT License 4 votes vote down vote up
public void create() {
       batch = new SpriteBatch();
       rm = new ResourceManager();
       player = new Player("player", rm);

       save = new Save(player, "save.json");
       save.load(rm);

       // debugging
       fps = new Label("", new Label.LabelStyle(rm.pixel10, Color.RED));
       fps.setFontScale(0.5f);
       fps.setVisible(player.settings.showFps);

       inventoryUI = new InventoryUI(this, player, rm);
       menuScreen = new MenuScreen(this, rm);
       gameScreen = new GameScreen(this, rm);
       worldSelectScreen = new WorldSelectScreen(this, rm);
       levelSelectScreen = new LevelSelectScreen(this, rm);
       inventoryScreen = new InventoryScreen(this, rm);
       shopScreen = new ShopScreen(this, rm);
       smoveScreen = new SpecialMoveScreen(this, rm);
       statisticsScreen = new StatisticsScreen(this, rm);
       victoryScreen = new VictoryScreen(this, rm);
       settingsScreen = new SettingsScreen(this, rm);

       // create parallax background
       menuBackground = new Background[3];

       // ordered by depth
       // sky
       menuBackground[0] = new Background(rm.titleScreenBackground[0],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0, 0));
       menuBackground[0].setVector(0, 0);
       // back clouds
       menuBackground[1] = new Background(rm.titleScreenBackground[2],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[1].setVector(20, 0);
       // front clouds
       menuBackground[2] = new Background(rm.titleScreenBackground[1],
           (OrthographicCamera) menuScreen.getStage().getCamera(), new Vector2(0.3f, 0));
       menuBackground[2].setVector(60, 0);

       // profiler
       GLProfiler.enable();

       this.setScreen(menuScreen);
}
 
Example #10
Source File: Profiler.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
public static void enable() {
	instance = new Profiler();
	GLProfiler.enable();
}
 
Example #11
Source File: Profiler.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
public static void disable() {
	instance = null;
	GLProfiler.disable();
}
 
Example #12
Source File: Profiler.java    From gdx-proto with Apache License 2.0 4 votes vote down vote up
public static void reset() {
	GLProfiler.reset();
}