/**
   * Sets a specified texture's OpenGL <code>Texture</code> parameters.
   *
   * @param dc the current draw context.
   * @param texture the texture whose parameters to set.
   */
  protected void setTextureParameters(DrawContext dc, Texture texture) {
    // Enable the appropriate mip-mapping texture filters if the caller has specified that
    // mip-mapping should be
    // enabled, and the texture itself supports mip-mapping.
    boolean useMipMapFilter =
        this.useMipMaps
            && (this.getTextureData().getMipmapData() != null
                || texture.isUsingAutoMipmapGeneration());

    GL gl = dc.getGL();
    gl.glTexParameteri(
        GL.GL_TEXTURE_2D,
        GL.GL_TEXTURE_MIN_FILTER,
        useMipMapFilter ? GL.GL_LINEAR_MIPMAP_LINEAR : GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);

    if (this.isUseAnisotropy() && useMipMapFilter) {
      double maxAnisotropy = dc.getGLRuntimeCapabilities().getMaxTextureAnisotropy();
      if (dc.getGLRuntimeCapabilities().isUseAnisotropicTextureFilter() && maxAnisotropy >= 2.0) {
        gl.glTexParameterf(
            GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, (float) maxAnisotropy);
      }
    }
  }
  protected void applyColor(DrawContext dc, java.awt.Color color, double opacity) {
    if (dc.isPickingMode()) return;

    double finalOpacity = opacity * (color.getAlpha() / 255.0);
    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
    OGLUtil.applyColor(gl, color, finalOpacity, true);
  }
Esempio n. 3
0
    protected void render(DrawContext dc, Vec4 p1, Vec4 p2, double radius) {
      // To compute the rotation of the cylinder axis to the orientation of the vector between the
      // two points,
      // this method performs the same operation as Vec4.axisAngle() but with a "v2" of <0, 0, 1>.

      // Compute rotation angle
      double length = p1.distanceTo3(p2);
      Vec4 u1 = new Vec4((p2.x - p1.x) / length, (p2.y - p1.y) / length, (p2.z - p1.z) / length);
      double angle = Math.acos(u1.z);

      // Compute the direction cosine factors that define the rotation axis
      double A = -u1.y;
      double B = u1.x;
      double L = Math.sqrt(A * A + B * B);

      GL gl = dc.getGL();

      // pushReferenceCenter performs the translation of the pipe's origin to point p1 and the
      // necessary
      // push/pop of the modelview stack. Otherwise we'd need to include a glPushMatrix and
      // gl.glTranslated(p1.x, p1.y, p1.z) above the rotation, and a corresponding glPopMatrix after
      // the
      // call to glCallIst.
      dc.getView().pushReferenceCenter(dc, p1);
      gl.glRotated(angle * TO_DEGREES, A / L, B / L, 0);
      gl.glScaled(
          radius, radius, length / 2); // length / 2 because cylinder is created with length 2
      dc.getGL().glCallList(this.glListId);
      dc.getView().popReferenceCenter(dc);
    }
Esempio n. 4
0
 /** {@inheritDoc} */
 public void render(DrawContext dc) {
   TreeLayout layout = this.getLayout();
   if (layout != null) {
     if (!dc.isOrderedRenderingMode()) dc.addOrderedRenderable(this);
     else layout.render(dc);
   }
 }
Esempio n. 5
0
  protected void setDepthFunc(DrawContext dc, OrderedIcon uIcon, Vec4 screenPoint) {
    GL gl = dc.getGL();

    if (uIcon.icon.isAlwaysOnTop()) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    Position eyePos = dc.getView().getEyePosition();
    if (eyePos == null) {
      gl.glDepthFunc(GL.GL_ALWAYS);
      return;
    }

    double altitude = eyePos.getElevation();
    if (altitude < (dc.getGlobe().getMaxElevation() * dc.getVerticalExaggeration())) {
      double depth = screenPoint.z - (8d * 0.00048875809d);
      depth = depth < 0d ? 0d : (depth > 1d ? 1d : depth);
      gl.glDepthFunc(GL.GL_LESS);
      gl.glDepthRange(depth, depth);
    } else if (uIcon.eyeDistance > uIcon.horizonDistance) {
      gl.glDepthFunc(GL.GL_EQUAL);
      gl.glDepthRange(1d, 1d);
    } else {
      gl.glDepthFunc(GL.GL_ALWAYS);
    }
  }
