com.badlogic.gdx.math.Matrix4.setToOrtho2D()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中com.badlogic.gdx.math.Matrix4.setToOrtho2D()方法的一些代码示例,展示了Matrix4.setToOrtho2D()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix4.setToOrtho2D()方法的具体详情如下:
包路径:com.badlogic.gdx.math.Matrix4
类名称:Matrix4
方法名:setToOrtho2D

Matrix4.setToOrtho2D介绍

[英]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.
[中]将此矩阵设置为正交投影矩阵,其原点位于(x,y)并按宽度和高度延伸。近平面设置为0,远平面设置为1。

代码示例

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  this.width = width;
  this.height = height;
  batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  this.width = width;
  this.height = height;
  batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void resize (int width, int height) {
  batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
}

代码示例来源:origin: libgdx/libgdx

@Override
public void resize (int width, int height) {
  Gdx.app.log("FullscreenTest", "resized: " + width + ", " + height);
  batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
    renderer.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
    renderer.updateMatrices();
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void resize (int width, int height) {
    spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
    camera.viewportWidth = width;
    camera.viewportHeight = height;
    camera.update();
  }
}

代码示例来源:origin: libgdx/libgdx

@Override
  public void resize (int width, int height) {
    stage.getViewport().update(width, height, true);
    batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
  }
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  batch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
  shapes.setProjectionMatrix(batch.getProjectionMatrix());
}

代码示例来源:origin: libgdx/libgdx

public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) {
  if (defaultShader == null) {
    renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0);
  } else {
    renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader);
  }
  projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  matrixDirty = true;
}

代码示例来源:origin: libgdx/libgdx

public ShapeRenderer (int maxVertices, ShaderProgram defaultShader) {
  if (defaultShader == null) {
    renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0);
  } else {
    renderer = new ImmediateModeRenderer20(maxVertices, false, true, 0, defaultShader);
  }
  projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
  matrixDirty = true;
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  renderer.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  renderer.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
}

代码示例来源:origin: libgdx/libgdx

public void resize (int width, int height) {
  spriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, width, height);
  renderer.setProjectionMatrix(spriteBatch.getProjectionMatrix());
  stage.getViewport().update(width, height, true);
}

代码示例来源:origin: libgdx/libgdx

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());
  }
}

代码示例来源:origin: libgdx/libgdx

public void create () {
  batch = new SpriteBatch();
  sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
  textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
  atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
  texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true);
  texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
  setTextureFilter(0);
  setModeString();
  sprite = atlas.createSprite("map");
  sprite2 = new Sprite(texture, 0, 0, 855, 480);
  font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
  Gdx.input.setInputProcessor(new InputAdapter() {
    public boolean touchDown (int x, int y, int pointer, int newParam) {
      mode++;
      if (mode == filters.length * 2) mode = 0;
      setTextureFilter(mode / 2);
      setModeString();
      return false;
    }
  });
}

代码示例来源:origin: libgdx/libgdx

/** Creates a cache with the specified size and OpenGL ES 2.0 shader.
 * @param size The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
 *           Max of 8191 if indices are used.
 * @param useIndices If true, indexed geometry will be used. */
public SpriteCache (int size, ShaderProgram shader, boolean useIndices) {
  this.shader = shader;
  if (useIndices && size > 8191) throw new IllegalArgumentException("Can't have more than 8191 sprites per batch: " + size);
  mesh = new Mesh(true, size * (useIndices ? 4 : 6), useIndices ? size * 6 : 0, new VertexAttribute(Usage.Position, 2,
    ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE),
    new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
  mesh.setAutoBind(false);
  if (useIndices) {
    int length = size * 6;
    short[] indices = new short[length];
    short j = 0;
    for (int i = 0; i < length; i += 6, j += 4) {
      indices[i + 0] = (short)j;
      indices[i + 1] = (short)(j + 1);
      indices[i + 2] = (short)(j + 2);
      indices[i + 3] = (short)(j + 2);
      indices[i + 4] = (short)(j + 3);
      indices[i + 5] = (short)j;
    }
    mesh.setIndices(indices);
  }
  projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}

代码示例来源:origin: libgdx/libgdx

public void create () {
  batch = new SpriteBatch();
  batch.setProjectionMatrix(new Matrix4().setToOrtho2D(0, 0, 855, 480));
  atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
  sprite = atlas.createSprite("map");
  font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);
  Gdx.gl.glClearColor(0, 1, 0, 1);
}

代码示例来源:origin: libgdx/libgdx

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;
    int activeCount = emitters.get(emitterIndex).getActiveCount();
    Gdx.app.log("libgdx", activeCount + "/" + particleCount + " particles, FPS: " + Gdx.graphics.getFramesPerSecond());
  }
}

代码示例来源:origin: libgdx/libgdx

@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();
}

代码示例来源:origin: libgdx/libgdx

public void render () {
  ui.act();
  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();
  for (ParticleEffect e : effects)
    e.draw(spriteBatch, delta);
  spriteBatch.end();
  fpsCounter += delta;
  if (fpsCounter > 3) {
    fpsCounter = 0;
    String log = effects.size + " particle effects, FPS: " + Gdx.graphics.getFramesPerSecond() + ", Render calls: "
      + spriteBatch.renderCalls;
    Gdx.app.log("libgdx", log);
    logLabel.setText(log);
  }
  ui.draw();
}

相关文章