Ejemplo n.º 1
0
  public void update(GL glGeneric) {
    if (!init) return;

    GL2 gl = glGeneric.getGL2();
    contentManager.update(gl);
    ui.update(gl, elapsedMS);
    world.update(gl, elapsedMS, ui);
    drawings.update();
  }
Ejemplo n.º 2
0
  @Override
  public void dispose(GLAutoDrawable drawable) {
    GL gl = drawable.getGL();

    if (netManager != null) netManager.shutdown();
    if (world != null) world.dispose(gl);
    if (renderer != null) renderer.dispose(gl);
    if (contentManager != null) contentManager.dispose(gl);
  }
Ejemplo n.º 3
0
  @Override
  public void init(GLAutoDrawable drawable) {
    GL2 gl = drawable.getGL().getGL2();

    if (!init) { // print OpenGL renderer info
      glInfo = new GLInfo(drawable.getGL());
      glInfo.print();
    }

    // initialize / load content
    contentManager = new ContentManager(config.teamColors);
    if (!contentManager.init(drawable, glInfo)) {
      exitError("Problems loading resource files!");
    }

    SceneGraph oldSceneGraph = null;
    if (init) oldSceneGraph = world.getSceneGraph();
    world = new WorldModel();
    world.init(drawable.getGL(), contentManager, config, mode);
    drawings = new Drawings();
    ui = new UserInterface(this, drawingFilter);

    if (mode == Mode.LIVE) {
      netManager = new NetworkManager();
      netManager.init(this, config);
      netManager.getServer().addChangeListener(world.getGameState());
    } else {
      if (!init) logPlayer = new LogPlayer(logFile, world, config, this);
      else logPlayer.setWorldModel(world);
    }

    ui.init();
    renderer = new Renderer(this);
    renderer.init(drawable, contentManager, glInfo);

    if (init && oldSceneGraph != null) world.setSceneGraph(oldSceneGraph);
    world.addSceneGraphListener(contentManager);

    gl.glClearColor(0, 0, 0, 1);
    init = true;
  }