Java Code Examples for com.badlogic.gdx.graphics.glutils.HdpiUtils

The following examples show how to use com.badlogic.gdx.graphics.glutils.HdpiUtils. These examples are extracted from open source projects. 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
public RetroSceneScreen() {
	screenViewport = new SceneFitViewport();

	worldViewport = new Viewport() {
		// This is the World Viewport. It is like a ScreenViewport but the
		// camera is the same that the screenViewport;
		@Override
		public void apply(boolean centerCamera) {
			HdpiUtils.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight());
			getCamera().viewportWidth = getScreenWidth();
			getCamera().viewportHeight = getScreenHeight();
			if (centerCamera)
				getCamera().position.set(getScreenWidth() / 2, getScreenHeight() / 2, 0);
			getCamera().update();
		}
	};

	worldViewport.setCamera(screenViewport.getCamera());
}
 
Example 2
@Override
public void apply(boolean centerCamera) {
	HdpiUtils.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight());
	getCamera().viewportWidth = getScreenWidth();
	getCamera().viewportHeight = getScreenHeight();
	if (centerCamera)
		getCamera().position.set(getScreenWidth() / 2, getScreenHeight() / 2, 0);
	getCamera().update();
}
 
Example 3
@Override
public void apply (boolean centerCamera) {
	HdpiUtils.glViewport(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight());
	getCamera().viewportWidth = getScreenWidth();
	getCamera().viewportHeight = getScreenHeight();
	if (centerCamera)
		getCamera().position.set(getScreenWidth() / 2, getScreenHeight() / 2, 0);
	getCamera().update();
}
 
Example 4
Source Project: talos   Source File: ViewportWidget.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    batch.end();

    localToScreenCoordinates(temp.set(0, 0));
    int x = (int)temp.x;
    int y = (int)temp.y;

    localToScreenCoordinates(temp.set(getWidth(), getHeight()));

    int x2 = (int)temp.x;
    int y2 = (int)temp.y;

    int ssWidth = x2 - x;
    int ssHeight = y - y2;

    HdpiUtils.glViewport(x, Gdx.graphics.getHeight() - y, ssWidth, ssHeight);

    Gdx.gl.glClearColor(bgColor.r, bgColor.g, bgColor.b, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    float aspect = getWidth()/getHeight();

    camera.viewportHeight = camera.viewportWidth / aspect;

    camera.update();

    prevTransform.set(batch.getTransformMatrix());
    prevProjection.set(batch.getProjectionMatrix());
    batch.setProjectionMatrix(camera.combined);
    batch.setTransformMatrix(emptyTransform);

    batch.begin();
    drawContent(batch, parentAlpha);
    batch.end();

    HdpiUtils.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    batch.setProjectionMatrix(prevProjection);
    batch.setTransformMatrix(prevTransform);
    batch.begin();

    super.draw(batch, parentAlpha);
}
 
Example 5
Source Project: Mundus   Source File: BasePicker.java    License: Apache License 2.0 4 votes vote down vote up
protected void begin(Viewport viewport) {
    fbo.begin();
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    HdpiUtils.glViewport(viewport.getScreenX(), viewport.getScreenY(), viewport.getScreenWidth(),
            viewport.getScreenHeight());
}