예제 #1
0
  public void beginExecution() {
    if (cam == null) {

      int numBuffers = 2;

      env = GraphicsEnvironment.getLocalGraphicsEnvironment();
      device = env.getDefaultScreenDevice();
      // MultiBufferTest test = new MultiBufferTest(numBuffers, device);

      try {

        GraphicsConfiguration gc = device.getDefaultConfiguration();
        mainFrame = new Frame(gc);
        mainFrame.setUndecorated(true);
        mainFrame.setIgnoreRepaint(true);
        device.setFullScreenWindow(mainFrame);
        if (device.isDisplayChangeSupported()) {
          chooseBestDisplayMode(device);
        }
        mainFrame.createBufferStrategy(numBuffers);
        bufferStrategy = mainFrame.getBufferStrategy();

      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
예제 #2
0
 private static DisplayMode getBestDisplayMode(GraphicsDevice device) {
   for (int x = 0; x < BEST_DISPLAY_MODES.length; x++) {
     DisplayMode[] modes = device.getDisplayModes();
     for (int i = 0; i < modes.length; i++) {
       if (modes[i].getWidth() == BEST_DISPLAY_MODES[x].getWidth()
           && modes[i].getHeight() == BEST_DISPLAY_MODES[x].getHeight()
           && modes[i].getBitDepth() == BEST_DISPLAY_MODES[x].getBitDepth()) {
         return BEST_DISPLAY_MODES[x];
       }
     }
   }
   return null;
 }
예제 #3
0
 public void endExecution() {
   device.setFullScreenWindow(null);
 }
예제 #4
0
 public static void chooseBestDisplayMode(GraphicsDevice device) {
   DisplayMode best = getBestDisplayMode(device);
   if (best != null) {
     device.setDisplayMode(best);
   }
 }