Esempio n. 6
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();
      }
    }
  }
  protected static boolean isTileVisible(
      DrawContext dc, Tile tile, double minDistanceSquared, double maxDistanceSquared) {
    if (!tile.getSector().intersects(dc.getVisibleSector())) return false;

    View view = dc.getView();
    Position eyePos = view.getEyePosition();
    if (eyePos == null) return false;

    Angle lat =
        clampAngle(
            eyePos.getLatitude(),
            tile.getSector().getMinLatitude(),
            tile.getSector().getMaxLatitude());
    Angle lon =
        clampAngle(
            eyePos.getLongitude(),
            tile.getSector().getMinLongitude(),
            tile.getSector().getMaxLongitude());
    Vec4 p = dc.getGlobe().computePointFromPosition(lat, lon, 0d);
    double distSquared = dc.getView().getEyePoint().distanceToSquared3(p);
    //noinspection RedundantIfStatement
    if (minDistanceSquared > distSquared || maxDistanceSquared < distSquared) return false;

    return true;
  }
 public void updateContext(DrawContext ctx) {
   Coloring c =
       (Coloring) stringMap.get(ctx.getBuffer(), ctx.getTokenOffset(), ctx.getTokenLength());
   if (c != null) {
     c.apply(ctx);
   }
 }
Esempio n. 9
0
  /**
   * Establish the OpenGL state needed to draw text.
   *
   * @param dc the current draw context.
   */
  protected void beginDrawing(DrawContext dc) {
    GL gl = dc.getGL();

    int attrMask =
        GL.GL_DEPTH_BUFFER_BIT // for depth test, depth mask and depth func
            | GL.GL_TRANSFORM_BIT // for modelview and perspective
            | GL.GL_VIEWPORT_BIT // for depth range
            | GL.GL_CURRENT_BIT // for current color
            | GL.GL_COLOR_BUFFER_BIT // for alpha test func and ref, and blend
            | GL.GL_DEPTH_BUFFER_BIT // for depth func
            | GL.GL_ENABLE_BIT; // for enable/disable changes

    this.BEogsh.pushAttrib(gl, attrMask);

    if (!dc.isPickingMode()) {
      gl.glEnable(GL.GL_BLEND);
      OGLUtil.applyBlending(gl, false);
    }

    // Do not depth buffer the label. (Labels beyond the horizon are culled above.)
    gl.glDisable(GL.GL_DEPTH_TEST);
    gl.glDepthMask(false);

    // The image is drawn using a parallel projection.
    this.BEogsh.pushProjectionIdentity(gl);
    gl.glOrtho(
        0d, dc.getView().getViewport().width, 0d, dc.getView().getViewport().height, -1d, 1d);

    this.BEogsh.pushModelviewIdentity(gl);
  }
