Am I making my window correctly?

Here’s the link to my source so you can see what I’m doing in setting up a window. The important method is the init() method.

http://www.gamelizard.com/com/RimscapeRunner.java

My problems are that sometimes when going to fullscreen mode, a white screen shows up and no graphics ever get drawn to it. Also fullscreen mode is much slower at drawing than windowed mode when generally I hear people saying that fullscreen mode should be faster.

Thanks for any help!

Anyone? please? :slight_smile:

pretty pretty please? Someone? Anyone? How does one properly set up an accelerated fullscreen application? Could I at least be redirected toward a good tutorial that covers this?

Have you looked at the source from Brackeen’s book to see how your’s differs?

Dr. A>

Thanks for that link! I tried out using the JFrame as he had it set up, and I think it’s creating fullscreen mode fine with no mishaps, but it’s still slower. Running windowed at 1024x768 yields a pretty constant 100fps. 1024x768 fullscreen gets about 50fps. That’s really weird. I tried printing the trace in both cases and it seems that everything is working the same as far as I can tell. Any ideas of what could be going wrong?

1024x768 fullscreen gets about 50fps.

Well, it’s vsynced in fullscreen mode… so the maximum framerate equals hz.

Since you say 1024x768 and 50fps… I guess you’re using a tft display right? :slight_smile:

JFrame’s don’t create their insets until after I pack the canvas on it, whereas Frames have them created when they’re made. That’s created a new and confusing problem with setting a maximized window. Here’s the code I now use to figure out how much room I have to draw on for my game:


Rectangle bounds = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();

//because you can't add a canvas with size 0,0 because the JFrame will get angry
canvas.setSize((int)bounds.getWidth(), (int)bounds.getHeight());

panel.add(canvas);
frame.pack();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);

Insets insets = frame.getInsets();
bounds.setFrame(bounds.getX(), bounds.getY(),
        bounds.getWidth(),
        bounds.getHeight() - insets.top + insets.bottom
);

canvas.setSize((int)bounds.getWidth(), (int)bounds.getHeight());

//Here's what my game logic will use
GAME_WIDTH = canvas.getWidth();
GAME_HEIGHT = canvas.getHeight();

And now everything works dandy, and it appears that with the JFrame change, both Windowed and Fullscreen modes are accelerated and now Fullscreen is SLIGHLTY faster for me than windowed mode. Neat!

Thank you oNyx for your direction :slight_smile: