public void render(float delta) { Gdx.gl.glClearColor(0.9f, 0.9f, 0.9f, 1); Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT); float font = text.getBounds(message).width; batch.begin(); { text.draw(batch, message, (width / 2F) - (font / 2F), height - text.getCapHeight()); replay.render(batch); menu.render(batch); } batch.end(); }
public void render(float delta) { gameTicks++; long seconds = (long) ((gameTicks / 60D) * 10L); Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1); Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT); controller.update(delta); updateEntities(delta); renderer.render(); button.begin(ShapeRenderer.ShapeType.Filled); { if (Gdx.app.getType().equals(Application.ApplicationType.Android)) { Gdx.gl.glEnable(Gdx.gl20.GL_BLEND); Gdx.gl.glBlendFunc(Gdx.gl20.GL_SRC_ALPHA, Gdx.gl20.GL_ONE_MINUS_SRC_ALPHA); button.setColor(0.0F, 0.5F, 0.5F, 0.5F); button.rect(left.x, left.y, left.width, left.height); button.rect(right.x, right.y, right.width, right.height); button.setColor(1.0F, 1.0F, 1.0F, 0.5F); button.rect(jump.x, jump.y, jump.width, jump.height); } world.getJaxon().inventory.renderGUI(button, width, height, buttonSize * 0.75F); } button.end(); batch.begin(); { if (Gdx.app.getType().equals(Application.ApplicationType.Android)) { batch.draw(controlLeft, left.x, left.y, left.width, left.height); batch.draw(controlRight, right.x, right.y, right.width, right.height); batch.draw(controlUp, jump.x, jump.y, jump.width, jump.height); } world.getJaxon().inventory.renderItems(batch, width, height, buttonSize * 0.75F); font.draw( batch, "Time: " + (seconds / 10D) + " ticks, FPS: " + Gdx.graphics.getFramesPerSecond(), 0, height - 10); } batch.end(); }
public static void dispose() { modelBatch.dispose(); spriteBatch.dispose(); frameBuffer.dispose(); tempBuffer.dispose(); shaderProvider.dispose(); for (ShaderProgram s : Bdx.matShaders.values()) { s.dispose(); } }
public static void resize(int width, int height) { spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, width, height); if (frameBuffer != null) frameBuffer.dispose(); if (tempBuffer != null) tempBuffer.dispose(); frameBuffer = new RenderBuffer( spriteBatch); // Have to recreate all render buffers and adjust the projection matrix as // the window size has changed tempBuffer = new RenderBuffer(spriteBatch); for (Scene scene : scenes) { if (scene.lastFrameBuffer != null) scene.lastFrameBuffer.dispose(); scene.lastFrameBuffer = new RenderBuffer(null); } }
public static void init() { time = 0; profiler = new Profiler(); display = new Display(); scenes = new ArrayListScenes(); sounds = new Sounds(); music = new Music(); mouse = new Mouse(); gamepads = new ArrayListNamed<Gamepad>(); for (int i = 0; i < Controllers.getControllers().size; i++) { gamepads.add(new Gamepad(i)); } imaps = new InputMaps(); keyboard = new Keyboard(); fingers = new ArrayList<Finger>(); components = new ArrayList<Component>(); matShaders = new HashMap<String, ShaderProgram>(); allocatedFingers = new ArrayList<Finger>(); for (int i = 0; i < 10; ++i) { allocatedFingers.add(new Finger(i)); } Gdx.input.setInputProcessor(new GdxProcessor(keyboard, mouse, allocatedFingers, gamepads)); com.badlogic.gdx.graphics.glutils.ShaderProgram.pedantic = false; shaderProvider = new BDXShaderProvider(); modelBatch = new ModelBatch(shaderProvider); spriteBatch = new SpriteBatch(); spriteBatch.setBlendFunction(Gdx.gl.GL_SRC_ALPHA, Gdx.gl.GL_ONE_MINUS_SRC_ALPHA); frameBuffer = new RenderBuffer(spriteBatch); tempBuffer = new RenderBuffer(spriteBatch); advancedLightingOn = true; }