예제 #1
0
  @Override
  public void start() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    gd = ge.getDefaultScreenDevice();

    if (!gd.isFullScreenSupported()) {
      onError("Full-screen exclusive mode not supported");
      System.exit(0);
    }
    // switch on FSEM
    //        gd.setFullScreenWindow(window);

    window.setVisible(true);

    renderThread.start();
    updateThread.start();
    inputThread.start();
  }
예제 #2
0
  @Override
  public void render() {
    if (!window.isFocused()) {
      return;
    }
    // Render single frame
    do {
      // The following loop ensures that the contents of the drawing buffer
      // are consistent in case the underlying surface was recreated
      do {
        // Get a new graphics context every time through the loop
        // to make sure the strategy is validated
        Graphics2D g2 = (Graphics2D) strategy.getDrawGraphics();

        // Clear rect
        g2.clearRect(0, 0, window.getWidth(), window.getHeight());
        // Render to graphics
        gsm.render(g2);
        // ...

        if (SHOW_INFO) {
          g2.setPaint(Color.WHITE);
          g2.drawString(renderThread.report(), 900, 18);
          g2.drawString(updateThread.report(), 1100, 18);
        }

        // Dispose the graphics
        g2.dispose();

        // Repeat the rendering if the drawing buffer contents
        // were restored
      } while (strategy.contentsRestored());

      // Display the buffer
      strategy.show();

      // Repeat the rendering if the drawing buffer was lost
    } while (strategy.contentsLost());
  }
예제 #3
0
 /** This method closes the GUI. */
 public void close() {
   updateThread.stop();
   connector.setRunning(false);
   connector.stop();
 }