de.grogra.imp3d.glsl
Class OpenGLState

java.lang.Object
  extended by de.grogra.imp3d.glsl.OpenGLState

public class OpenGLState
extends java.lang.Object

OpenGLState stores all relevant information about the used OpenGL Context. This includes active shaders, FBOs and the state of tests like the alpha test, the z-test. It also stores the state of culling and blending. This is done to prevent unnecessary state changes. This class also gives access to the used FBOs through an instance of the GLSLFBOManager class. It stores all data shared by the different classes of OpenGL (Proteus).

Author:
Konni Hartmann

Field Summary
static char ALPHA_TEST
           
static char ALPHA_TEST_BIT
           
static int[] attachPoints
           
 boolean BGFound
           
static char BLEND
           
static char BLEND_BIT
           
 CachedShaderCollection csc
          ShaderCollection buffers all compiled Shaders used to simulate scene-shaders (like different Phong combinations, RGBAShader ...) and light-Shaders (like Spot-Light, SunSkyLight ...)
static char CULLING
           
static char CULLING_BIT
           
 java.lang.String currentPassName
           
 boolean debugDrawn
           
static int DEFAULT_MATERIAL
           
protected static int DEFERRED_FBO
           
 DrawableContainer deferredLabelRenderable
           
 DrawableContainer deferredSolidRenderable
           
 DrawableContainer deferredToolRenderable
           
 DrawableContainer deferredTranspRenderable
           
 java.util.Vector<LightPos> defLight
           
static int DEPTH_PEELIG_MATERIAL
           
static char DEPTH_TEST
           
static char DEPTH_TEST_BIT
           
 int floatRT
           
static char FREE2
           
static char FREE2_BIT
           
 FrustumCullingTester frustumCullingTester
           
protected static int HDR_FBO
           
 int height
           
static int INFINITY_PLANE_MATERIAL
           
static char LIGHTING
           
static char LIGHTING_BIT
           
 java.util.Vector<LightPos> lights
          Vector of LightPos-objects.
 LineSegmentizationCache lineCache
           
 int[] occlusionQuery
           
 int renderPass
           
 boolean resetCache
           
protected static int RT_DIFF_SPEC
           
protected static int RT_EMIS_FREE
           
protected static int RT_FIRSTHDR
           
protected static int RT_NORM_POS_SHINE
           
protected static int RT_SECONDHDR
           
protected static int RT_TRANSP_SPECTRANSP
           
protected static int SHADOWMAP_FBO
           
static int SKY_MATERIAL
           
static int SKY_PREVIEW_MATERIAL
           
static int SKY_REFLECTION_MATERIAL
           
 GLSLSkyCube skyCube
           
 GLSLSkyCube skyDiffuseCube
           
 ShadowMapCollection SM_Manager
           
 java.util.Vector<GLSLOpenGLObject> staticObjects
           
static char STENCIL_TEST
           
static char STENCIL_TEST_BIT
           
static char TEXTURE_2D
           
static char TEXTURE_2D_BIT
           
static int TRANSP_DEPTH_ONLY_MATERIAL
           
 VBOManager VBO_Manager
           
 GLSLVolumeBuilder volume
           
 int width
           
 
