Ejemplo n.º 1
0
  public void paintGL() {
    synchronized (PAINT_LOCK) {
      try {
        DisplaySystem.getDisplaySystem().setCurrentCanvas(this);

        if (updateInput) InputSystem.update();

        if (!impl.isSetup()) {
          impl.doSetup();

          if (DisplaySystem.getDisplaySystem().getMinSamples() != 0
              && GLContext.getCapabilities().GL_ARB_multisample) {
            GL11.glEnable(ARBMultisample.GL_MULTISAMPLE_ARB);
          }
        }

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

        impl.doUpdate();

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

        impl.doRender();

        swapBuffers();
      } catch (LWJGLException e) {
        logger.log(Level.SEVERE, "Exception in paintGL()", e);
      }
    }
  }
Ejemplo n.º 2
0
  @Override
  protected void initializeWorld() {
    this.world = (World) DataManager.getInstance().getWorld(EWorld.Battle);
    this.world.setModelBound(new BoundingBox());
    this.world.updateModelBound();
    this.world.updateWorldBound();

    Callable<Void> exe =
        new Callable<Void>() {
          @Override
          public Void call() throws Exception {
            // initialize our environment code
            buildEnvironment();
            // kill the ambient on the sun/moon
            astronomy
                .getAstronomyLight()
                .getLightList()
                .get(0)
                .setAmbient(new ColorRGBA(.1f, .1f, .1f, 1));
            astronomy
                .getAstronomyLight()
                .getLightList()
                .get(1)
                .setAmbient(new ColorRGBA(.1f, .1f, .1f, 1));
            // start snowing
            environment.setWeather(EWeather.Snow, world);
            return null;
          }
        };
    GameTaskQueueManager.getManager().render(exe);
  }
Ejemplo n.º 3
0
 /** Change the visibility of the mouse cursor */
 private static void setCursorVisible(final boolean visible) {
   GameTaskQueueManager.getManager()
       .update(
           new Callable<Object>() {
             public Object call() throws Exception {
               MouseInput.get().setCursorVisible(visible);
               return null;
             }
           });
 }
Ejemplo n.º 4
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();
  }
Ejemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see java.lang.Thread#run()
   */
  @Override
  public void run() {
    logger.debug("UpdateThread started.");
    lasttick = timer.getTimeInSeconds();
    float currentTime = 0.0f;
    while (keepRunning) {
      lock.lock();
      currentTime = timer.getTimeInSeconds();
      float dt = (float) (currentTime - (lasttick + offset));
      offset = 0;
      GameTaskQueueManager.getManager().getQueue(GameTaskQueue.UPDATE).execute();
      sceneData.getRoomNode().updateGeometricState(dt, true);
      sceneData.getRootNode().updateGeometricState(dt, true);
      performCameraMotion();
      GameStateManager.getInstance().update(dt);
      if (!isPaused()) {
        sceneData.getCollisionHandler().update(dt);
        sceneData.getPhysicsSpace().update(dt);
      }
      TextOverlayManager.getInstance().update(dt);
      float timePassed = currentTime - lasttick;
      synchronized (repeatedActions) {
        for (RepeatedUpdateAction action : repeatedActions) {
          action.doUpdate(timePassed);
        }
      }

      if (sceneData.getRootNode() != null) {
        // TODO: should probably go away
        sceneData.getRootNode().updateRenderState();
      }
      lasttick = currentTime;
      fieldService.checkFields();
      lock.unlock();
      try {
        sleep(10);
      } catch (InterruptedException e) {
        // we can ignore this buddy
      }
      if (isPaused()) {
        offset += 0.001f;
      }
    }
    logger.debug("UpdateThread stopped.");
  }
Ejemplo n.º 6
0
  /*
   * (non-Javadoc)
   *
   * @see org.rifidi.designer.entities.interfaces.Switch#turnOn()
   */
  @Override
  public void turnOn() {
    GameTaskQueueManager.getManager()
        .update(
            new Callable<Object>() {

              /*
               * (non-Javadoc)
               *
               * @see java.util.concurrent.Callable#call()
               */
              @Override
              public Object call() throws Exception {
                getNode().clearRenderState(RenderState.RS_MATERIAL);
                getNode().setRenderState(msStarted);
                return null;
              }
            });
    running = true;
  }