# LibGDX full screen display mode and camera resize

I'm creating a simple 2D platformer and I have problem with my camera y position when I enter full screen mode. But first here's my code

screenY = Gdx.graphics.getHeight();

public void updateCamera(){
camera.position.x += (player1.getHitBox().x - camera.position.x);
if(screenY < player1.getHitBox().getY() && player1.getHitBox().getY() > (screenY - Gdx.graphics.getHeight())){
screenChanger++;
}else if(player1.getHitBox().getY() < (screenY - Gdx.graphics.getHeight())){
screenChanger--;
}
screenY = Gdx.graphics.getHeight() * screenChanger;
camera.position.y = (screenY - screenY/2);
camera.update();

System.out.println(Gdx.graphics.getHeight() + " " + screenY);
}


So here's my results: 1) When I start the game all works fine

2) But when I enter to fullscreen here what I get

3) here how it looks when I zoom out my camera

• Have a read through this. Apr 26 '15 at 21:11

## 1 Answer

When you "enter full-screen", the base window's border is removed and it is re-sized and moved such that its' ClientBounds == ScreenBounds. When this occurs, the Device is destroyed ("lost"), and needs to be recreated. At the same time, the back-buffer and any other textures or rendertargets that should be "full-screen" must also be re-created with the new size. Recreating them with the wrong dimensions will cause magnification and/or minification artifacts (pixelation, looking "crushed" or "smushed", etc.).

As a function of re-sizing the rendertargets, the gl_Viewport describing the portion of the render target to use may also need to be updated.

As a function of updating the Viewport, the Camera may also need to use different matrices. For 2D, the View matrix is typically Identity, so you really only need to update the camera's Projection to fit "more world" into the texture. The World matrix is still just World.

LibGDX wraps all of the above into the Viewport class (low-level usage details).

Have a read through this (high-level usage details). – StrongJoshua

• Thanks! But still I have some scaling problems or others I don't know because then my background position is still bad... Apr 28 '15 at 19:51
• @user3334375, please add an updated screenshot.
– Jon
May 3 '15 at 6:47