NOTE: I am moving this question here from Stack Overflow because I feel it belongs better on this forum. I am deleting the original question from Stack Overflow.

I'm working on a game in Slick2D and I want to have some versatility with the resolutions I can use for fullscreen. Is there a way to make the game's fullscreen add black bars around the game instead of stretching the game to whatever resolution the graphics card can support for fullscreen? I'm not terribly familiar with openGL so if the only way to fix that requires openGL, I would appreciate some detailed explanation on how to implement the code. Currently I'm using the

arg0.setDisplayMode(X_resolution, Y_resolution, true); //arg0 is my AppGameContainer

method. But it means I have to stretch my game to one of the compatible resolutions.


Just call the render function and draw a filling black rectangle on your screen.

public void render(GameContainer arg0, Graphics arg1) throws SlickException {

    arg1.fillRect   (   0.0f,


Then all you need to do is set up a clipping area for the rest you're rendering:

g.setWorldClip((int) x, (int) y, (int) width, (int) height);

That way anything outside that area won't be rendered. Voilà!

  • \$\begingroup\$ Thank you, it worked beautifully (after making sure it centered everything of course, but that part is just some division). \$\endgroup\$
    – Ryuluce
    Jan 13 '16 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.