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
FieldsModifier and TypeFieldDescriptionstatic final booleanDebug switch.protected booleanstatic final EnumerationTypeEnumeration 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, visitorFields inherited from class de.grogra.imp.awt.ViewComponentAdapter
DISPOSED, DISPOSING, RENDER_OVERLAY, RENDER_OVERLAY_FINISHED, RENDERED_IMAGE, RENDERING, RENDERING_OVERLAY, REPAINT_MASKFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface de.grogra.imp3d.RenderState
CURRENT_HIGHLIGHTFields inherited from interface de.grogra.imp.ViewComponent
ALL, CHANGED, MIN_USER_FLAG, SCENE, SELECTION, TOOLS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddrawBoxImpl(javax.media.opengl.GL gl, float x0, float y0, float z0, float x1, float y1, float z1) voiddrawGrid(javax.media.opengl.GL gl) voiddrawParallelogram(float length, Vector3f axis, float scaleU, float scaleV, Shader s, int highlight, boolean asWireframe, Matrix4d t) voidDraw an x/y plane.voidDraw a single point with the specified pixel size and color.voiddrawPolygons(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t) voiddrawPolygons(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t, int defaultCulledSide, boolean cullingEnabled, boolean normalMode) Draw a polygonizable Object.voiddrawRectangle(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.voidfillRectangle(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.voidSearches 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.floatfloatfloatfloatfloatReturns the OpenGLState associated with the current GLContext.intstatic intintintvoidinit()Initialize OpenGL (Proteus).voidinit(javax.media.opengl.GLAutoDrawable d) Initialise opengl state and set default values.voidinitView(View view, EventListener listener) Initializes this component.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanisVisible(int layer) Tests if the given layer is currently visible.protected voidoptionValueChanged(String name, Object value) static voidprintDebugInfo(String string) Output a string to OUT if the DEBUG switch is set.static voidprintDebugInfoN(String string) Output a string to OUT if the DEBUG switch is set.protected voidrender(int flags) Render the scene graph.voidThis method renders the Scene.voidresize()If called, all associated FBOs are resized to the current viewports size.voidsetGL(javax.media.opengl.GL gl) Sets the gl object as current active GL object.booleansetupBGShader(Sky node) Setup a sky.voidsetUpContext(javax.media.opengl.GLContext context) Setter for GL.voidsetVisitor(GLDisplay.GLVisitor visitor) Sets the active visitor.static voidViewOrtho(javax.media.opengl.GL gl, int width, int height) construct an orthogonal view matrix for easing full screen Quad drawingstatic voidViewPerspective(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, reshapeMethods inherited from class de.grogra.imp.awt.ViewComponentAdapter
checkRepaint, checkRepaintWrapException, disposeRenderer, disposeView, getColor, getColor, getDisplayResolution, getFactory, getFontMetrics, getGlobalLOD, getIntColor, getInterruptedException, getOption, getRenderGraphState, getView, initFactory, installListeners, invokeRenderSync, isRenderingOverlay, render, render, renderUninterruptibly, repaint, run, toSelection, uninstallListeners, updateResolutionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.grogra.imp3d.RenderState
getFontMetrics, getRenderGraphStateMethods 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:ViewComponentInitializes this component. This method sets theviewwithin 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:
initViewin interfaceViewComponent- Overrides:
initViewin classGLDisplay- Parameters:
view- the containing viewlistener- mouse and key events will be reported to this listener
-
render
Description copied from class:GLDisplayRender 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:
renderin 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 ifDEBUGis 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:GLDisplayDraw an x/y plane.- Specified by:
drawPlanein interfaceRenderState- Overrides:
drawPlanein classGLDisplay
-
drawPolygons
public void drawPolygons(Polygonizable pz, Object obj, boolean asNode, Shader s, int highlight, boolean asWireframe, Matrix4d t) - Specified by:
drawPolygonsin interfaceRenderState- Overrides:
drawPolygonsin classGLDisplay- Parameters:
pz-obj-asNode-s-highlight-t-
-
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:
-
drawParallelogram
public void drawParallelogram(float length, Vector3f axis, float scaleU, float scaleV, Shader s, int highlight, boolean asWireframe, Matrix4d t) - Specified by:
drawParallelogramin interfaceRenderState- Overrides:
drawParallelogramin 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:GLDisplayDraw a rectangle from (x/y) to (x+w/y+h) with the specified color.- Specified by:
drawRectanglein interfaceRenderState- Overrides:
drawRectanglein classGLDisplay
-
fillRectangle
Description copied from class:GLDisplayDraw a filled rectangle from (x/y) to (x+w/y+h) with the specified color.- Specified by:
fillRectanglein interfaceRenderState- Overrides:
fillRectanglein classGLDisplay
-
drawPoint
Description copied from class:GLDisplayDraw 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:
drawPointin interfaceRenderState- Overrides:
drawPointin classGLDisplay- Parameters:
pixelSize- size of point on screen in pixels
-
getTransformation
- Overrides:
getTransformationin classGLDisplay
-
optionValueChanged
- Overrides:
optionValueChangedin 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.
-