java.lang.Object
de.grogra.imp.awt.ViewComponentAdapter
de.grogra.glsl.GLDisplay
de.grogra.glsl.GLSLDisplay
- All Implemented Interfaces:
ViewComponent
,RenderState
,ComponentWrapper
,Selectable
,Disposable
,ImageObserver
,Runnable
,EventListener
,javax.media.opengl.GLEventListener
Extension to the GLDisplay class to work with shaders generated by ShaderOGL
- Author:
- Konni Hartmann, nmi
-
Nested Class Summary
Nested classes/interfaces inherited from class de.grogra.glsl.GLDisplay
GLDisplay.GLVisitor
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Debug switch.protected boolean
static final EnumerationType
Enumeration of the available Tonemapping-Algorithms.Fields inherited from class de.grogra.glsl.GLDisplay
curHighlight, dlSphere, dlSupershape, endPoint, gridColor, lineWidth, LOD_LEVELS, optionGridColorB, optionGridColorG, optionGridColorR, optionGridDimension, optionGridSpacing, optionRenderAsWireframe, optionShowAxes, optionShowDisplaySize, optionShowGrid, optionShowPoints, polyCache, pool, RENDER_MODE, startPoint, supportsVBO, visitor
Fields inherited from class de.grogra.imp.awt.ViewComponentAdapter
DISPOSED, DISPOSING, RENDERED_IMAGE, RENDERING, REPAINT_MASK
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface de.grogra.imp3d.RenderState
CURRENT_HIGHLIGHT
Fields inherited from interface de.grogra.imp.ViewComponent
ALL, CHANGED, MIN_USER_FLAG, SCENE, SELECTION, TOOLS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
drawBoxImpl
(javax.media.opengl.GL gl, float x0, float y0, float z0, float x1, float y1, float z1) void
drawGrid
(javax.media.opengl.GL gl) void
drawParallelogram
(float length, Vector3f axis, float scaleU, float scaleV, Shader s, int highlight, boolean asWireframe, Matrix4d t) void
Draw an x/y plane.void
Draw a single point with the specified pixel size and color.void
drawPolygons
(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t) void
drawPolygons
(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t, int defaultCulledSide, boolean cullingEnabled, boolean normalMode) Draw a polygonizable Object.void
drawRectangle
(int x, int y, int w, int h, Tuple3f color) Draw a rectangle from (x/y) to (x+w/y+h) with the specified color.void
fillRectangle
(int x, int y, int w, int h, Tuple3f color) Draw a filled rectangle from (x/y) to (x+w/y+h) with the specified color.void
Searches Shader-Cache for a GLSL-Shader corresponding to the given Shader s.findShader
(Shader s) Searches Shader-Cache for a GLSL-Shader corresponding to the given Shader s.float
float
float
float
float
Returns the OpenGLState associated with the current GLContext.int
static int
int
int
void
init()
Initialize OpenGL (Proteus).void
init
(javax.media.opengl.GLAutoDrawable d) Initialise opengl state and set default values.void
initView
(View view, EventListener listener) Initializes this component.boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
isVisible
(int layer) Tests if the given layer is currently visible.protected void
optionValueChanged
(String name, Object value) static void
printDebugInfo
(String string) Output a string to OUT if the DEBUG switch is set.static void
printDebugInfoN
(String string) Output a string to OUT if the DEBUG switch is set.protected void
render
(int flags) Render the scene graph.void
This method renders the Scene.void
resize()
If called, all associated FBOs are resized to the current viewports size.void
setGL
(javax.media.opengl.GL gl) Sets the gl object as current active GL object.boolean
setupBGShader
(Sky node) Setup a sky.void
setUpContext
(javax.media.opengl.GLContext context) Setter for GL.void
setVisitor
(GLDisplay.GLVisitor visitor) Sets the active visitor.static void
ViewOrtho
(javax.media.opengl.GL gl, int width, int height) construct an orthogonal view matrix for easing full screen Quad drawingstatic void
ViewPerspective
(javax.media.opengl.GL gl) change view matrix back to defaultMethods inherited from class de.grogra.glsl.GLDisplay
display, displayChanged, dispose, drawAxes, drawBox, drawDisplaySize, drawFrustum, drawFrustumIrregular, drawLamella, drawLine, drawPointCloud, drawPrismRectangular, drawSphere, drawSphereSegmentSolid, drawString, drawSupershape, drawTextBlock, drawWithDisplayList, estimateScaleAt, estimateScaleAt, getComponent, getCurrentHighlight, getCurrentShader, getLOD, getObserverForRenderer, getPool, getShader, getView3D, getWindowPos, imageUpdate, initRender, invokeRender, isExtensionSupported, makeSnapshot, reshape
Methods inherited from class de.grogra.imp.awt.ViewComponentAdapter
checkRepaint, checkRepaintWrapException, disposeRenderer, getColor, getColor, getDisplayResolution, getFactory, getFontMetrics, getGlobalLOD, getIntColor, getInterruptedException, getOption, getRenderGraphState, getView, initFactory, installListeners, invokeRenderSync, render, render, renderUninterruptibly, repaint, run, toSelection, uninstallListeners, updateResolution
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.grogra.imp3d.RenderState
getFontMetrics, getRenderGraphState
Methods inherited from interface de.grogra.pf.ui.edit.Selectable
toSelection
-
Field Details
-
DEBUG
public static final boolean DEBUGDebug switch. May be used to test if debug output should be printed. This variable is set to true by specifying the argument "-Dgroimp.debug.GLSLDisplay=1" for the Java VM. -
TONEMAPPING_TYPE
Enumeration of the available Tonemapping-Algorithms. This is used by the configuration Dialog of OpenGL (Proteus). -
optionShowBGImage
protected boolean optionShowBGImage
-
-
Constructor Details
-
GLSLDisplay
public GLSLDisplay()
-
-
Method Details
-
printDebugInfoN
Output a string to OUT if the DEBUG switch is set. This version terminates the line.- Parameters:
string
- The String to be printed.
-
printDebugInfo
Output a string to OUT if the DEBUG switch is set. This version does not terminate the line.- Parameters:
string
- The String to be printed.
-
initView
Description copied from interface:ViewComponent
Initializes this component. This method sets theview
within which this view component is used to display the graph. It also sets an event listener. this has to be informed of mouse and keys events within the view component by implementations of this method.- Specified by:
initView
in interfaceViewComponent
- Overrides:
initView
in classGLDisplay
- Parameters:
view
- the containing viewlistener
- mouse and key events will be reported to this listener
-
render
Description copied from class:GLDisplay
Render the scene graph. This function will traverse the scene graph and render all objects of it. These steps are performed:
- get GL
- if GL changed, delete textures
- clear the frame buffer
- draw background image (i.e. from povray)
- cleaar depth buffer
- set projection matrix
- check if the scene graph changed since last render, than remember that and perform an update of the light sources
- walk graph first time, visit every object, update lights if necessary
- if lights have changed, draw the scene again
- walk graph second time, visit highlighted objects
- disable lighting and depth buffer
- walk graph third time, visit tools (i.e. arrows to move objects)
- enable lighting and depth buffer
- Overrides:
render
in classGLDisplay
- Parameters:
flags
- combination of bit masks- Throws:
InterruptedException
- if the rendering has been interrupted
-
init
public void init(javax.media.opengl.GLAutoDrawable d) Initialise opengl state and set default values. All functions can assume those values being set upon call (i.e. MatrixMode as GL_MODELVIEW). If a function changes any of those values, it has to restore its state before calling another function or exiting. This also wraps DebugGL arround the current GL-Object ifDEBUG
is set to true resulting in detailed Debug-Output if an GLError occurs. -
drawBoxImpl
public void drawBoxImpl(javax.media.opengl.GL gl, float x0, float y0, float z0, float x1, float y1, float z1) -
drawPlane
Description copied from class:GLDisplay
Draw an x/y plane.- Specified by:
drawPlane
in interfaceRenderState
- Overrides:
drawPlane
in classGLDisplay
-
drawPolygons
public void drawPolygons(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t) - Specified by:
drawPolygons
in interfaceRenderState
- Overrides:
drawPolygons
in classGLDisplay
-
drawPolygons
public void drawPolygons(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t, int defaultCulledSide, boolean cullingEnabled, boolean normalMode) Draw a polygonizable Object. This Method adds additional parameters for dealing with different culling modes set by OpenGL.- Parameters:
pz
-obj
-asNode
-s
-highlight
-t
- Transformation matrix. Input forgetTransformation(Matrix4d)
defaultCulledSide
- Default state for culling. This is one of GL.FRONT, GL.GL_BACKcullingEnabled
- True if culling is currently enabled in OpenGL. False else.normalMode
- True if this is used for drawing visible geometry. False if used for drawing into Shadow Map.- See Also:
-
GLDisplay#drawPolygons(Polygonizable, Object, boolean, Shader, int, Matrix4d)
-
drawParallelogram
public void drawParallelogram(float length, Vector3f axis, float scaleU, float scaleV, Shader s, int highlight, boolean asWireframe, Matrix4d t) - Specified by:
drawParallelogram
in interfaceRenderState
- Overrides:
drawParallelogram
in classGLDisplay
-
drawGrid
public void drawGrid(javax.media.opengl.GL gl) -
ViewOrtho
public static void ViewOrtho(javax.media.opengl.GL gl, int width, int height) construct an orthogonal view matrix for easing full screen Quad drawing- Parameters:
gl
- Current GL Object. Used to issue OpenGL commands.width
- Width of the orthogonal projection in OpenGL units.height
- Height of the orthogonal projection in OpenGL units.
-
ViewPerspective
public static void ViewPerspective(javax.media.opengl.GL gl) change view matrix back to default- Parameters:
gl
- Current GL Object. Used to issue OpenGL commands.
-
drawRectangle
Description copied from class:GLDisplay
Draw a rectangle from (x/y) to (x+w/y+h) with the specified color.- Specified by:
drawRectangle
in interfaceRenderState
- Overrides:
drawRectangle
in classGLDisplay
-
fillRectangle
Description copied from class:GLDisplay
Draw a filled rectangle from (x/y) to (x+w/y+h) with the specified color.- Specified by:
fillRectangle
in interfaceRenderState
- Overrides:
fillRectangle
in classGLDisplay
-
drawPoint
Description copied from class:GLDisplay
Draw a single point with the specified pixel size and color. Although OpenGL provides a function to draw points, the point is represented by a sphere, because some graphics cards/drivers seem to have problems setting the size for the point.- Specified by:
drawPoint
in interfaceRenderState
- Overrides:
drawPoint
in classGLDisplay
pixelSize
- size of point on screen in pixels
-
getTransformation
- Overrides:
getTransformation
in classGLDisplay
-
optionValueChanged
- Overrides:
optionValueChanged
in classGLDisplay
-
isOptionShowGrid
public boolean isOptionShowGrid()- Returns:
- true, if grid should be rendered. false, else
-
isOptionRenderAsWireframe
public boolean isOptionRenderAsWireframe()- Returns:
- true, if grid should be rendered. false, else
-
isOptionShowBGImage
public boolean isOptionShowBGImage()- Returns:
- true, if the background (checkboard) image should be rendered. false, else
-
getBackgroundColorR
public float getBackgroundColorR()- Returns:
- red value of background color
-
getBackgroundColorG
public float getBackgroundColorG()- Returns:
- green value of background color
-
getBackgroundColorB
public float getBackgroundColorB()- Returns:
- blue value of background color
-
getBackgroundAlpha
public float getBackgroundAlpha()- Returns:
- alpha value of background
-
isOptionLighting
public boolean isOptionLighting()- Returns:
- true, if scene should be rendered with all lights. false, only use default directional light.
-
isOptionShowSky
public boolean isOptionShowSky()- Returns:
- true, if scene sky should be rendered.
-
isOptionShowShadows
public boolean isOptionShowShadows()- Returns:
- true, if shadows should be rendered and displayed.
-
isOptionEdgeFiltering
public boolean isOptionEdgeFiltering()- Returns:
- true, if edge-filtering should be used. This Option is currently unused since a working filtering approach was not implemented.
-
isOptionAltDrawing
public boolean isOptionAltDrawing()- Returns:
- true, if alternative drawing methods should be called. Up to now this will only result in infinite planes.
-
isOptionPhysicalLighting
public boolean isOptionPhysicalLighting()- Returns:
- true, if lights intensity should decrease by the squared distance from the lights source.
-
isOptionShowDiffuseSkyLight
public boolean isOptionShowDiffuseSkyLight()- Returns:
- true, if diffuse light of sky-Nodes should be approximated.
-
isOptionShaderAntialiasing
public boolean isOptionShaderAntialiasing()- Returns:
- true, if anti-aliasing material-shaders should be used.
-
isOptionAutoAdjustBrightness
public boolean isOptionAutoAdjustBrightness()- Returns:
- true, if brightness should be automatically adjusted for the rendered image.
-
getBrightness
public float getBrightness()- Returns:
- the brightness factor used to brighten the rendered image.
-
getTonemapping
public int getTonemapping()- Returns:
- the index of the choosen tonemapping algorithm. For now this is: 0: Linear tonemapping 1: DDR (Dynamic Range Reduction). See paper at link.
-
getDebugRenderPass
public int getDebugRenderPass()- Returns:
- the index of a renderpass, which should be displayed. This will render the content of each HDR- and DeferredShading-FBO as seen at the specified RenderPass to the screen.
-
getMaxDepth
public int getMaxDepth()- Returns:
- Number of Depth-Peeling passes used to display transparent materials.
-
getVisitor
- Returns:
- The current active Visitor to traverse the Scene-Tree.
-
setVisitor
Sets the active visitor. The previous visitor will not be saved. UsegetVisitor()
to store a reference.- Parameters:
visitor
- The visitor Object that replaces the active visitor.
-
getTextureManager
- Returns:
- The Manager used to the Textures for each translated material.
-
isVisible
public boolean isVisible(int layer) Tests if the given layer is currently visible.- Parameters:
layer
- The layer that should be tested.- Returns:
- true, if the layer is visible.
-
getCurrentGLState
Returns the OpenGLState associated with the current GLContext.- Returns:
- The current OpenGLState.
- See Also:
-
getDepthStencilSetup
public static int getDepthStencilSetup() -
init
public void init()Initialize OpenGL (Proteus). This will initialize all Collections -
setGL
public void setGL(javax.media.opengl.GL gl) Sets the gl object as current active GL object. Effectively this will callOpenGLState.setGL(GL)
.- Parameters:
gl
- The GL object
-
resize
public void resize()If called, all associated FBOs are resized to the current viewports size. -
setUpContext
public void setUpContext(javax.media.opengl.GLContext context) Setter for GL. This will also reset glState and cleanup the Java-Side of the used OpenGL-Objects.- Parameters:
context
- The new GL-context that should be used for all actions.
-
renderScene
public void renderScene()This method renders the Scene. This includes all objects of the Scene-Graph. Additional rendering like highlighting of objects and the size of the current viewport will be handled byGLDisplay.render(int)
. -
findAndActivateShader
Searches Shader-Cache for a GLSL-Shader corresponding to the given Shader s. If no GLSL-Shader is found one is created. The Shader is then activated.- Parameters:
s
- The GroIMP-Shader.
-
findShader
Searches Shader-Cache for a GLSL-Shader corresponding to the given Shader s. If no GLSL-Shader is found one is created.- Parameters:
s
- The GroIMP-Shader.- Returns:
- The GLSL-Shader.
-
setupBGShader
Setup a sky. This method is used by a visitor to store a sky-node. Since it is considered a hack this method will be removed in upcoming commits of the source-code.- Parameters:
node
-- Returns:
- false, if a sky has already been set.
-