Package com.ardor3d.renderer.jogl
Class JoglRenderer
java.lang.Object
com.ardor3d.renderer.AbstractRenderer
com.ardor3d.renderer.jogl.JoglRenderer
- All Implemented Interfaces:
Renderer
JoglRenderer provides an implementation of the Renderer interface using the JOGL API.- See Also:
-
Field Summary
Fields inherited from class com.ardor3d.renderer.AbstractRenderer
_backgroundColor, _inOrthoMode, _processingQueue, _queue, _stencilClearValue, defaultStateList, renderLogicFields inherited from interface com.ardor3d.renderer.Renderer
BUFFER_ACCUMULATION, BUFFER_COLOR, BUFFER_COLOR_AND_DEPTH, BUFFER_DEPTH, BUFFER_NONE, BUFFER_STENCIL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyDefaultColor(ReadOnlyColorRGBA defaultColor) voidapplyNormalsMode(NormalsMode normalsMode, ReadOnlyTransform worldTransform) booleanCheck a given Spatial to see if it should be queued. return true if it was queued.voidcheckAndSetTextureArrayUnit(int unit, com.jogamp.opengl.GL gl, RendererRecord record, ContextCapabilities caps) voidCheck the underlying rendering system (opengl, etc.) for exceptions.voidclearBuffers(int buffers) clearBuffersclears the given buffers (specified as a bitwise &).voidclearBuffers(int buffers, boolean strict) clearBuffersclears the given buffers (specified as a bitwise &).voidClear all rectangles from the clip stack and disable clipping.voidclear the render queuevoidRemoves the given display lists by id from the current OpenGL context.voiddeleteTexture(Texture texture) Explicitly remove this Texture from the graphics card.voidRemoves the given texture ids from the current OpenGL context.voiddeleteVBOs(AbstractBufferData<?> buffer) Attempts to delete any VBOs associated with this buffer that are relevant to the current RenderContext.voiddeleteVBOs(Collection<Integer> ids) Attempts to delete the VBOs with the given id.protected voiddoApplyState(RenderState state) booleandoTransforms(ReadOnlyTransform transform) doTransformssets the current transform.voiddraw(Renderable renderable) drawrenders the renderable to the back buffer.voiddrawrenders a scene.voiddrawArrays(FloatBufferData vertexBuffer, int[] indexLengths, IndexMode[] indexModes, int primcount) voiddrawElements(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) voiddrawElementsVBO(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) voidEnds a display list.voidfinishis similar to flush, however it blocks until all waiting hardware graphics commands have been finished.voidflushFrame(boolean doSwap) flushFramehandles rendering any items still remaining in the render buckets and optionally swaps the back buffer with the currently displayed buffer.voidflushtells the graphics hardware to send through all currently waiting commands in the buffer.intgetExpectedBufferSizeToGrabScreenContents(ImageDataFormat format, PixelDataType type, int w, int h) Gets the expected size (in bytes) of the buffer used to callgrabScreenContentsgetModelViewMatrix(FloatBuffer store) Gets the current model-view matrix in row major ordergetProjectionMatrix(FloatBuffer store) Gets the current projection matrix in row major ordervoidgrabScreenContents(ByteBuffer store, ImageDataFormat format, PixelDataType type, int x, int y, int w, int h) voidloadTexture(Texture texture, int unit) Loads a texture onto the card for the current OpenGL context.voidpopClip()Pop the most recent rectangle from the stack and adjust the rendering area accordingly.protected voidre-initializes the GL context for rendering of another piece of geometry.voidpushClip(ReadOnlyRectangle2 rectangle) Add the given rectangle to the clip stack, clipping the rendering area by the given rectangle intersected with any existing scissor entries.voidPush a clip onto the stack indicating that future clips should not intersect with clips prior to this one.voidrender queues - will first sort, then render, then finally clear the queuevoidrenderBuckets(boolean doSort, boolean doClear) render queuesvoidrenderDisplayList(int displayListID) Draw the given display list.voidsetBackgroundColorsets the color of window.voidsetClipTestEnabled(boolean enabled) voidsetDepthRange(double depthRangeNear, double depthRangeFar) voidsetDrawBuffer(DrawBufferTarget target) Specify which color buffers are to be drawn into.voidsetModelViewMatrix(FloatBuffer matrix) voidsetOrtho()setOrthosets the display system to be in orthographic mode.voidsetProjectionMatrix(FloatBuffer matrix) voidsetupColorData(FloatBufferData colorBufferData) voidvoidsetupFogData(FloatBufferData fogBufferData) voidvoidsetupLineParameters(float lineWidth, int stippleFactor, short stipplePattern, boolean antialiased) This is a workaround until we make shared Record classes, or open up lower level opengl calls abstracted from jogl.voidsetupNormalData(FloatBufferData normalBufferData) voidvoidsetupPointParameters(float pointSize, boolean antialiased, boolean isSprite, boolean useDistanceAttenuation, FloatBuffer attenuationCoefficients, float minPointSize, float maxPointSize) This is a workaround until we make shared Record classes, or open up lower level opengl calls abstracted from jogl.voidsetupTextureData(List<FloatBufferData> textureCoords) voidsetupTextureDataVBO(List<FloatBufferData> textureCoords) static intsetupVBO(AbstractBufferData<? extends Buffer> data, RenderContext context) voidsetupVertexData(FloatBufferData vertexBufferData) voidvoidsetViewport(int x, int y, int width, int height) intStart a new display list.voidUnbind the current VBO elements.voidundoTransforms(ReadOnlyTransform transform) undoTransformsreverts the latest transform.voidunsetOrhtounsets the display system from orthographic mode back into regular projection mode.voidupdateTexture1DSubImage(Texture1D destination, int dstOffsetX, int dstWidth, ByteBuffer source, int srcOffsetX) Update all or a portion of an existing one dimensional texture object.voidupdateTexture2DSubImage(Texture2D destination, int dstOffsetX, int dstOffsetY, int dstWidth, int dstHeight, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcTotalWidth) Update all or a portion of an existing two dimensional texture object.voidupdateTexture3DSubImage(Texture3D destination, int dstOffsetX, int dstOffsetY, int dstOffsetZ, int dstWidth, int dstHeight, int dstDepth, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcOffsetZ, int srcTotalWidth, int srcTotalHeight) Update all or a portion of an existing one dimensional texture object.voidupdateTextureCubeMapSubImage(TextureCubeMap destination, TextureCubeMap.Face dstFace, int dstOffsetX, int dstOffsetY, int dstWidth, int dstHeight, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcTotalWidth) Update all or a portion of a single two dimensional face on an existing cubemap texture object.Methods inherited from class com.ardor3d.renderer.AbstractRenderer
addStats, applyState, getBackgroundColor, getProperRenderState, getQueue, getStencilClearValue, grabScreenContents, isClipTestEnabled, isInOrthoMode, isProcessingQueue, setRenderLogic, setStencilClearValue
-
Constructor Details
-
JoglRenderer
public JoglRenderer()Constructor instantiates a newJoglRendererobject.
-
-
Method Details
-
setBackgroundColor
Description copied from interface:RenderersetBackgroundColorsets the color of window. This color will be shown for any pixel that is not set via typical rendering operations.- Parameters:
c- the color to set the background to.
-
renderBuckets
public void renderBuckets()Description copied from interface:Rendererrender queues - will first sort, then render, then finally clear the queue -
renderBuckets
public void renderBuckets(boolean doSort, boolean doClear) Description copied from interface:Rendererrender queues- Parameters:
doSort- if true, the queues will be sorted prior to rendering.doClear- if true, the queues will be emptied after rendering.
-
clearQueue
public void clearQueue()clear the render queue -
clearBuffers
public void clearBuffers(int buffers) Description copied from interface:RendererclearBuffersclears the given buffers (specified as a bitwise &).- Parameters:
buffers- the buffers to clear.- See Also:
-
clearBuffers
public void clearBuffers(int buffers, boolean strict) Description copied from interface:RendererclearBuffersclears the given buffers (specified as a bitwise &).- Parameters:
buffers- the buffers to clear.strict- if true, we'll limit the clearing to just the viewport area specified by the current camera.- See Also:
-
flushFrame
public void flushFrame(boolean doSwap) Description copied from interface:RendererflushFramehandles rendering any items still remaining in the render buckets and optionally swaps the back buffer with the currently displayed buffer.- Parameters:
doSwap- if true, will ask the underlying implementation to blit the back buffer contents to the display buffer. Usually this will be true, unless you are in a windowing toolkit that handles doing this for you.
-
setOrtho
public void setOrtho()Description copied from interface:RenderersetOrthosets the display system to be in orthographic mode. If the system has already been set to orthographic mode aArdor3dExceptionis thrown. The origin (0,0) is the bottom left of the screen. -
unsetOrtho
public void unsetOrtho()Description copied from interface:RendererunsetOrhtounsets the display system from orthographic mode back into regular projection mode. If the system is not in orthographic mode aArdor3dExceptionis thrown. -
grabScreenContents
public void grabScreenContents(ByteBuffer store, ImageDataFormat format, PixelDataType type, int x, int y, int w, int h) -
getExpectedBufferSizeToGrabScreenContents
public int getExpectedBufferSizeToGrabScreenContents(ImageDataFormat format, PixelDataType type, int w, int h) Description copied from interface:RendererGets the expected size (in bytes) of the buffer used to callgrabScreenContents- Specified by:
getExpectedBufferSizeToGrabScreenContentsin interfaceRenderer- Overrides:
getExpectedBufferSizeToGrabScreenContentsin classAbstractRenderer- Parameters:
format- the format to read in data for.type- the format to read in data for.w- - width of blockh- - height of block- Returns:
- the expected size (in bytes) of the buffer used to call
grabScreenContents
-
draw
Description copied from interface:Rendererdrawrenders a scene. As it receives a base class ofSpatialthe renderer hands off management of the scene to spatial for it to determine when aGeometryleaf is reached.- Parameters:
s- the scene to render.
-
checkAndAdd
Description copied from interface:RendererCheck a given Spatial to see if it should be queued. return true if it was queued.- Parameters:
s- Spatial to check- Returns:
- true if it was queued.
-
postdrawGeometry
re-initializes the GL context for rendering of another piece of geometry.- Parameters:
g- the mesh
-
flushGraphics
public void flushGraphics()Description copied from interface:Rendererflushtells the graphics hardware to send through all currently waiting commands in the buffer. -
finishGraphics
public void finishGraphics()Description copied from interface:Rendererfinishis similar to flush, however it blocks until all waiting hardware graphics commands have been finished. -
applyNormalsMode
-
applyDefaultColor
-
deleteVBOs
Description copied from interface:RendererAttempts to delete the VBOs with the given id. Ignores null ids or ids < 1.- Parameters:
ids- the identifiers
-
deleteDisplayLists
Description copied from interface:RendererRemoves the given display lists by id from the current OpenGL context.- Parameters:
ids- a list/set of ids to remove.
-
deleteVBOs
Description copied from interface:RendererAttempts to delete any VBOs associated with this buffer that are relevant to the current RenderContext.- Parameters:
buffer- the buffer data
-
updateTexture1DSubImage
public void updateTexture1DSubImage(Texture1D destination, int dstOffsetX, int dstWidth, ByteBuffer source, int srcOffsetX) Description copied from interface:RendererUpdate all or a portion of an existing one dimensional texture object.- Parameters:
destination- the texture to update. Should already have been sent to the card (have a valid texture id.)dstOffsetX- the offset into the destination to start our update.dstWidth- the width of the region to update.source- the data to update from.srcOffsetX- the optional offset into our source data.
-
updateTexture2DSubImage
public void updateTexture2DSubImage(Texture2D destination, int dstOffsetX, int dstOffsetY, int dstWidth, int dstHeight, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcTotalWidth) Description copied from interface:RendererUpdate all or a portion of an existing two dimensional texture object.- Parameters:
destination- the texture to update. Should already have been sent to the card (have a valid texture id.)dstOffsetX- the x offset into the destination to start our update.dstOffsetY- the y offset into the destination to start our update.dstWidth- the width of the region to update.dstHeight- the height of the region to update.source- the data to update from.srcOffsetX- the optional X offset into our source data.srcOffsetY- the optional Y offset into our source data.srcTotalWidth- the total width of our source data, so we can properly walk through it.
-
updateTexture3DSubImage
public void updateTexture3DSubImage(Texture3D destination, int dstOffsetX, int dstOffsetY, int dstOffsetZ, int dstWidth, int dstHeight, int dstDepth, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcOffsetZ, int srcTotalWidth, int srcTotalHeight) Description copied from interface:RendererUpdate all or a portion of an existing one dimensional texture object.- Parameters:
destination- the texture to update. Should already have been sent to the card (have a valid texture id.)dstOffsetX- the x offset into the destination to start our update.dstOffsetY- the y offset into the destination to start our update.dstOffsetZ- the z offset into the destination to start our update.dstWidth- the width of the region to update.dstHeight- the height of the region to update.dstDepth- the depth of the region to update. eg. 1 == one slicesource- the data to update from.srcOffsetX- the optional X offset into our source data.srcOffsetY- the optional Y offset into our source data.srcOffsetZ- the optional Z offset into our source data.srcTotalWidth- the total width of our source data, so we can properly walk through it.srcTotalHeight- the total height of our source data, so we can properly walk through it.
-
updateTextureCubeMapSubImage
public void updateTextureCubeMapSubImage(TextureCubeMap destination, TextureCubeMap.Face dstFace, int dstOffsetX, int dstOffsetY, int dstWidth, int dstHeight, ByteBuffer source, int srcOffsetX, int srcOffsetY, int srcTotalWidth) Description copied from interface:RendererUpdate all or a portion of a single two dimensional face on an existing cubemap texture object.- Parameters:
destination- the texture to update. Should already have been sent to the card (have a valid texture id.)dstFace- the face to update.dstOffsetX- the x offset into the destination to start our update.dstOffsetY- the y offset into the destination to start our update.dstWidth- the width of the region to update.dstHeight- the height of the region to update.source- the data to update from.srcOffsetX- the optional X offset into our source data.srcOffsetY- the optional Y offset into our source data.srcTotalWidth- the total width of our source data, so we can properly walk through it.
-
checkCardError
Description copied from interface:RendererCheck the underlying rendering system (opengl, etc.) for exceptions.- Throws:
Ardor3dException- if an error is found.
-
draw
Description copied from interface:Rendererdrawrenders the renderable to the back buffer.- Parameters:
renderable- the text object to be rendered.
-
doTransforms
Description copied from interface:RendererdoTransformssets the current transform.- Parameters:
transform- transform to apply.- Returns:
trueif the transform has been applied
-
undoTransforms
Description copied from interface:RendererundoTransformsreverts the latest transform.- Parameters:
transform- transform to revert.
-
setupVertexData
-
setupNormalData
-
setupColorData
-
setupFogData
-
setupTextureData
-
drawElements
public void drawElements(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) -
setupVBO
-
setupVertexDataVBO
-
setupNormalDataVBO
-
setupColorDataVBO
-
setupFogDataVBO
-
setupTextureDataVBO
-
drawElementsVBO
public void drawElementsVBO(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) -
drawArrays
public void drawArrays(FloatBufferData vertexBuffer, int[] indexLengths, IndexMode[] indexModes, int primcount) -
unbindVBO
public void unbindVBO()Description copied from interface:RendererUnbind the current VBO elements. -
setModelViewMatrix
-
setProjectionMatrix
-
getModelViewMatrix
Description copied from interface:RendererGets the current model-view matrix in row major order- Parameters:
store- The buffer to store in. If null or remaining is < 16, a new FloatBuffer will be created and returned.- Returns:
- the model-view matrix
-
getProjectionMatrix
Description copied from interface:RendererGets the current projection matrix in row major order- Parameters:
store- The buffer to store in. If null or remaining is < 16, a new FloatBuffer will be created and returned.- Returns:
- the projection matrix
-
setViewport
public void setViewport(int x, int y, int width, int height) -
setDepthRange
public void setDepthRange(double depthRangeNear, double depthRangeFar) -
setDrawBuffer
Description copied from interface:RendererSpecify which color buffers are to be drawn into.- Parameters:
target- the target
-
setupLineParameters
public void setupLineParameters(float lineWidth, int stippleFactor, short stipplePattern, boolean antialiased) Description copied from interface:RendererThis is a workaround until we make shared Record classes, or open up lower level opengl calls abstracted from jogl.- Parameters:
lineWidth- the line widthstippleFactor- the stipple factorstipplePattern- the stipple patternantialiased-trueif anti-aliased
-
setupPointParameters
public void setupPointParameters(float pointSize, boolean antialiased, boolean isSprite, boolean useDistanceAttenuation, FloatBuffer attenuationCoefficients, float minPointSize, float maxPointSize) Description copied from interface:RendererThis is a workaround until we make shared Record classes, or open up lower level opengl calls abstracted from jogl.- Parameters:
pointSize- the point sizeantialiased-trueif anti-aliasedisSprite-trueif it is a spriteuseDistanceAttenuation-trueif the distance attenuation is enabledattenuationCoefficients- the attenuation coefficientsminPointSize- the points minimum sizemaxPointSize- the points maximum size
-
doApplyState
- Specified by:
doApplyStatein classAbstractRenderer
-
deleteTexture
Description copied from interface:RendererExplicitly remove this Texture from the graphics card. Note, the texture is only removed for the current context. If the texture is used in other contexts, those uses are not touched. If the texture is not used in this context, this is a no-op.- Parameters:
texture- the Texture object to remove.
-
loadTexture
Description copied from interface:RendererLoads a texture onto the card for the current OpenGL context.- Parameters:
texture- the texture object to load.unit- the texture unit to load into
-
deleteTextureIds
Description copied from interface:RendererRemoves the given texture ids from the current OpenGL context.- Parameters:
ids- a list/set of ids to remove.
-
startDisplayList
public int startDisplayList()Start a new display list. All further renderer commands that can be stored in a display list are part of this new list untilendDisplayList()is called.- Returns:
- id of new display list
-
endDisplayList
public void endDisplayList()Ends a display list. Will likely cause an OpenGL exception is a display list is not currently being generated. -
renderDisplayList
public void renderDisplayList(int displayListID) Draw the given display list. -
clearClips
public void clearClips()Description copied from interface:RendererClear all rectangles from the clip stack and disable clipping. -
popClip
public void popClip()Description copied from interface:RendererPop the most recent rectangle from the stack and adjust the rendering area accordingly. -
pushClip
Description copied from interface:RendererAdd the given rectangle to the clip stack, clipping the rendering area by the given rectangle intersected with any existing scissor entries. Enable clipping if this is the first rectangle in the stack.- Parameters:
rectangle- the rectangle
-
pushEmptyClip
public void pushEmptyClip()Description copied from interface:RendererPush a clip onto the stack indicating that future clips should not intersect with clips prior to this one. Basically this allows you to ignore prior clips for nested drawing. Make sure you pop this usingRenderer.popClip(). -
setClipTestEnabled
public void setClipTestEnabled(boolean enabled) - Parameters:
enabled- toggle clipping without effecting the current clip stack.
-
checkAndSetTextureArrayUnit
public void checkAndSetTextureArrayUnit(int unit, com.jogamp.opengl.GL gl, RendererRecord record, ContextCapabilities caps)
-