Constructor Summary
OpenGLState()
           
 
Method Summary
 void cleanUp(boolean javaonly)
           
 void disable(char state)
           
 void enable(char state)
           
 int getActiveShader()
           
 FrameBufferObject getAlphaFBO()
           
 float getBgPowerDensity()
           
 Shader getBGShader()
           
 FrameBufferObject getCubeFBO()
           
 TextureRenderTarget getDeferredShadingDepthTRT()
           
 FrameBufferObject getDeferredShadingFBO()
           
 RenderBuffer getDepthRB()
           
 FrameBufferObject getDualDepthFBO()
           
 int getFaceCullingMode()
           
 GLSLFBOManager getFboManager()
           
 int getFloatRT()
           
 int getFloatRTLast()
           
 javax.media.opengl.GL getGL()
           
 int getGraphStamp()
           
 FrameBufferObject getHDRFBO()
           
 Matrix4d getInvViewToClip()
           
 Matrix4d getInvWorldToView()
           
 TextureRenderTarget getPeelingFarDepthTRT()
           
 TextureRenderTarget getPeelingNearDepthTRT()
           
 RenderBuffer getPeelingRB()
           
 FrameBufferObject getShadowFBO()
           
 RenderableCollection getShapeManager()
           
 boolean getState(char state)
           
 Matrix4d getViewToClip()
           
 Matrix4d getWorldToView()
           
 boolean hasGraphChanged()
           
 void info(java.lang.String txt)
           
 void initLineCache(GLDisplay disp)
           
 void initSize(int width, int height)
           
 void invalidateCache()
           
 boolean isAssumeTranspMaterials()
           
 void loadMatrixd(Matrix4d m)
           
 long popClock()
           
 void presentDebugScreen(GLSLDisplay disp)
           
 long printClock(java.lang.String pre)
           
 void printGPUMemoryUsage(GLSLDisplay disp)
           
 void printPoints()
           
 void setActiveProgram(int program)
           
 void setAssumeTranspMaterials(boolean assumeTranspMaterials)
           
 void setDeferredShadingDepthTRT(TextureRenderTarget dsDTRT)
           
 void setDepthMask(boolean maskEnable)
           
 void setFaceCullingMode(int faceCulling)
           
 void setFBO(int fboNo)
           
 void setGL(javax.media.opengl.GL glcontext)
           
 void setMatrixMode(int matrixMode)
           
 void setPoint(Vector3f v, int i)
           
 void setShaderConfSwitch(int shaderConfSwitch)
           
 void setState(char state)
          Set the GL-Statemachine to the state given.
 void setupBGPowerDensity(float powerDensity)
           
 void setupBGShader(Shader shader)
           
 void startClock()
           
 void switchFloatRT()
           
 void testFBO()
           
 boolean testGLError()
           
 boolean testGLError(java.lang.String prefix)
           
 float[] toGLMatrix3f(Matrix3f mat)
           
 double[] toGLMatrix4(Matrix4d m)
           
 void updateTransformations(GLSLDisplay disp)
           
 void warning(java.lang.String txt)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALPHA_TEST

public static final char ALPHA_TEST
See Also:
Constant Field Values

ALPHA_TEST_BIT

public static final char ALPHA_TEST_BIT
See Also:
Constant Field Values

attachPoints

public static final int[] attachPoints

BGFound

public boolean BGFound

BLEND

public static final char BLEND
See Also:
Constant Field Values

BLEND_BIT

public static final char BLEND_BIT
See Also:
Constant Field Values

csc

public CachedShaderCollection csc
ShaderCollection buffers all compiled Shaders used to simulate scene-shaders (like different Phong combinations, RGBAShader ...) and light-Shaders (like Spot-Light, SunSkyLight ...)


CULLING

public static final char CULLING
See Also:
Constant Field Values

CULLING_BIT

public static final char CULLING_BIT
See Also:
Constant Field Values

currentPassName

public java.lang.String currentPassName

debugDrawn

public boolean debugDrawn

DEFAULT_MATERIAL

public static final int DEFAULT_MATERIAL
See Also:
Constant Field Values

DEFERRED_FBO

protected static final int DEFERRED_FBO
See Also:
Constant Field Values

deferredLabelRenderable

public DrawableContainer deferredLabelRenderable

deferredSolidRenderable

public DrawableContainer deferredSolidRenderable

deferredToolRenderable

public DrawableContainer deferredToolRenderable

deferredTranspRenderable

public DrawableContainer deferredTranspRenderable

defLight

public java.util.Vector<LightPos> defLight

DEPTH_PEELIG_MATERIAL

public static final int DEPTH_PEELIG_MATERIAL
See Also:
Constant Field Values

DEPTH_TEST

