Skip to content

Instantly share code, notes, and snippets.

@mariusk
Created October 5, 2013 11:45
Show Gist options
  • Save mariusk/6839875 to your computer and use it in GitHub Desktop.
Save mariusk/6839875 to your computer and use it in GitHub Desktop.
Vector2 size = Scaling.fit.apply(scene_width, scene_height, scr_width, scr_height);
int viewportX = (int)(scr_width - size.x) / 2;
int viewportY = (int)(scr_height - size.y) / 2;
int viewportWidth = (int) size.x;
int viewportHeight = (int) size.y;
Gdx.gl.glViewport(viewportX, viewportY, viewportWidth, viewportHeight);
stage.setViewport(scr_width, scr_height, true,
viewportX, viewportY, viewportWidth, viewportHeight);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment