Search in sources :

Example 1 with ShadowMapRegion

use of com.badlogic.gdx.tests.g3d.shadows.utils.ShadowMapAllocator.ShadowMapRegion in project libgdx by libgdx.

the class BaseShadowSystem method processViewport.

/** Set viewport according to allocator.
	 * @param lp LightProperties to process.
	 * @param cameraViewport Set camera viewport if true. */
protected void processViewport(LightProperties lp, boolean cameraViewport) {
    Camera camera = lp.camera;
    ShadowMapRegion r = allocator.nextResult(currentLight);
    if (r == null)
        return;
    TextureRegion region = lp.region;
    region.setTexture(frameBuffers[currentPass].getColorBufferTexture());
    // We don't use HdpiUtils
    // gl commands related to shadow map size and not to screen size
    Gdx.gl.glViewport(r.x, r.y, r.width, r.height);
    Gdx.gl.glScissor(r.x + 1, r.y + 1, r.width - 2, r.height - 2);
    region.setRegion(r.x, r.y, r.width, r.height);
    if (cameraViewport) {
        camera.viewportHeight = r.height;
        camera.viewportWidth = r.width;
        camera.update();
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ShadowMapRegion(com.badlogic.gdx.tests.g3d.shadows.utils.ShadowMapAllocator.ShadowMapRegion) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) Camera(com.badlogic.gdx.graphics.Camera) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera)

Aggregations

Camera (com.badlogic.gdx.graphics.Camera)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 ShadowMapRegion (com.badlogic.gdx.tests.g3d.shadows.utils.ShadowMapAllocator.ShadowMapRegion)1