コード例 #1
0
  public static void setBoundElementVBO(final RendererRecord rendRecord, final int id) {
    final GL gl = GLContext.getCurrentGL();

    if (!rendRecord.isElementVboValid() || rendRecord.getCurrentElementVboId() != id) {
      gl.glBindBuffer(GL.GL_ELEMENT_ARRAY_BUFFER, id);
      rendRecord.setCurrentElementVboId(id);
      rendRecord.setElementVboValid(true);
    }
  }
コード例 #2
0
  public static void applyScissors(final RendererRecord rendRecord) {
    final GL gl = GLContext.getCurrentGL();
    final Stack<ReadOnlyRectangle2> clips = rendRecord.getScissorClips();

    if (clips.size() > 0) {
      final Rectangle2 init = Rectangle2.fetchTempInstance();
      init.set(-1, -1, -1, -1);
      ReadOnlyRectangle2 r;
      boolean first = true;
      for (int i = clips.size(); --i >= 0; ) {
        r = clips.get(i);

        if (r == null) {
          break;
        }
        if (first) {
          init.set(r);
          first = false;
        } else {
          init.intersect(r, init);
        }
        if (init.getWidth() <= 0 || init.getHeight() <= 0) {
          init.setWidth(0);
          init.setHeight(0);
          break;
        }
      }

      if (init.getWidth() == -1) {
        setClippingEnabled(rendRecord, false);
      } else {
        setClippingEnabled(rendRecord, true);
        gl.glScissor(init.getX(), init.getY(), init.getWidth(), init.getHeight());
      }
      Rectangle2.releaseTempInstance(init);
    } else {
      // no clips, so disable
      setClippingEnabled(rendRecord, false);
    }
  }
コード例 #3
0
 GL2 gl() {
   if (gl == null) {
     gl = GLContext.getCurrentGL().getGL2();
   }
   return gl;
 }
コード例 #4
-1
  public static void setClippingEnabled(final RendererRecord rendRecord, final boolean enabled) {
    final GL gl = GLContext.getCurrentGL();

    if (enabled && (!rendRecord.isClippingTestValid() || !rendRecord.isClippingTestEnabled())) {
      gl.glEnable(GL.GL_SCISSOR_TEST);
      rendRecord.setClippingTestEnabled(true);
    } else if (!enabled
        && (!rendRecord.isClippingTestValid() || rendRecord.isClippingTestEnabled())) {
      gl.glDisable(GL.GL_SCISSOR_TEST);
      rendRecord.setClippingTestEnabled(false);
    }
    rendRecord.setClippingTestValid(true);
  }