Пример #1
0
  @Override
  protected void initGL() {

    if (glInitialized) {
      return;
    }
    glInitialized = true;

    try {
      LWJGLDisplaySystem display = (LWJGLDisplaySystem) DisplaySystem.getDisplaySystem();
      display.switchContext(this);

      // Complete canvas configuration.
      Dimension size = this.getSize();
      display.initForCanvas(size.width, size.height);

      impl.doSetup();

      if (display.getMinSamples() != 0 && GLContext.getCapabilities().GL_ARB_multisample) {
        GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
      }
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Exception in initGL()", e);
    }
  }
Пример #2
0
  @Override
  protected void paintGL() {

    try {
      ((LWJGLDisplaySystem) DisplaySystem.getDisplaySystem()).switchContext(this);

      if (updateInput) {
        InputSystem.update();
      }

      GameTaskQueueManager.getManager().getQueue(GameTaskQueue.UPDATE).execute();

      impl.doUpdate();

      if (!drawWhenDirty || dirty) {
        GameTaskQueueManager.getManager().getQueue(GameTaskQueue.RENDER).execute();

        impl.doRender();

        swapBuffers();
        dirty = false;
      }
    } catch (LWJGLException e) {
      logger.log(Level.SEVERE, "Exception in paintGL()", e);
    }

    // sync
    if (syncRate > 0) {
      long sinceLast = System.nanoTime() - lastRender;
      if (sinceLast < syncNS) {
        try {
          Thread.sleep((Math.round((syncNS - sinceLast) / 1000000L)));
        } catch (InterruptedException e) {
        }
      }
      lastRender = System.nanoTime();
    }

    repaint();
  }
Пример #3
0
 public void setBackground(Color bgColor) {
   impl.setBackground(makeColorRGBA(bgColor));
 }