Java Code Examples for com.badlogic.gdx.graphics.glutils.ShapeRenderer#setProjectionMatrix()

The following examples show how to use com.badlogic.gdx.graphics.glutils.ShapeRenderer#setProjectionMatrix() . 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: Cursor.java    From riiablo with Apache License 2.0 6 votes vote down vote up
public void render(PaletteIndexedBatch batch) {
  if (dc != null) {
    BBox box = dc.getBox();
    coords.set(Gdx.input.getX(), Gdx.input.getY());
    Riiablo.extendViewport.unproject(coords);
    coords.sub(box.width / 2f, box.height / 2f);

    batch.begin();
    batch.setColormap(transform, transformColor);
    if (item.isEthereal()) batch.setAlpha(Item.ETHEREAL_ALPHA);
    batch.draw(dc.getTexture(), coords.x, coords.y);
    if (item.isEthereal()) batch.resetColor();
    batch.resetColormap();
    batch.end();

    if (DEBUG_ITEM_BOUNDS) {
      ShapeRenderer shapes = Riiablo.shapes;
      shapes.setProjectionMatrix(Riiablo.extendViewport.getCamera().combined);
      shapes.begin(ShapeRenderer.ShapeType.Line);
      shapes.setColor(Color.GREEN);
      shapes.rect(coords.x, coords.y, box.width, box.height);
      shapes.end();
    }
  }
}
 
Example 2
Source File: EntityStage.java    From Norii with Apache License 2.0 5 votes vote down vote up
public void drawEntitiesDebug() {
	final Array<Actor> actors = getActors();
	final ShapeRenderer debugRenderer = new ShapeRenderer();
	debugRenderer.setProjectionMatrix(getCamera().combined);
	debugRenderer.setColor(Color.RED);
	debugRenderer.begin(ShapeType.Line);
	for (final Actor actor : actors) {
		actor.debug();
		actor.drawDebug(debugRenderer);
	}
	debugRenderer.end();
}
 
Example 3
Source File: Rain.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
@Override public void draw(Batch batch, float parentAlpha) {
    validate();
    batch.end();
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ShapeRenderer renderer = Config.shapeRenderer;
    renderer.setProjectionMatrix(batch.getProjectionMatrix());
    renderer.setTransformMatrix(batch.getTransformMatrix());

    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(style.color.r, style.color.g, style.color.b, style.color.a * parentAlpha);
    float usedWidth = getWidth() - style.pad;
    int count = (int) (usedWidth / (style.dropWidth + style.pad));
    if (count == 0)
        return;
    float step = usedWidth / ((float) count);
    float x = style.pad;
    for (int i = 0, n = rows.size; i < n; i++) {
        Row row = rows.get(i);
        drawRow(x, row);
        x += step;
    }
    renderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}
 
Example 4
Source File: RenderSystem.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void drawDebug(ShapeRenderer shapes) {
  batch.setProjectionMatrix(iso.combined);
  shapes.setProjectionMatrix(iso.combined);
  if (RENDER_DEBUG_GRID > 0)
    drawDebugGrid(shapes);

  if (RENDER_DEBUG_WALKABLE > 0)
    drawDebugWalkable(shapes);

  if (RENDER_DEBUG_CELLS > 0)
    drawDebugCells(shapes);

  if (RENDER_DEBUG_SPECIAL)
    drawDebugSpecial(shapes);

  if (RENDER_DEBUG_TILE) {
    shapes.setColor(Color.OLIVE);
    DebugUtils.drawDiamond2(shapes, tpx, tpy, Tile.WIDTH, Tile.HEIGHT);
  }

  if (RENDER_DEBUG_SUBTILE) {
    shapes.setColor(Color.WHITE);
    DebugUtils.drawDiamond2(shapes, spx, spy, Tile.SUBTILE_WIDTH, Tile.SUBTILE_HEIGHT);
  }

  if (RENDER_DEBUG_ENTITIES)
    drawDebugObjects(shapes);

  if (RENDER_DEBUG_CAMERA)
    drawDebugCamera(shapes);

  if (RENDER_DEBUG_OVERSCAN > 0)
    drawDebugOverscan(shapes);

  if (DEBUG_MOUSE)
    drawDebugMouse(shapes);
}
 
Example 5
Source File: DemoCamera.java    From ud405 with MIT License 5 votes vote down vote up
/**
 * Set's the ShapeRenderer's projection matrix depending on the mode of the demo camera.
 */
public void setCamera(ShapeRenderer renderer) {
    if (inCloseupMode) {
        closeupCamera.update();
        renderer.setProjectionMatrix(closeupCamera.combined);
    } else {
        overviewCamera.update();
        renderer.setProjectionMatrix(overviewCamera.combined);
    }
}