Hi there,
I wrote a small active rendering loop that worked quite fast. But somehow I managed to get the thing broken and I have no idea what causes the trouble.
here’s the basic part of the loop:
//Constructor
public GameWindow(GraphicsDevice device, int userDefinedGameTicks) {
gd = device;
setUndecorated(true);
if (gd.isFullScreenSupported()) {
gd.setFullScreenWindow(this);
} else {
System.out.println("Fullscreen not supported");
System.exit(0);
}
DisplayMode[] dmodes = gd.getDisplayModes();
Config.readIni();
if (gd.isDisplayChangeSupported()) {
gd.setDisplayMode(dmodes[Config.getDm()]);
} else {
System.out.println("Displaymode not supported");
System.exit(0);
}
//debug information
System.out.println(getWidth());
System.out.println(getHeight());
createBufferStrategy(2);
bs = this.getBufferStrategy();
width = this.getWidth();
height = this.getHeight();
fTime = .00001;
timer = new AdvancedTimer();
gameticks_per_second = userDefinedGameTicks;
gametick_time = timer.getTicksPerSecond() / gameticks_per_second;
iLib.loadAllImages();
timer.start();
run();
}
public static void main(String[] args) {
System.setProperty("sun.java2d.translaccel", "true");
System.setProperty("sun.java2d.accthreshold", "0");
System.setProperty("sun.java2d.ddscale", "true");
System.setProperty("sun.java2d.ddforcevram", "true");
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
new GameWindow(device, 20);
}
The result is a white screen without any rendering. There’s this system-message:
“java.lang.IllegalArgumentException: Width (0) and height (600) cannot be <= 0”
So I checked the initial Desktop-Resolution (1600x1200) with a System.out… before I switch to the Loop-Resolution (which is bzw. 800x600)
And all I get is:
width: 0
height: 1200
really strange thing. any ideas??