示例#1
0
  @Override
  public void display(GLAutoDrawable drawable) {
    final int deltaTimeMs = local.getDeltaTimeMs();
    eventListeners.processEvents();

    GL2 gl = drawable.getGL().getGL2();
    final GLGraphics g = new GLGraphics(gl, local, true, deltaTimeMs);

    gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();
    gl.glTranslatef(0.375f, 0.375f, 0);

    float paddedWidth = getWidth() - padding.left - padding.right;
    float paddedHeight = getHeight() - padding.top - padding.bottom;
    g.move(padding.left, padding.right);

    if (dirty) {
      root.setBounds(0, 0, paddedWidth, paddedHeight);
      root.relayout();
      dirty = false;
    }

    // 1 pass: picking
    Runnable toRender =
        new Runnable() {
          @Override
          public void run() {
            root.renderPick(g);
          }
        };

    Vec2f mousePos = pickingManager.getCurrentMousePos();
    if (mousePos != null) {
      root.getMouseLayer()
          .setBounds(
              mousePos.x() - padding.left,
              mousePos.y() - padding.top,
              getWidth() - mousePos.x(),
              getHeight() - mousePos.y());
      root.getMouseLayer().relayout();
    }
    pickingManager.doPicking(g.gl, toRender);

    // 2. pass: layout
    root.layout(deltaTimeMs);

    // 3. pass: rendering
    if (renderPick) root.renderPick(g);
    else root.render(g);

    g.move(-padding.left, -padding.right);
  }
示例#2
0
 @Override
 public Vec2f toRelative(Vec2f absolute) {
   absolute.sub(new Vec2f(padding.left, padding.top));
   return absolute;
 }
示例#3
0
 @Override
 public Vec2f toAbsolute(Vec2f relative) {
   relative.add(new Vec2f(padding.left, padding.top));
   return relative;
 }