org.deegree.rendering.r3d.opengl
Class JOGLUtils

java.lang.Object
  extended by org.deegree.rendering.r3d.opengl.JOGLUtils

public class JOGLUtils
extends Object

JOGL-related utility methods.

Version:
$Revision: 29127 $, $Date: 2011-01-10 16:13:35 +0100 (Mon, 10 Jan 2011) $
Author:
Markus Schneider, last edited by: $Author: aschmitz $

Constructor Summary
JOGLUtils()
           
 
Method Summary
static int convertBytesToARGBInt(byte[] color)
          Create an int value ([a]rgb) from the given color array (rgb[a]), the result can be used for buffered images.
static int convertBytesToRGBInt(byte[] color)
          Create an int value (rgb) from the given color array (rgb), the result can be used for buffered images.
static float[] convertColorFloats(Color color)
          Create an a float array from the given color object, which can be used for rendering with jogl.
static int convertColorGLColor(Color color)
          Create an int with rgba from the given color (which returns the argb values).
static float[] convertColorIntAsFloats(int color)
          The float array appropriate for opengl.
static float[] getEyeFromModelView(javax.media.opengl.GL gl)
          Calculate the eye position from the given modelview, note, no scale may be applied.
static ByteBuffer getFrameBufferRGB(javax.media.opengl.GL glContext, ByteBuffer imageBuffer, int viewPortX, int viewPortY, int width, int height)
          Read the framebuffer's rgb values and place them into a ByteBuffer.
static BufferedImage getFrameBufferRGB(javax.media.opengl.GL glContext, ByteBuffer imageBuffer, int viewPortX, int viewPortY, int width, int height, BufferedImage resultImage)
          Read the framebuffer's rgb values and place them into a BufferedImage.
static ByteBuffer getFrameBufferRGBA(javax.media.opengl.GL glContext, ByteBuffer imageBuffer, int viewPortX, int viewPortY, int width, int height)
          Read the framebuffer's rgba values and place them into a ByteBuffer.
static BufferedImage getFrameBufferRGBA(javax.media.opengl.GL glContext, ByteBuffer imageBuffer, int viewPortX, int viewPortY, int width, int height, BufferedImage resultImage)
          Read the framebuffer's rgb values and place them into a BufferedImage.
static int getMaxTextureSize(javax.media.opengl.GL gl)
          Returns maximum texture size support by the GL driver.
static String getMVAsString(javax.media.opengl.GL gl)
          Get a string representation of the current modelview matrix of the given context.
static int getNumTextureImageUnits(javax.media.opengl.GL gl)
          Returns the number of texture image units that can be used in fragment shaders.
static String getProjectionAsString(javax.media.opengl.GL gl)
          Get a string representation of the current Projection matrix of the given context.
static int getTextureUnitConst(int textureId)
          Returns the value of the symbolic constant TEXTURE0...TEXTURE31 for a certain texture unit id.
static String outputMatrix(javax.media.opengl.GL gl, int GL_MATRIX_TYPE)
          Get a string representation of the given matrix type of the given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JOGLUtils

public JOGLUtils()
Method Detail

getMaxTextureSize

public static int getMaxTextureSize(javax.media.opengl.GL gl)
Returns maximum texture size support by the GL driver.

Parameters:
gl -
Returns:
maximum texture size (pixels)

getNumTextureImageUnits

public static int getNumTextureImageUnits(javax.media.opengl.GL gl)
Returns the number of texture image units that can be used in fragment shaders.

NOTE: This method evaluates the value of GL_MAX_TEXTURE_IMAGE_UNITS. The number is usually not identical to GL_MAX_TEXTURE_UNITS which denotes the maximum number of texture units in fixed shader functions.

Parameters:
gl -
Returns:
number of texture image units

getTextureUnitConst

public static int getTextureUnitConst(int textureId)
Returns the value of the symbolic constant TEXTURE0...TEXTURE31 for a certain texture unit id.

Parameters:
textureId - id of the requested texture unit (0...31)
Returns:
value of the corresponding symbolic constant

getMVAsString

public static String getMVAsString(javax.media.opengl.GL gl)
Get a string representation of the current modelview matrix of the given context.

Parameters:
gl -
Returns:
the String representation of modelview matrix

getProjectionAsString

public static String getProjectionAsString(javax.media.opengl.GL gl)
Get a string representation of the current Projection matrix of the given context.

Parameters:
gl -
Returns:
the String representation of projection matrix

outputMatrix

public static String outputMatrix(javax.media.opengl.GL gl,
                                  int GL_MATRIX_TYPE)
Get a string representation of the given matrix type of the given context.

Parameters:
gl -
GL_MATRIX_TYPE - one of GL.GL_MODELVIEW_MATRIX, GL.GL_PROJECTION_MATRIX
Returns:
the String representation of given matrix