Esempio n. 10
0
  /**
   * Draw labels for picking.
   *
   * @param dc Current draw context.
   * @param pickSupport the PickSupport instance to be used.
   */
  protected void doPick(DrawContext dc, PickSupport pickSupport) {
    GL gl = dc.getGL();

    Angle heading = this.rotation;

    double headingDegrees;
    if (heading != null) headingDegrees = heading.degrees;
    else headingDegrees = 0;

    int x = this.screenPoint.x;
    int y = this.screenPoint.y;

    boolean matrixPushed = false;
    try {
      if (headingDegrees != 0) {
        gl.glPushMatrix();
        matrixPushed = true;

        gl.glTranslated(x, y, 0);
        gl.glRotated(headingDegrees, 0, 0, 1);
        gl.glTranslated(-x, -y, 0);
      }

      for (int i = 0; i < this.lines.length; i++) {
        Rectangle2D bounds = this.lineBounds[i];
        double width = bounds.getWidth();
        double height = bounds.getHeight();

        x = this.screenPoint.x;
        if (this.textAlign.equals(AVKey.CENTER)) x = x - (int) (width / 2.0);
        else if (this.textAlign.equals(AVKey.RIGHT)) x = x - (int) width;
        y -= this.lineHeight;

        Color color = dc.getUniquePickColor();
        int colorCode = color.getRGB();
        PickedObject po = new PickedObject(colorCode, this.getPickedObject(), this.position, false);
        pickSupport.addPickableObject(po);

        // Draw line rectangle
        gl.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());

        try {
          gl.glBegin(GL.GL_POLYGON);
          gl.glVertex3d(x, y, 0);
          gl.glVertex3d(x + width - 1, y, 0);
          gl.glVertex3d(x + width - 1, y + height - 1, 0);
          gl.glVertex3d(x, y + height - 1, 0);
          gl.glVertex3d(x, y, 0);
        } finally {
          gl.glEnd();
        }

        y -= this.lineSpacing;
      }
    } finally {
      if (matrixPushed) {
        gl.glPopMatrix();
      }
    }
  }
  public void testMaliciousSetIcons() {
    // Create an Iterable with null elements.
    java.util.List<WWIcon> list = new java.util.ArrayList<WWIcon>();
    list.add(null);

    IconLayer layer =
        new IconLayer() {
          // Override to avoid View initialization issues.
          public boolean isLayerActive(DrawContext dc) {
            return true;
          }
        };
    layer.setIcons(list);

    DrawContext dc = new DrawContextImpl();
    dc.setModel(new BasicModel());
    dc.setView(new BasicOrbitView());

    try {
      // Test that the layer does not fail when the Iterable is used.
      layer.render(dc);
    } catch (NullPointerException e) {
      fail("Layer does not check for null elements in Iterable");
    }
  }
