Пример #1
0
  /**
   * 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();
      }
    }
  }
Пример #2
0
  /**
   * 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();
      }
    }
  }