public static final char DEPTH_TEST
See Also:
Constant Field Values

DEPTH_TEST_BIT

public static final char DEPTH_TEST_BIT
See Also:
Constant Field Values

floatRT

public int floatRT

FREE2

public static final char FREE2
See Also:
Constant Field Values

FREE2_BIT

public static final char FREE2_BIT
See Also:
Constant Field Values

frustumCullingTester

public FrustumCullingTester frustumCullingTester

HDR_FBO

protected static final int HDR_FBO
See Also:
Constant Field Values

height

public int height

INFINITY_PLANE_MATERIAL

public static final int INFINITY_PLANE_MATERIAL
See Also:
Constant Field Values

LIGHTING

public static final char LIGHTING
See Also:
Constant Field Values

LIGHTING_BIT

public static final char LIGHTING_BIT
See Also:
Constant Field Values

lights

public java.util.Vector<LightPos> lights
Vector of LightPos-objects. Is filled by the first renderpass with lights from the scenegraph, including there transformation.


lineCache

public LineSegmentizationCache lineCache

occlusionQuery

public int[] occlusionQuery

renderPass

public int renderPass

resetCache

public boolean resetCache

RT_DIFF_SPEC

protected static final int RT_DIFF_SPEC
See Also:
Constant Field Values

RT_EMIS_FREE

protected static final int RT_EMIS_FREE
See Also:
Constant Field Values

RT_FIRSTHDR

protected static final int RT_FIRSTHDR
See Also:
Constant Field Values

RT_NORM_POS_SHINE

protected static final int RT_NORM_POS_SHINE
See Also:
Constant Field Values

RT_SECONDHDR

protected static final int RT_SECONDHDR
See Also:
Constant Field Values

RT_TRANSP_SPECTRANSP

protected static final int RT_TRANSP_SPECTRANSP
See Also:
Constant Field Values

SHADOWMAP_FBO

protected static final int SHADOWMAP_FBO
See Also:
Constant Field Values

SKY_MATERIAL

public static final int SKY_MATERIAL
See Also:
Constant Field Values

SKY_PREVIEW_MATERIAL

public static final int SKY_PREVIEW_MATERIAL
See Also:
Constant Field Values

SKY_REFLECTION_MATERIAL

public static final int SKY_REFLECTION_MATERIAL
See Also:
Constant Field Values

skyCube

public GLSLSkyCube skyCube

skyDiffuseCube

public GLSLSkyCube skyDiffuseCube

SM_Manager

public ShadowMapCollection SM_Manager

staticObjects

public java.util.Vector<GLSLOpenGLObject> staticObjects

STENCIL_TEST

public static final char STENCIL_TEST
See Also:
Constant Field Values

STENCIL_TEST_BIT

public static final char STENCIL_TEST_BIT
See Also:
Constant Field Values

TEXTURE_2D

public static final char TEXTURE_2D
See Also:
Constant Field Values

TEXTURE_2D_BIT

public static final char TEXTURE_2D_BIT
See Also:
Constant Field Values

TRANSP_DEPTH_ONLY_MATERIAL

public static final int TRANSP_DEPTH_ONLY_MATERIAL
See Also:
Constant Field Values

VBO_Manager

public VBOManager VBO_Manager

volume

public GLSLVolumeBuilder volume

width

public int width
Constructor Detail

OpenGLState

public OpenGLState()
Method Detail

cleanUp

public void cleanUp(boolean javaonly)

disable

public void disable(char state)

enable

public void enable(char state)

getActiveShader

public int getActiveShader()

getAlphaFBO

public FrameBufferObject getAlphaFBO()
Returns:
the alphaFBO

getBgPowerDensity

public float getBgPowerDensity()

getBGShader

public Shader getBGShader()

getCubeFBO

public FrameBufferObject getCubeFBO()
Returns:
the cubeFBO

getDeferredShadingDepthTRT

public TextureRenderTarget getDeferredShadingDepthTRT()

getDeferredShadingFBO

