# How do you make a ShapeRenderer always full screen on resize?

I have:

shapeRenderer.setProjectionMatrix(stage.getViewport().getCamera().combined);


And I tried to do the following in render():

shapeRenderer.rect(0, 0, stage.getViewport().getScreenWidth(), stage.getViewport.getScreenHeight());


Which full-screens the ShapeRenderer when I first run my project, but as soon as I resize the window, the rectangle starts to change size and go off-screen. I'm using a FitViewport on my Stage, is there any way to make the ShapeRenderer always be full screen?

You should use the methods getWorldWidth and getWorldHeight instead of the screen counterparts. "World" is the emulated size of the viewport while "screen" is your actual screen size.
• Lucky call? You should actually give it the matrix you want to draw to. So if you have a camera for viewing the map and want to use shapeRenderer.setProjectionMatric(worldCamera.combined). If you want to use it on your fixed screen gui that's using the stage then getting the camera from the stage is perfectly fine. Just make sure you use resize() properly. – Madmenyo Feb 14 '18 at 15:21
• @Madmenyo They are setting the projection matrix (read: shapeRenderer.setProjectionMatrix(stage.getViewport().getCamera().combined);). And that is exactly why it's the wrong size. They cannot use the size of the screen since that is not in sync with the size of the viewport unless the viewport is a ScreenViewport. – Charanor Feb 14 '18 at 15:49