getEyeFromModelView

public static float[] getEyeFromModelView(javax.media.opengl.GL gl)
Calculate the eye position from the given modelview, note, no scale may be applied.

Parameters:
gl - to get the modelview from.
Returns:
the eye position of the modelview matrix.

convertColorGLColor

public static int convertColorGLColor(Color color)
Create an int with rgba from the given color (which returns the argb values).

Parameters:
color - to be converted.
Returns:
the color as an int holding rgba.

convertColorFloats

public static float[] convertColorFloats(Color color)
Create an a float array from the given color object, which can be used for rendering with jogl.

Parameters:
color - to be converted.
Returns:
the color as an float array holding rgba.

convertColorIntAsFloats

public static float[] convertColorIntAsFloats(int color)
The float array appropriate for opengl.

Parameters:
color - (rgba) to be converted into a float arra.
Returns:
the float array ready to be rendered.

convertBytesToARGBInt

public static int convertBytesToARGBInt(byte[] color)
Create an int value ([a]rgb) from the given color array (rgb[a]), the result can be used for buffered images.

Parameters:
color - to be converted may be of length 3 or 4, not null.
Returns:
the color as an int holding argb.

convertBytesToRGBInt

public static int convertBytesToRGBInt(byte[] color)
Create an int value (rgb) from the given color array (rgb), the result can be used for buffered images.

Parameters:
color - to be converted may be only be of length 3, not null.
Returns:
the color as an int holding rgb.

getFrameBufferRGBA

public static ByteBuffer getFrameBufferRGBA(javax.media.opengl.GL glContext,
                                            ByteBuffer imageBuffer,
                                            int viewPortX,
                                            int viewPortY,
                                            int width,
                                            int height)
Read the framebuffer's rgba values and place them into a ByteBuffer. If the resultImage was null or it's height or width are to small a new ByteBuffer is created.

Parameters:
glContext - to get the image from.
imageBuffer - to write the framebuffer to.
viewPortX - the x location in the framebuffer.
viewPortY - the y location in the framebuffer.
width - of read in the framebuffer.
height - of read in the framebuffer.
Returns:
the resultImage or a newly created BufferedImage holding the requested data from the framebuffer.

getFrameBufferRGBA

public static BufferedImage getFrameBufferRGBA(javax.media.opengl.GL glContext,
                                               ByteBuffer imageBuffer,
                                               int viewPortX,
                                               int viewPortY,
                                               int width,
                                               int height,
                                               BufferedImage resultImage)
Read the framebuffer's rgb values and place them into a BufferedImage. If the resultImage was null or it's height or width are to small a new BufferedImage is created. The resultImage type is supposed to be BufferedImage.TYPE_INT_RGB.

Parameters:
glContext - to get the image from.
imageBuffer - to write the framebuffer to.
viewPortX - the x location in the framebuffer.
viewPortY - the y location in the framebuffer.
width - of read in the framebuffer.
height - of read in the framebuffer.
resultImage - which will hold the result, may be null
Returns:
the resultImage or a newly created BufferedImage holding the requested data from the framebuffer.

getFrameBufferRGB

public static ByteBuffer getFrameBufferRGB(javax.media.opengl.GL glContext,
                                           ByteBuffer imageBuffer,
                                           int viewPortX,
                                           int viewPortY,
                                           int width,
                                           int height)
Read the framebuffer's rgb values and place them into a ByteBuffer. If the resultImage was null or it's height or width are to small a new ByteBuffer is created.

Parameters:
glContext - to get the image from.
imageBuffer - to write the framebuffer to.
viewPortX - the x location in the framebuffer.
viewPortY - the y location in the framebuffer.
width - of read in the framebuffer.
height - of read in the framebuffer.
Returns:
the resultImage or a newly created BufferedImage holding the requested data from the framebuffer.

getFrameBufferRGB

public static BufferedImage getFrameBufferRGB(javax.media.opengl.GL glContext,
                                              ByteBuffer imageBuffer,
                                              int viewPortX,
                                              int viewPortY,
                                              int width,
                                              int height,
                                              BufferedImage resultImage)
Read the framebuffer's rgb values and place them into a BufferedImage. If the resultImage was null or it's height or width are to small a new BufferedImage is created. The resultImage type is supposed to be BufferedImage.TYPE_INT_RGB.

Parameters:
glContext - to get the image from.
imageBuffer - to write the framebuffer to.
viewPortX - the x location in the framebuffer.
viewPortY - the y location in the framebuffer.
width - of read in the framebuffer.
height - of read in the framebuffer.
resultImage - which will hold the result, may be null
Returns:
the resultImage or a newly created BufferedImage holding the requested data from the framebuffer.


Copyright © 2011. All Rights Reserved.