コード例 #1
0
  private void selectionDraw(GL10 glUnused) {
    setFBO(glUnused, true);

    if (layers == null) {
      return;
    }
    synchronized (layers) {
      for (Layer layer : getLayers()) {
        if (layer.isEnabled() && (layer instanceof SelectableLayer)) {
          camera.pushM();
          if (layer instanceof TfLayer) {
            GraphName layerFrame = ((TfLayer) layer).getFrame();
            if (layerFrame != null) {
              Transform t =
                  Utility.newTransformIfPossible(
                      frameTransformTree, layerFrame, camera.getFixedFrame());
              camera.applyTransform(t);
            }
          }
          ((SelectableLayer) layer).selectionDraw(glUnused);
          camera.popM();
        }
      }
    }

    // is THIS your card?
    ByteBuffer colorBuf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder());
    colorBuf.position(0);
    Point selected = camera.getSelectionManager().getSelectionCoordinates();
    selected.set(selected.x, (camera.getViewport().getHeight() - selected.y));
    GLES20.glReadPixels(
        selected.x, selected.y, 1, 1, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, colorBuf);
    colorBuf.position(0);
    Color selectedColor =
        new Color(
            (colorBuf.get() & 0xff) / 255f,
            (colorBuf.get() & 0xff) / 255f,
            (colorBuf.get() & 0xff) / 255f,
            1f);
    camera.getSelectionManager().selectItemWithColor(selectedColor);

    setFBO(glUnused, false);
  }
コード例 #2
0
 private void drawLayers(GL10 glUnused) {
   if (layers == null) {
     return;
   }
   synchronized (layers) {
     for (Layer layer : getLayers()) {
       if (layer.isEnabled()) {
         camera.pushM();
         if (layer instanceof TfLayer) {
           GraphName layerFrame = ((TfLayer) layer).getFrame();
           if (layerFrame != null) {
             Transform t =
                 Utility.newTransformIfPossible(
                     frameTransformTree, layerFrame, camera.getFixedFrame());
             camera.applyTransform(t);
           }
         }
         layer.draw(glUnused);
         camera.popM();
       }
     }
   }
 }