I just discovered the same issue. I didn't notice until now because I was either starting out directly in window mode or directly in full screen mode with ScalableGame. As long as you do that, everything looks fine. But, if you set up your application to toggle between window mode and full screen mode, your issue occurs. This should be listed as a bug.
Edit: The cause appears to be because ScalableGame works out the amount of scaling and the amount of black padding in the init() method. There should be a way to force it recompute those values.
Edit 2: As an experiment, I copied the code of ScalableGame into ScalableGame2 and I added this method:
Code:
public void containerSizeChanged(GameContainer container) {
targetWidth = container.getWidth();
targetHeight = container.getHeight();
if (maintainAspect) {
boolean normalIsWide = (normalWidth / normalHeight > 1.6 ? true : false);
boolean containerIsWide = ((float) targetWidth
/ (float) targetHeight > 1.6 ? true : false);
float wScale = targetWidth / normalWidth;
float hScale = targetHeight / normalHeight;
if (normalIsWide & containerIsWide) {
float scale = (wScale < hScale ? wScale : hScale);
targetWidth = (int) (normalWidth * scale);
targetHeight = (int) (normalHeight * scale);
} else if (normalIsWide & !containerIsWide) {
targetWidth = (int) (normalWidth * wScale);
targetHeight = (int) (normalHeight * wScale);
} else if (!normalIsWide & containerIsWide) {
targetWidth = (int) (normalWidth * hScale);
targetHeight = (int) (normalHeight * hScale);
} else {
float scale = (wScale < hScale ? wScale : hScale);
targetWidth = (int) (normalWidth * scale);
targetHeight = (int) (normalHeight * scale);
}
}
container.getInput().setScale(normalWidth / targetWidth,
normalHeight / targetHeight);
int yoffset = 0;
int xoffset = 0;
if (targetHeight < container.getHeight()) {
yoffset = (container.getHeight() - targetHeight) / 2;
}
if (targetWidth < container.getWidth()) {
xoffset = (container.getWidth() - targetWidth) / 2;
}
container.getInput().setOffset(-xoffset / (targetWidth / normalWidth),
-yoffset / (targetHeight / normalHeight));
}
I maintain a reference to both the AppGameContainer and the ScalableGame2 with my game class. After changing the size with the methods of AppGameContainer, I call the above method. This hack works quite well.