/**
   * Draws text for subsequent Label ordered renderables in the ordered renderable list. This method
   * is called after the text renderer has been set up (after beginRendering has been called), so
   * this method can only draw text for subsequent labels that use the same font and rotation as
   * this label. This method differs from {@link #drawBatched(gov.nasa.worldwind.render.DrawContext)
   * drawBatched} in that this method reuses the active text renderer context to draw as many labels
   * as possible without switching text renderer state.
   *
   * @param dc the current draw context.
   * @param textRenderer Text renderer used to draw the label.
   */
  protected void drawBatchedText(DrawContext dc, TextRenderer textRenderer) {
    // Draw as many as we can in a batch to save ogl state switching.
    Object nextItem = dc.peekOrderedRenderables();

    if (!dc.isPickingMode()) {
      while (nextItem != null && nextItem instanceof TacticalGraphicLabel) {
        TacticalGraphicLabel nextLabel = (TacticalGraphicLabel) nextItem;
        if (!nextLabel.isEnableBatchRendering()) break;

        boolean sameFont = this.font.equals(nextLabel.getFont());
        boolean sameRotation =
            (this.rotation == null && nextLabel.rotation == null)
                || (this.rotation != null && this.rotation.equals(nextLabel.rotation));
        boolean drawInterior = nextLabel.isDrawInterior();

        // We've already set up the text renderer state, so we can can't change the font or text
        // rotation.
        // Also can't batch render if the next label needs an interior since that will require
        // tearing down the
        // text renderer context.
        if (!sameFont || !sameRotation || drawInterior) break;

        dc.pollOrderedRenderables(); // take it off the queue
        nextLabel.doDrawText(textRenderer);

        nextItem = dc.peekOrderedRenderables();
      }
    }
  }
  /**
   * Draws this ordered renderable and all subsequent Label ordered renderables in the ordered
   * renderable list. This method differs from {@link
   * #drawBatchedText(gov.nasa.worldwind.render.DrawContext, TextRenderer) drawBatchedText} in that
   * this method re-initializes the text renderer to draw the next label, while {@code
   * drawBatchedText} re-uses the active text renderer context. That is, {@code drawBatchedText}
   * attempts to draw as many labels as possible that share same text renderer configuration as this
   * label, and this method attempts to draw as many labels as possible regardless of the text
   * renderer configuration of the subsequent labels.
   *
   * @param dc the current draw context.
   */
  protected void drawBatched(DrawContext dc) {
    // Draw as many as we can in a batch to save ogl state switching.
    Object nextItem = dc.peekOrderedRenderables();

    if (!dc.isPickingMode()) {
      while (nextItem != null && nextItem instanceof TacticalGraphicLabel) {
        TacticalGraphicLabel nextLabel = (TacticalGraphicLabel) nextItem;
        if (!nextLabel.isEnableBatchRendering()) break;

        dc.pollOrderedRenderables(); // take it off the queue
        nextLabel.doDrawOrderedRenderable(dc, this.pickSupport);

        nextItem = dc.peekOrderedRenderables();
      }
    } else if (this.isEnableBatchPicking()) {
      while (nextItem != null && nextItem instanceof TacticalGraphicLabel) {
        TacticalGraphicLabel nextLabel = (TacticalGraphicLabel) nextItem;
        if (!nextLabel.isEnableBatchRendering() || !nextLabel.isEnableBatchPicking()) break;

        if (nextLabel.pickLayer != this.pickLayer) // batch pick only within a single layer
        break;

        dc.pollOrderedRenderables(); // take it off the queue
        nextLabel.doDrawOrderedRenderable(dc, this.pickSupport);

        nextItem = dc.peekOrderedRenderables();
      }
    }
  }
Example #3
0
  protected void drawIconsInBatch(DrawContext dc, OrderedIcon uIcon) {
    this.drawIcon(dc, uIcon);

    // Draw as many as we can in a batch to save ogl state switching.
    Object nextItem = dc.peekOrderedRenderables();
    while (nextItem != null && nextItem instanceof OrderedIcon) {
      OrderedIcon oi = (OrderedIcon) nextItem;
      if (oi.getRenderer() != this) return;

      dc.pollOrderedRenderables(); // take it off the queue
      this.drawIcon(dc, oi);

      nextItem = dc.peekOrderedRenderables();
    }
  }
Example #4
0
  protected void pickIconsInBatch(DrawContext dc, OrderedIcon uIcon) {
    this.drawIcon(dc, uIcon);

    // Draw as many as we can in a batch to save ogl state switching.
    // Note that there's a further qualification here than in render(): only items associated with
    // the
    // same layer can be batched because the pick resolution step at the end of batch rendering
    // associates the item's layer with the resolved picked object.
    Object nextItem = dc.peekOrderedRenderables();
    while (nextItem != null
        && nextItem instanceof OrderedIcon
        && ((OrderedIcon) nextItem).layer == uIcon.layer) {
      OrderedIcon oi = (OrderedIcon) nextItem;
      if (oi.getRenderer() != this) return;

      dc.pollOrderedRenderables(); // take it off the queue
      this.drawIcon(dc, oi);

      nextItem = dc.peekOrderedRenderables();
    }
  }