Esempio n. 12
0
  protected void initializeTexture(DrawContext dc) {
    Texture iconTexture = dc.getTextureCache().getTexture(this.getIconFilePath());
    if (iconTexture != null) return;

    try {
      InputStream iconStream = this.getClass().getResourceAsStream("/" + this.getIconFilePath());
      if (iconStream == null) {
        File iconFile = new File(this.iconFilePath);
        if (iconFile.exists()) {
          iconStream = new FileInputStream(iconFile);
        }
      }

      iconTexture = TextureIO.newTexture(iconStream, false, null);
      iconTexture.bind();
      this.iconWidth = iconTexture.getWidth();
      this.iconHeight = iconTexture.getHeight();
      dc.getTextureCache().put(this.getIconFilePath(), iconTexture);
    } catch (IOException e) {
      String msg = Logging.getMessage("layers.IOExceptionDuringInitialization");
      Logging.logger().severe(msg);
      throw new WWRuntimeException(msg, e);
    }

    GL gl = dc.getGL();
    gl.glTexParameteri(
        GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR); // _MIPMAP_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
    // Enable texture anisotropy, improves "tilted" world map quality.
    int[] maxAnisotropy = new int[1];
    gl.glGetIntegerv(GL.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy, 0);
    gl.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy[0]);
  }
  /**
   * Select the visible grid elements
   *
   * @param dc the current <code>DrawContext</code>.
   */
  protected void selectRenderables(DrawContext dc) {
    if (dc == null) {
      String message = Logging.getMessage("nullValue.DrawContextIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }
    Sector vs = dc.getVisibleSector();
    OrbitView view = (OrbitView) dc.getView();
    // Compute labels offset from view center
    Position centerPos = view.getCenterPosition();
    Double pixelSizeDegrees =
        Angle.fromRadians(
                view.computePixelSizeAtDistance(view.getZoom())
                    / dc.getGlobe().getEquatorialRadius())
            .degrees;
    Double labelOffsetDegrees = pixelSizeDegrees * view.getViewport().getWidth() / 4;
    Position labelPos =
        Position.fromDegrees(
            centerPos.getLatitude().degrees - labelOffsetDegrees,
            centerPos.getLongitude().degrees - labelOffsetDegrees,
            0);
    Double labelLatDegrees = labelPos.getLatitude().normalizedLatitude().degrees;
    labelLatDegrees = Math.min(Math.max(labelLatDegrees, -76), 78);
    labelPos =
        new Position(
            Angle.fromDegrees(labelLatDegrees), labelPos.getLongitude().normalizedLongitude(), 0);

    if (vs != null) {
      for (GridElement ge : this.gridElements) {
        if (ge.isInView(dc)) {
          if (ge.renderable instanceof GeographicText) {
            GeographicText gt = (GeographicText) ge.renderable;
            if (labelPos.getLatitude().degrees < 72
                || "*32*34*36*".indexOf("*" + gt.getText() + "*") == -1) {
              // Adjust label position according to eye position
              Position pos = gt.getPosition();
              if (ge.type.equals(GridElement.TYPE_LATITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        pos.getLatitude().degrees,
                        labelPos.getLongitude().degrees,
                        pos.getElevation());
              else if (ge.type.equals(GridElement.TYPE_LONGITUDE_LABEL))
                pos =
                    Position.fromDegrees(
                        labelPos.getLatitude().degrees,
                        pos.getLongitude().degrees,
                        pos.getElevation());

              gt.setPosition(pos);
            }
          }

          this.graticuleSupport.addRenderable(ge.renderable, GRATICULE_UTM);
        }
      }
      // System.out.println("Total elements: " + count + " visible sector: " + vs);
    }
  }
 public void updateContext(DrawContext ctx) {
   if (foreColor != null) {
     ctx.setForeColor(foreColor);
   }
   if (backColor != null) {
     ctx.setBackColor(backColor);
   }
 }
Esempio n. 15
0
 /**
  * Draw this label during ordered rendering.
  *
  * @param dc Current draw context.
  * @param pickSupport Support object used during picking.
  */
 protected void doDrawOrderedRenderable(DrawContext dc, PickSupport pickSupport) {
   TextRenderer textRenderer =
       OGLTextRenderer.getOrCreateTextRenderer(dc.getTextRendererCache(), font);
   if (dc.isPickingMode()) {
     this.doPick(dc, pickSupport);
   } else {
     this.drawText(dc, textRenderer);
   }
 }
  protected static boolean isServiceVisible(DrawContext dc, PlaceNameService placeNameService) {
    //noinspection SimplifiableIfStatement
    if (!placeNameService.isEnabled()) return false;

    return (dc.getVisibleSector() != null)
        && placeNameService.getMaskingSector().intersects(dc.getVisibleSector());
    //
    //        return
    // placeNameService.getExtent(dc).intersects(dc.getView().getFrustumInModelCoordinates());
  }
Esempio n. 17
0
  protected Angle computeIconRadius(DrawContext dc, double regionPixelSize, Sector drawSector) {
    double minCosLat =
        Math.min(drawSector.getMinLatitude().cos(), drawSector.getMaxLatitude().cos());
    if (minCosLat < 0.001) return Angle.POS180;

    Rectangle2D iconDimension = this.computeDrawDimension(regionPixelSize); // Meter
    double dLat = iconDimension.getHeight() / dc.getGlobe().getRadius();
    double dLon = iconDimension.getWidth() / dc.getGlobe().getRadius() / minCosLat;
    return Angle.fromRadians(Math.sqrt(dLat * dLat + dLon * dLon) / 2);
  }
    @SuppressWarnings({"RedundantIfStatement"})
    public boolean isInView(DrawContext dc) {
      if (!viewFrustum.intersects(this.getExtent(dc.getGlobe(), dc.getVerticalExaggeration())))
        return false;

      // Check apparent size
      if (getSizeInPixels(dc) <= MIN_CELL_SIZE_PIXELS) return false;

      return true;
    }
 public void updateContext(DrawContext ctx) {
   int pos = ctx.getFragmentOffset();
   if (pos >= blocks[curInd] && pos < blocks[curInd + 1]) {
     if (coloring == null) {
       coloring = ctx.getEditorUI().getColoring(SettingsNames.HIGHLIGHT_SEARCH_COLORING);
     }
     if (coloring != null) {
       coloring.apply(ctx);
     }
   }
 }
    public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
      int nextActivityOffset;
      coloring = null;

      if (mark == null) return false;

      if (ctx.getEditorUI().getComponent() == null || !mark.activateLayer) return false;

      BaseDocument doc = ctx.getEditorUI().getDocument();

      // Gets the active annotation attached to this mark. It is possible
      // that
      // no active annotation might exist for the mark
      AnnotationDesc anno = doc.getAnnotations().getActiveAnnotation(mark);
      if (anno == null) return false;

      int nextLineStart = -1;
      try {
        nextLineStart = Utilities.getRowStart(doc, ctx.getFragmentOffset(), 1);
      } catch (BadLocationException e) {
        return false;
      }
      if (nextLineStart < 0) { // end of doc
        nextLineStart = Integer.MAX_VALUE;
      }
      if (anno.isWholeLine()) {
        nextActivityOffset = nextLineStart;
      } else {
        nextActivityOffset = ctx.getFragmentOffset() + anno.getLength();
        if (nextActivityOffset > nextLineStart) nextActivityOffset = nextLineStart;
      }

      setNextActivityChangeOffset(nextActivityOffset);
      coloring = anno.getColoring();

      // The following code ensures that if active annotation does not
      // have highlight the color of next one will be used.
      // It was decided that it will not be used
      //
      // if (coloring.getBackColor() == null) {
      // AnnotationDesc[] annos =
      // doc.getAnnotations().getPasiveAnnotations(anno.getLine());
      // if (annos != null) {
      // for (int i=0; i<annos.length; i++) {
      // if (annos[i].getColoring().getBackColor() != null) {
      // coloring = annos[i].getColoring();
      // break;
      // }
      // }
      // }
      // }

      return true;
    }
  protected static boolean isNameVisible(
      DrawContext dc, PlaceNameService service, Position namePosition) {
    double elevation = dc.getVerticalExaggeration() * namePosition.getElevation();
    Vec4 namePoint =
        dc.getGlobe()
            .computePointFromPosition(
                namePosition.getLatitude(), namePosition.getLongitude(), elevation);
    Vec4 eyeVec = dc.getView().getEyePoint();

    double dist = eyeVec.distanceTo3(namePoint);
    return dist >= service.getMinDisplayDistance() && dist <= service.getMaxDisplayDistance();
  }
Esempio n. 22
0
  /**
   * Draws the graphic as an ordered renderable.
   *
   * @param dc the current draw context.
   */
  protected void makeOrderedRenderable(DrawContext dc) {
    if (this.lines == null || this.position == null) return;

    this.computeGeometryIfNeeded(dc);

    // Don't draw if beyond the horizon.
    double horizon = dc.getView().getHorizonDistance();
    if (this.eyeDistance > horizon) return;

    if (this.intersectsFrustum(dc)) dc.addOrderedRenderable(this);

    if (dc.isPickingMode()) this.pickLayer = dc.getCurrentLayer();
  }
Esempio n. 23
0
  @Override
  protected void doRender(DrawContext dc) {
    if (this.frameTimestamp != dc.getFrameTimeStamp()) {
      this.assembleControlPoints(dc);
      this.frameTimestamp = dc.getFrameTimeStamp();
    }

    this.markerRenderer.render(dc, this.controlPoints);

    if (this.annotation != null && isShowAnnotation()) {
      this.annotation.render(dc);
    }
  }
Esempio n. 24
0
  /**
   * Determine if this label intersects the view or pick frustum.
   *
   * @param dc Current draw context.
   * @return True if this label intersects the active frustum (view or pick). Otherwise false.
   */
  protected boolean intersectsFrustum(DrawContext dc) {
    View view = dc.getView();
    Frustum frustum = view.getFrustumInModelCoordinates();

    // Test the label's model coordinate point against the near and far clipping planes.
    if (this.placePoint != null
        && (frustum.getNear().distanceTo(this.placePoint) < 0
            || frustum.getFar().distanceTo(this.placePoint) < 0)) {
      return false;
    }

    if (dc.isPickingMode()) return dc.getPickFrustums().intersectsAny(this.screenExtent);
    else return view.getViewport().intersects(this.screenExtent);
  }
 public void init(DrawContext ctx) {
   if (enabled) {
     try {
       BaseDocument doc = ctx.getEditorUI().getDocument();
       blocks =
           FindSupport.getFindSupport()
               .getBlocks(blocks, doc, ctx.getStartOffset(), ctx.getEndOffset());
     } catch (BadLocationException e) {
       blocks = new int[] {-1, -1};
     }
     coloring = null; // reset so it will be re-read
     curInd = 0;
   }
 }
Esempio n. 26
0
  /**
   * Compute the lat/lon position of the view center
   *
   * @param dc the current DrawContext
   * @param view the current View
   * @return the ground position of the view center or null
   */
  protected Position computeGroundPosition(DrawContext dc, View view) {
    if (view == null) return null;

    Position groundPos =
        view.computePositionFromScreenPoint(
            view.getViewport().getWidth() / 2, view.getViewport().getHeight() / 2);
    if (groundPos == null) return null;

    double elevation =
        dc.getGlobe().getElevation(groundPos.getLatitude(), groundPos.getLongitude());
    return new Position(
        groundPos.getLatitude(),
        groundPos.getLongitude(),
        elevation * dc.getVerticalExaggeration());
  }
Esempio n. 27
0
  protected void endDrawIcons(DrawContext dc) {
    if (dc.isPickingMode()) this.pickSupport.endPicking(dc);

    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    if (dc.isPickingMode()) {
      gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_TEXTURE_ENV_MODE, OGLUtil.DEFAULT_TEX_ENV_MODE);
      gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_SRC0_RGB, OGLUtil.DEFAULT_SRC0_RGB);
      gl.glTexEnvf(GL2.GL_TEXTURE_ENV, GL2.GL_COMBINE_RGB, OGLUtil.DEFAULT_COMBINE_RGB);
    }

    gl.glBindTexture(GL.GL_TEXTURE_2D, 0);

    this.oglStackHandler.pop(gl);
  }
Esempio n. 28
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();
    }
  }
    public boolean isActive(DrawContext ctx, MarkFactory.DrawMark mark) {
      boolean active;
      if (mark != null) {
        active = mark.activateLayer;
      } else {
        JTextComponent c = ctx.getEditorUI().getComponent();
        active =
            (c != null)
                && c.getCaret().isSelectionVisible()
                && ctx.getFragmentOffset() >= c.getSelectionStart()
                && ctx.getFragmentOffset() < c.getSelectionEnd();
      }

      return active;
    }
 public double getSizeInPixels(DrawContext dc) {
   View view = dc.getView();
   Vec4 centerPoint =
       getSurfacePoint(dc, this.centroid.getLatitude(), this.centroid.getLongitude());
   Double distance = view.getEyePoint().distanceTo3(centerPoint);
   return this.size / view.computePixelSizeAtDistance(distance);
 }