Before anyone suggests it, i have seen this post. It doesn’t provide a solution to my problem, even though it seems to be the exact same behavior that i’m getting.
My program works great in 32bit XP, however on 64bit win7 and vista OS’s, it refuses to display correctly. Upon startup, it appears to clear the screen and draw normally for one frame, then just shows a white screen. I’ve been testing this pretty extensively, and found these things out.
- The animator is running, and the game is updating.
- It’s not a buffering problem, it doesn’t work with any mix of double, triple, or single buffering.
- It’s not a vsync problem, tried it with and without vsync.
- The width/height of the canvas and screen are all correct, i don’t mess with layouts or managers, just absolute positioning.
- The displaymode is correct, i don’t even bother changing it, just reading values from it. (read: not creating new ones). I have, in the past, tried setting the displaymode, but it appears unrelated to the problem.
- Libraries are, of course, all being references and linked correctly. The program runs with no exceptions, eaten or otherwise.
What’s worse is that if i alt-tab out of the game, and go back in, it will again display exactly one frame of the game, and then go back to a blank white screen.
public class ScreenManager extends Frame
{
// ... variables
public ScreenManager()
{
super("Game");
setLayout(null);
// specifically to let the game know if the window is closed natively
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
VMain.exit();
}
});
setFullscreen();
setupJOGL();
hideCursor();
// must put canvas in spotlight, since it gets focus.
canvas.requestFocus();
setVisible(true);
canvas.createBufferStrategy(2);
// double buffer created -after- visible, didn't help.
}
private void setFullscreen()
{// sets to fullscreen mode.
DisplayMode mode;
device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
mode = device.getDisplayMode();
// just some global variables, nothing special is done here.
setResolution(mode.getWidth(), mode.getHeight());
COLOR_BITS = mode.getBitDepth();
HERTZ = mode.getRefreshRate();
setUndecorated(true);
setIgnoreRepaint(true);
setResizable(false);
pack();
device.setFullScreenWindow(this);
}
private void hideCursor()
{
setCursor(Toolkit.getDefaultToolkit().createCustomCursor(Toolkit.getDefaultToolkit().getImage(""), new Point(0, 0), "invis"));
}
private void showCursor()
{
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
private void setupJOGL()
{
GLCapabilities caps;
Animator an;
caps = new GLCapabilities();
renderer = new VRenderer();
caps.setDoubleBuffered(true);
caps.setHardwareAccelerated(true);
canvas = new GLCanvas(caps);
canvas.addGLEventListener(renderer);
canvas.setBounds(0, 0, RESOLUTION_X, RESOLUTION_Y);
add(canvas);
an = new Animator(canvas);
an.setRunAsFastAsPossible(true);
an.start();
}
I’ll stress that it works great in XP, and that the fault doesn’t seem to be with the renderer code, but probably something with how i’m making the window.
I’m open to any wild ideas, i think i’ve exhausted the normal line of thought on this, so if anyone has any weird ideas or insight i’m definitely willing to listen.