/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane * is set to 0, the far plane is set to 1. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height) { setToOrtho(x, x + width, y, y + height, 0, 1); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane * is set to 0, the far plane is set to 1. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height) { setToOrtho(x, x + width, y, y + height, 0, 1); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near * and far plane. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @param near The near plane * @param far The far plane * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height, float near, float far) { setToOrtho(x, x + width, y, y + height, near, far); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near * and far plane. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @param near The near plane * @param far The far plane * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height, float near, float far) { setToOrtho(x, x + width, y, y + height, near, far); return this; }
@Override public void update (boolean updateFrustum) { projection.setToOrtho(zoom * -viewportWidth / 2, zoom * (viewportWidth / 2), zoom * -(viewportHeight / 2), zoom * viewportHeight / 2, near, far); view.setToLookAt(position, tmp.set(position).add(direction), up); combined.set(projection); Matrix4.mul(combined.val, view.val); if (updateFrustum) { invProjectionView.set(combined); Matrix4.inv(invProjectionView.val); frustum.update(invProjectionView); } }
@Override public void update (boolean updateFrustum) { projection.setToOrtho(zoom * -viewportWidth / 2, zoom * (viewportWidth / 2), zoom * -(viewportHeight / 2), zoom * viewportHeight / 2, near, far); view.setToLookAt(position, tmp.set(position).add(direction), up); combined.set(projection); Matrix4.mul(combined.val, view.val); if (updateFrustum) { invProjectionView.set(combined); Matrix4.inv(invProjectionView.val); frustum.update(invProjectionView); } }
@Override public void create () { Gdx.input.setInputProcessor(new InputAdapter() { public boolean touchDown (int x, int y, int pointer, int newParam) { renderMode = (renderMode + 1) % 4; return false; } }); spriteBatch = new SpriteBatch(); spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1)); texture = new Texture(Gdx.files.internal("data/badlogic.jpg")); logoSprite = new Sprite(texture); logoSprite.flip(false, true); logoSprite.setPosition(0, 320 - 256); logoSprite.setColor(1, 1, 1, 0.5f); font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true); cache1 = font.newFontCache(); cache2 = font.newFontCache(); cache3 = font.newFontCache(); cache4 = font.newFontCache(); cache5 = font.newFontCache(); createCaches("cached", cache1, cache2, cache3, cache4, cache5); font.getData().setScale(1.33f); cacheScaled1 = font.newFontCache(); cacheScaled2 = font.newFontCache(); cacheScaled3 = font.newFontCache(); cacheScaled4 = font.newFontCache(); cacheScaled5 = font.newFontCache(); createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5); }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane * is set to 0, the far plane is set to 1. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height) { setToOrtho(x, x + width, y, y + height, 0, 1); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane * is set to 0, the far plane is set to 1. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height) { setToOrtho(x, x + width, y, y + height, 0, 1); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near * and far plane. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @param near The near plane * @param far The far plane * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height, float near, float far) { setToOrtho(x, x + width, y, y + height, near, far); return this; }
/** Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near * and far plane. * * @param x The x-coordinate of the origin * @param y The y-coordinate of the origin * @param width The width * @param height The height * @param near The near plane * @param far The far plane * @return This matrix for the purpose of chaining methods together. */ public Matrix4 setToOrtho2D (float x, float y, float width, float height, float near, float far) { setToOrtho(x, x + width, y, y + height, near, far); return this; }
public GameBatchRenderer (GL20 gl) { // setup a top-left origin // y-flip topLeftOrigin = new Matrix4(); topLeftOrigin.setToOrtho(0, ScaleUtils.PlayWidth, ScaleUtils.PlayHeight, 0, 0, 10); identity = new Matrix4(); // Issues may arise on Tegra2 (Asus Transformer) devices if the buffers' // count is higher than 10 // batch = new SpriteBatch(1000, 8); batch = new SpriteBatch(); begin = false; this.gl = gl; }
@Override public void update() { float left = zoom * -viewportWidth / 2 + virtualViewport.getVirtualWidth() * origin.x; float right = zoom * viewportWidth / 2 + virtualViewport.getVirtualWidth() * origin.x; float top = zoom * viewportHeight / 2 + virtualViewport.getVirtualHeight() * origin.y; float bottom = zoom * -viewportHeight / 2 + virtualViewport.getVirtualHeight() * origin.y; projection.setToOrtho(left, right, bottom, top, Math.abs(near), Math.abs(far)); view.setToLookAt(position, tmp.set(position).add(direction), up); combined.set(projection); Matrix4.mul(combined.val, view.val); invProjectionView.set(combined); Matrix4.inv(invProjectionView.val); frustum.update(invProjectionView); //Gdx.gl.glViewport((int) viewport.x, (int) viewport.y, (int) viewport.width, (int) viewport.height); }
@Override public void update (boolean updateFrustum) { projection.setToOrtho(zoom * -viewportWidth / 2, zoom * (viewportWidth / 2), zoom * -(viewportHeight / 2), zoom * viewportHeight / 2, near, far); view.setToLookAt(position, tmp.set(position).add(direction), up); combined.set(projection); Matrix4.mul(combined.val, view.val); if (updateFrustum) { invProjectionView.set(combined); Matrix4.inv(invProjectionView.val); frustum.update(invProjectionView); } }