NASA World Wind

gov.nasa.worldwind.util
Class OGLUtil

java.lang.Object
  extended by gov.nasa.worldwind.util.OGLUtil

public class OGLUtil
extends java.lang.Object

A collection of OpenGL utility methods, all static.


Field Summary
protected static Vec4 DEFAULT_LIGHT_DIRECTION
           
protected static boolean DEFAULT_USE_PREMULTIPLIED_COLORS
           
protected static java.lang.String EXT_BLEND_FUNC_SEPARATE_STRING
           
 
Constructor Summary
OGLUtil()
           
 
Method Summary
static void applyBlending(javax.media.opengl.GL gl)
          Sets the GL blending state for colors premultiplied by the alpha component.
static void applyBlending(javax.media.opengl.GL gl, boolean isPremultipliedAlpha)
          Sets the GL blending state according to the specified color mode.
static void applyColor(javax.media.opengl.GL gl, java.awt.Color color)
          Sets the GL color state to the specified Color.
static void applyColor(javax.media.opengl.GL gl, java.awt.Color color, boolean premultiply)
          Sets the GL color state to the specified Color, and with the specified color mode.
static void applyColor(javax.media.opengl.GL gl, java.awt.Color color, double opacity)
          Sets the GL color state to the specified Color and opacity.
static void applyColor(javax.media.opengl.GL gl, java.awt.Color color, double opacity, boolean premultiply)
          Sets the GL color state to the specified Color and opacity, and with the specified color mode.
static void applyLightingDirectionalFromViewer(javax.media.opengl.GL gl, int light)
          Sets the GL lighting state to a white light originating from the eye position and pointed directly along the forward vector form the eye point
static void applyLightingDirectionalFromViewer(javax.media.opengl.GL gl, int light, Vec4 direction)
          Sets the GL lighting state to a white light originating from the eye position and pointed in the specified direction, in model coordinates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LIGHT_DIRECTION

protected static final Vec4 DEFAULT_LIGHT_DIRECTION

DEFAULT_USE_PREMULTIPLIED_COLORS

protected static final boolean DEFAULT_USE_PREMULTIPLIED_COLORS
See Also:
Constant Field Values

EXT_BLEND_FUNC_SEPARATE_STRING

protected static final java.lang.String EXT_BLEND_FUNC_SEPARATE_STRING
See Also:
Constant Field Values
Constructor Detail

OGLUtil

public OGLUtil()
Method Detail

applyBlending

public static void applyBlending(javax.media.opengl.GL gl)
Sets the GL blending state for colors premultiplied by the alpha component.

Parameters:
gl - the GL context.
Throws:
java.lang.IllegalArgumentException - if the GL is null.

applyBlending

public static void applyBlending(javax.media.opengl.GL gl,
                                 boolean isPremultipliedAlpha)
Sets the GL blending state according to the specified color mode. If isPremultipliedAlpha is true, this applies a blending function appropriate for colors premultiplied by the alpha component. Otherwise, this applies a blending function appropriate for non-premultiplied colors.

Parameters:
gl - the GL context.
isPremultipliedAlpha - true to configure blending for colors premultiplied by the alpha components, and false to configure blending for non-premultiplied colors.
Throws:
java.lang.IllegalArgumentException - if the GL is null.

applyColor

public static void applyColor(javax.media.opengl.GL gl,
                              java.awt.Color color)
Sets the GL color state to the specified Color. This premultipies the Red, Green, and Blue color values by the Alpha value.

Parameters:
gl - the GL context.
color - the Red, Green, Blue, and Alpha values to set.
Throws:
java.lang.IllegalArgumentException - if the GL is null, if the Color is null, if the opacity is less than 0, or if the opacity is greater than 1.

applyColor

public static void applyColor(javax.media.opengl.GL gl,
                              java.awt.Color color,
                              boolean premultiply)
Sets the GL color state to the specified Color, and with the specified color mode. If premultiply is true, this premultipies the Red, Green, and Blue color values by the Alpha value. Otherwise, this does not modify the Red, Green, and Blue color values.

Parameters:
gl - the GL context.
color - the Red, Green, Blue, and Alpha values to set.
premultiply - true to premultiply the Red, Green and Blue color values by the Alpha value, false to leave the Red, Green, and Blue values unmodified.
Throws:
java.lang.IllegalArgumentException - if the GL is null, if the Color is null, if the opacity is less than 0, or if the opacity is greater than 1.

applyColor

public static void applyColor(javax.media.opengl.GL gl,
                              java.awt.Color color,
                              double opacity)
Sets the GL color state to the specified Color and opacity. This premultipies the Red, Green, and Blue color values by the opacity value.

Parameters:
gl - the GL context.
color - the Red, Green, and Blue values to set.
opacity - the opacity to set.
Throws:
java.lang.IllegalArgumentException - if the GL is null, if the Color is null, if the opacity is less than 0, or if the opacity is greater than 1.

applyColor

public static void applyColor(javax.media.opengl.GL gl,
                              java.awt.Color color,
                              double opacity,
                              boolean premultiply)
Sets the GL color state to the specified Color and opacity, and with the specified color mode. If premultiply is true, this premultipies the Red, Green, and Blue color values by the opacity value. Otherwise, this does not modify the Red, Green, and Blue color values.

Parameters:
gl - the GL context.
color - the Red, Green, and Blue values to set.
opacity - the opacity to set.
premultiply - true to premultiply the Red, Green, and Blue color values by the opacity value, false to leave the Red, Green, and Blue values unmodified.
Throws:
java.lang.IllegalArgumentException - if the GL is null, if the Color is null, if the opacity is less than 0, or if the opacity is greater than 1.

applyLightingDirectionalFromViewer

public static void applyLightingDirectionalFromViewer(javax.media.opengl.GL gl,
                                                      int light)
Sets the GL lighting state to a white light originating from the eye position and pointed directly along the forward vector form the eye point

Parameters:
gl - the GL context.
light - the GL light name to set.
Throws:
java.lang.IllegalArgumentException - if the GL is null.

applyLightingDirectionalFromViewer

public static void applyLightingDirectionalFromViewer(javax.media.opengl.GL gl,
                                                      int light,
                                                      Vec4 direction)
Sets the GL lighting state to a white light originating from the eye position and pointed in the specified direction, in model coordinates. The light direction is always relative to the current eye point and viewer direction. If the direction is null, this the light direction defaults to (0, 0, -1), which points directly along the forward vector form the eye point

Parameters:
gl - the GL context.
light - the GL light name to set.
direction - the light direction in model coordinates, may be null.
Throws:
java.lang.IllegalArgumentException - if the GL is null.

NASA World Wind