예제 #1
0
  protected void applyBackground(
      DrawContext dc,
      WWIcon icon,
      Vec4 screenPoint,
      double width,
      double height,
      double pedestalSpacing,
      double pedestalScale) {
    GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.

    double backgroundScale;
    backgroundScale = icon.getBackgroundScale();

    if (icon.getBackgroundTexture() != null) {
      if (icon.getBackgroundTexture().bind(dc)) {
        TextureCoords texCoords = icon.getBackgroundTexture().getTexCoords();
        gl.glPushMatrix();
        gl.glLoadIdentity();
        double bgwidth = backgroundScale * width;
        double bgheight = backgroundScale * height;
        // Offset the background for the highlighted scale.
        // if (icon.isHighlighted())
        // {
        //    gl.glTranslated(0d, height * (icon.getHighlightScale() - 1) / 2, 0d);
        // }
        // Offset the background for the pedestal height.
        gl.glTranslated(0d, (pedestalScale * height) + pedestalSpacing, 0d);
        // Place the background centered behind the icon.
        gl.glTranslated(screenPoint.x - bgwidth / 2, screenPoint.y - (bgheight - height) / 2, 0d);
        // Scale to the background image dimension.
        gl.glScaled(bgwidth, bgheight, 1d);
        dc.drawUnitQuad(texCoords);
        gl.glPopMatrix();
      }
    }
  }