public FrameBufferObject getDeferredShadingFBO()
Returns:
the deferredShadingFBO

getDepthRB

public RenderBuffer getDepthRB()
Returns:
the depthRB

getDualDepthFBO

public FrameBufferObject getDualDepthFBO()
Returns:
the dualDepthFBO

getFaceCullingMode

public int getFaceCullingMode()

getFboManager

public GLSLFBOManager getFboManager()
Returns:
the fboManager

getFloatRT

public int getFloatRT()

getFloatRTLast

public int getFloatRTLast()

getGL

public javax.media.opengl.GL getGL()

getGraphStamp

public int getGraphStamp()

getHDRFBO

public FrameBufferObject getHDRFBO()
Returns:
the HDRFBO

getInvViewToClip

public Matrix4d getInvViewToClip()

getInvWorldToView

public Matrix4d getInvWorldToView()

getPeelingFarDepthTRT

public TextureRenderTarget getPeelingFarDepthTRT()
Returns:
the peelingFarDepthTRT

getPeelingNearDepthTRT

public TextureRenderTarget getPeelingNearDepthTRT()
Returns:
the peelingNearDepthTRT

getPeelingRB

public RenderBuffer getPeelingRB()
Returns:
the peelingRB

getShadowFBO

public FrameBufferObject getShadowFBO()
Returns:
the shadowFBO

getShapeManager

public RenderableCollection getShapeManager()

getState

public boolean getState(char state)

getViewToClip

public Matrix4d getViewToClip()

getWorldToView

public Matrix4d getWorldToView()

hasGraphChanged

public boolean hasGraphChanged()

info

public void info(java.lang.String txt)

initLineCache

public void initLineCache(GLDisplay disp)

initSize

public void initSize(int width,
                     int height)

invalidateCache

public void invalidateCache()

isAssumeTranspMaterials

public boolean isAssumeTranspMaterials()

loadMatrixd

public void loadMatrixd(Matrix4d m)

popClock

public long popClock()

presentDebugScreen

public void presentDebugScreen(GLSLDisplay disp)

printClock

public long printClock(java.lang.String pre)

printGPUMemoryUsage

public void printGPUMemoryUsage(GLSLDisplay disp)

printPoints

public void printPoints()

setActiveProgram

public void setActiveProgram(int program)

setAssumeTranspMaterials

public void setAssumeTranspMaterials(boolean assumeTranspMaterials)

setDeferredShadingDepthTRT

public void setDeferredShadingDepthTRT(TextureRenderTarget dsDTRT)

setDepthMask

public void setDepthMask(boolean maskEnable)

setFaceCullingMode

public void setFaceCullingMode(int faceCulling)

setFBO

public void setFBO(int fboNo)

setGL

public void setGL(javax.media.opengl.GL glcontext)

setMatrixMode

public void setMatrixMode(int matrixMode)

setPoint

public void setPoint(Vector3f v,
                     int i)

setShaderConfSwitch

public void setShaderConfSwitch(int shaderConfSwitch)

setState

public void setState(char state)
Set the GL-Statemachine to the state given.

Parameters:
state - The State to be set. Each Bit corresponds to a certain Parameter.

setupBGPowerDensity

public void setupBGPowerDensity(float powerDensity)

setupBGShader

public void setupBGShader(Shader shader)

startClock

public void startClock()

switchFloatRT

public void switchFloatRT()

testFBO

public void testFBO()

testGLError

public boolean testGLError()

testGLError

public boolean testGLError(java.lang.String prefix)

toGLMatrix3f

public float[] toGLMatrix3f(Matrix3f mat)
Parameters:
mat -
Returns:

toGLMatrix4

public double[] toGLMatrix4(Matrix4d m)
Parameters:
m -
Returns:
a one dimensional array containing the data of m ordered such that it may be used in OpenGL-Methods.

updateTransformations

public void updateTransformations(GLSLDisplay disp)

warning

public void warning(java.lang.String txt)