Package com.ardor3d.renderer
Interface Renderer
- All Known Implementing Classes:
AbstractRenderer
,JoglRenderer
public interface Renderer
Renderer
defines an interface for classes that handle displaying of graphics data to a render context.
All rendering state and tasks should be handled through this class.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Often a higher precision buffer used to gather rendering results over time.static final int
A buffer storing color information generally for display to the user.static final int
Convenience for those that find it too hard to do bitwise or. :)static final int
A depth buffer allows sorting of pixels by depth or distance from the view port.static final int
No buffer.static final int
A buffer used for masking out areas of the screen to prevent drawing. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyDefaultColor
(ReadOnlyColorRGBA defaultColor) void
applyNormalsMode
(NormalsMode normMode, ReadOnlyTransform worldTransform) void
applyState
(RenderState.StateType type, RenderState state) Apply the given state to the current RenderContext using this Renderer.boolean
Check a given Spatial to see if it should be queued. return true if it was queued.void
Check the underlying rendering system (opengl, etc.) for exceptions.void
clearBuffers
(int buffers) clearBuffers
clears the given buffers (specified as a bitwise &).void
clearBuffers
(int buffers, boolean strict) clearBuffers
clears the given buffers (specified as a bitwise &).void
Clear all rectangles from the clip stack and disable clipping.void
clear the render queuevoid
deleteDisplayLists
(Collection<Integer> collection) Removes the given display lists by id from the current OpenGL context.void
deleteTexture
(Texture texture) Explicitly remove this Texture from the graphics card.void
Removes the given texture ids from the current OpenGL context.void
deleteVBOs
(AbstractBufferData<?> buffer) Attempts to delete any VBOs associated with this buffer that are relevant to the current RenderContext.void
deleteVBOs
(Collection<Integer> ids) Attempts to delete the VBOs with the given id.boolean
doTransforms
(ReadOnlyTransform transform) doTransforms
sets the current transform.void
draw
(Renderable renderable) draw
renders the renderable to the back buffer.void
draw
renders a scene.void
drawArrays
(FloatBufferData vertexBuffer, int[] indexLengths, IndexMode[] indexModes, int primcount) void
drawElements
(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) void
drawElementsVBO
(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) void
Ends a display list.void
finish
is similar to flush, however it blocks until all waiting hardware graphics commands have been finished.void
flushFrame
(boolean doSwap) flushFrame
handles rendering any items still remaining in the render buckets and optionally swaps the back buffer with the currently displayed buffer.void
flush
tells the graphics hardware to send through all currently waiting commands in the buffer.getBackgroundColor
retrieves the clear color of the current OpenGL context.int
getExpectedBufferSizeToGrabScreenContents
(ImageDataFormat format, PixelDataType type, int w, int h) Gets the expected size (in bytes) of the buffer used to callgrabScreenContents
getModelViewMatrix
(FloatBuffer store) Gets the current model-view matrix in row major ordergetProjectionMatrix
(FloatBuffer store) Gets the current projection matrix in row major ordergetProperRenderState
(RenderState.StateType type, RenderState current) getQueue()
Get the render queue associated with this Renderer.void
grabScreenContents
(ByteBuffer store, ImageDataFormat format, int x, int y, int w, int h) grabScreenContents
reads a block of data as bytes from the current framebuffer.void
grabScreenContents
(ByteBuffer store, ImageDataFormat format, PixelDataType type, int x, int y, int w, int h) boolean
boolean
boolean
Return true if this renderer is in the middle of processing its RenderQueue.void
loadTexture
(Texture texture, int unit) Loads a texture onto the card for the current OpenGL context.void
popClip()
Pop the most recent rectangle from the stack and adjust the rendering area accordingly.void
pushClip
(ReadOnlyRectangle2 rectangle) Add the given rectangle to the clip stack, clipping the rendering area by the given rectangle intersected with any existing scissor entries.void
Push a clip onto the stack indicating that future clips should not intersect with clips prior to this one.void
render queues - will first sort, then render, then finally clear the queuevoid
renderBuckets
(boolean doSort, boolean doClear) render queuesvoid
renderDisplayList
(int displayListID) void
setBackgroundColor
sets the color of window.void
setClipTestEnabled
(boolean enabled) void
setDepthRange
(double depthRangeNear, double depthRangeFar) void
setDrawBuffer
(DrawBufferTarget target) Specify which color buffers are to be drawn into.void
setModelViewMatrix
(FloatBuffer matrix) void
setOrtho()
setOrtho
sets the display system to be in orthographic mode.void
setProjectionMatrix
(FloatBuffer matrix) void
setRenderLogic
(RenderLogic logic) Set rendering logic that will be called during drawing of renderablesvoid
setupColorData
(FloatBufferData colorCoords) void
setupColorDataVBO
(FloatBufferData colorCoords) void
setupFogData
(FloatBufferData fogCoords) void
setupFogDataVBO
(FloatBufferData fogCoords) void
setupLineParameters
(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.void
setupNormalData
(FloatBufferData normalCoords) void
setupNormalDataVBO
(FloatBufferData normalCoords) void
setupPointParameters
(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.void
setupTextureData
(List<FloatBufferData> textureCoords) void
setupTextureDataVBO
(List<FloatBufferData> textureCoords) void
setupVertexData
(FloatBufferData vertexCoords) void
setupVertexDataVBO
(FloatBufferData vertexCoords) void
setViewport
(int x, int y, int width, int height) int
Start a new display list.void
Unbind the current VBO elements.void
undoTransforms
(ReadOnlyTransform transform) undoTransforms
reverts the latest transform.void
unsetOrhto
unsets the display system from orthographic mode back into regular projection mode.void
updateTexture1DSubImage
(Texture1D destination, int dstOffsetX, int dstWidth, ByteBuffer source, int srcOffsetX) Update all or a portion of an existing one dimensional texture object.void
updateTexture2DSubImage
(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.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) Update all or a portion of an existing one dimensional texture object.void
updateTextureCubeMapSubImage
(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.
-
Field Details
-
BUFFER_NONE
static final int BUFFER_NONENo buffer.- See Also:
-
BUFFER_COLOR
static final int BUFFER_COLORA buffer storing color information generally for display to the user.- See Also:
-
BUFFER_DEPTH
static final int BUFFER_DEPTHA depth buffer allows sorting of pixels by depth or distance from the view port.- See Also:
-
BUFFER_ACCUMULATION
static final int BUFFER_ACCUMULATIONOften a higher precision buffer used to gather rendering results over time.- See Also:
-
BUFFER_STENCIL
static final int BUFFER_STENCILA buffer used for masking out areas of the screen to prevent drawing.- See Also:
-
BUFFER_COLOR_AND_DEPTH
static final int BUFFER_COLOR_AND_DEPTHConvenience for those that find it too hard to do bitwise or. :)- See Also:
-
-
Method Details
-
setBackgroundColor
setBackgroundColor
sets 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.
-
getBackgroundColor
ReadOnlyColorRGBA getBackgroundColor()getBackgroundColor
retrieves the clear color of the current OpenGL context.- Returns:
- the current clear color.
-
clearBuffers
void clearBuffers(int buffers) clearBuffers
clears the given buffers (specified as a bitwise &).- Parameters:
buffers
- the buffers to clear.- See Also:
-
clearBuffers
void clearBuffers(int buffers, boolean strict) clearBuffers
clears 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
void flushFrame(boolean doSwap) flushFrame
handles 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
void setOrtho()setOrtho
sets the display system to be in orthographic mode. If the system has already been set to orthographic mode aArdor3dException
is thrown. The origin (0,0) is the bottom left of the screen. -
unsetOrtho
void unsetOrtho()unsetOrhto
unsets the display system from orthographic mode back into regular projection mode. If the system is not in orthographic mode aArdor3dException
is thrown. -
isInOrthoMode
boolean isInOrthoMode()- Returns:
- true if the renderer is currently in ortho mode.
-
renderBuckets
void renderBuckets()render queues - will first sort, then render, then finally clear the queue -
renderBuckets
void renderBuckets(boolean doSort, boolean doClear) render queues- Parameters:
doSort
- if true, the queues will be sorted prior to rendering.doClear
- if true, the queues will be emptied after rendering.
-
clearQueue
void clearQueue()clear the render queue -
grabScreenContents
grabScreenContents
reads a block of data as bytes from the current framebuffer. The format determines how many bytes per pixel are read and thus how big the buffer must be that you pass in.- Parameters:
store
- a buffer to store contents in.format
- the format to read in bytes for.x
- - x starting point of blocky
- - y starting point of blockw
- - width of blockh
- - height of block
-
grabScreenContents
void grabScreenContents(ByteBuffer store, ImageDataFormat format, PixelDataType type, int x, int y, int w, int h) -
getExpectedBufferSizeToGrabScreenContents
int getExpectedBufferSizeToGrabScreenContents(ImageDataFormat format, PixelDataType type, int w, int h) Gets the expected size (in bytes) of the buffer used to callgrabScreenContents
- 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
draw
renders a scene. As it receives a base class ofSpatial
the renderer hands off management of the scene to spatial for it to determine when aGeometry
leaf is reached.- Parameters:
s
- the scene to render.
-
flushGraphics
void flushGraphics()flush
tells the graphics hardware to send through all currently waiting commands in the buffer. -
finishGraphics
void finishGraphics()finish
is similar to flush, however it blocks until all waiting hardware graphics commands have been finished. -
getQueue
RenderQueue getQueue()Get the render queue associated with this Renderer.- Returns:
- RenderQueue
-
isProcessingQueue
boolean isProcessingQueue()Return true if this renderer is in the middle of processing its RenderQueue.- Returns:
- boolean
-
checkAndAdd
Check 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.
-
deleteVBOs
Attempts to delete the VBOs with the given id. Ignores null ids or ids < 1.- Parameters:
ids
- the identifiers
-
deleteVBOs
Attempts to delete any VBOs associated with this buffer that are relevant to the current RenderContext.- Parameters:
buffer
- the buffer data
-
unbindVBO
void unbindVBO()Unbind the current VBO elements. -
updateTexture1DSubImage
void updateTexture1DSubImage(Texture1D destination, int dstOffsetX, int dstWidth, ByteBuffer source, int srcOffsetX) Update 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
void updateTexture2DSubImage(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.- 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
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) Update 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
void updateTextureCubeMapSubImage(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.- 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
Check the underlying rendering system (opengl, etc.) for exceptions.- Throws:
Ardor3dException
- if an error is found.
-
draw
draw
renders the renderable to the back buffer.- Parameters:
renderable
- the text object to be rendered.
-
doTransforms
doTransforms
sets the current transform.- Parameters:
transform
- transform to apply.- Returns:
true
if the transform has been applied
-
undoTransforms
undoTransforms
reverts the latest transform.- Parameters:
transform
- transform to revert.
-
setupVertexData
-
setupNormalData
-
setupColorData
-
setupFogData
-
setupTextureData
-
drawElements
void drawElements(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) -
drawArrays
void drawArrays(FloatBufferData vertexBuffer, int[] indexLengths, IndexMode[] indexModes, int primcount) -
drawElementsVBO
void drawElementsVBO(IndexBufferData<?> indices, int[] indexLengths, IndexMode[] indexModes, int primcount) -
applyNormalsMode
-
applyDefaultColor
-
setupVertexDataVBO
-
setupNormalDataVBO
-
setupColorDataVBO
-
setupFogDataVBO
-
setupTextureDataVBO
-
renderDisplayList
void renderDisplayList(int displayListID) -
setProjectionMatrix
-
getProjectionMatrix
Gets 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
-
setModelViewMatrix
-
getModelViewMatrix
Gets 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
-
setViewport
void setViewport(int x, int y, int width, int height) -
setDepthRange
void setDepthRange(double depthRangeNear, double depthRangeFar) -
setDrawBuffer
Specify which color buffers are to be drawn into.- Parameters:
target
- the target
-
setupLineParameters
void setupLineParameters(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.- Parameters:
lineWidth
- the line widthstippleFactor
- the stipple factorstipplePattern
- the stipple patternantialiased
-true
if anti-aliased
-
setupPointParameters
void setupPointParameters(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.- Parameters:
pointSize
- the point sizeantialiased
-true
if anti-aliasedisSprite
-true
if it is a spriteuseDistanceAttenuation
-true
if the distance attenuation is enabledattenuationCoefficients
- the attenuation coefficientsminPointSize
- the points minimum sizemaxPointSize
- the points maximum size
-
applyState
Apply the given state to the current RenderContext using this Renderer.- Parameters:
type
- the state typestate
- the render state. If null, the renderer's default is applied instead.
-
startDisplayList
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
void endDisplayList()Ends a display list. Will likely cause an OpenGL exception if a display list is not currently being generated. -
loadTexture
Loads a texture onto the card for the current OpenGL context.- Parameters:
texture
- the texture object to load.unit
- the texture unit to load into
-
deleteTexture
Explicitly 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.
-
deleteTextureIds
Removes the given texture ids from the current OpenGL context.- Parameters:
ids
- a list/set of ids to remove.
-
deleteDisplayLists
Removes the given display lists by id from the current OpenGL context.- Parameters:
collection
- a list/set of ids to remove.
-
pushClip
Add 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
void pushEmptyClip()Push 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 usingpopClip()
. -
popClip
void popClip()Pop the most recent rectangle from the stack and adjust the rendering area accordingly. -
clearClips
void clearClips()Clear all rectangles from the clip stack and disable clipping. -
setClipTestEnabled
void setClipTestEnabled(boolean enabled) - Parameters:
enabled
- toggle clipping without effecting the current clip stack.
-
isClipTestEnabled
boolean isClipTestEnabled()- Returns:
- true if the renderer believes clipping is enabled
-
getProperRenderState
- Parameters:
type
- the state type to grabcurrent
- the current render state- Returns:
- the appropriate render state for the current context for the current type. This is the enforced state if one exists or the given current state if not null. Otherwise, the Renderer's default state is returned.
-
setRenderLogic
Set rendering logic that will be called during drawing of renderables- Parameters:
logic
- logic to use in rendering. call with null to reset rendering.- See Also:
-