com.threerings.opengl.renderer
Class Renderer

java.lang.Object
  extended by com.threerings.opengl.renderer.Renderer

public class Renderer
extends Object

Provides access to state associated with the renderer. Any state changes made should be done through this object so that its internal state is synchronized with the OpenGL state.


Nested Class Summary
static interface Renderer.Observer
          An interface for objects interested in renderer state changes.
 
Constructor Summary
Renderer()
           
 
Method Summary
 void addObserver(Renderer.Observer observer)
          Adds an observer to the list of objects interested in state changes.
 void cleanup()
          Gives the renderer a chance to perform any periodic cleanup necessary.
 int getAlphaBits()
          Returns the number of alpha bit planes in the frame buffer.
 int getBatchCount()
          Returns the number of batches rendered since the last call to resetStats().
 float getBottom()
          Returns the bottom projection parameter.
 int getBufferObjectBytes()
          Returns the total number of bytes in buffer objects.
 int getBufferObjectCount()
          Returns the number of active buffer objects.
 Color4f getClearColor()
          Returns a reference to the clear color.
 float getClearDepth()
          Returns the clear depth.
 int getClearStencil()
          Returns the clear stencil value.
 int getDisplayListCount()
          Returns the number of active display lists.
 org.lwjgl.opengl.Drawable getDrawable()
          Returns a reference to the drawable target of this renderer.
 float getFar()
          Returns the far projection parameter.
 int getFrontFace()
          Returns the current front face.
 int getHeight()
          Returns the height of the renderer's drawable surface.
 float getLeft()
          Returns the left projection parameter.
 int getMaxClipPlanes()
          Returns the maximum number of user clip planes supported.
 int getMaxLights()
          Returns the maximum number of lights supported.
 int getMaxTextureImageUnits()
          Returns the maximum number of texture units usable with the programmable pipeline.
 int getMaxTextureUnits()
          Returns the maximum number of texture units usable with the fixed-function pipeline.
 int getMaxVertexAttribs()
          Returns the maximum number of vertex attributes available to vertex shaders.
 float getNear()
          Returns the near projection parameter.
 Vector3f getNearFarNormal()
          Returns a reference to the near/far normal projection parameter.
 int getPrimitiveCount()
          Returns the number of primitives rendered since the last call to resetStats().
 float getRight()
          Returns the right projection parameter.
 Rectangle getScissor()
          Returns a reference to the scissor box, or null if scissor testing is disabled.
 int getShaderObjectCount()
          Returns the number of active shader objects.
 int getStencilBits()
          Returns the number of stencil bit planes in the frame buffer.
 int getTextureBytes()
          Returns the total number of bytes in textures.
 int getTextureChangeCount()
          Returns the number of texture changes since the last call to resetStats().
 int getTextureCount()
          Returns the number of active textures.
 float getTop()
          Returns the top projection parameter.
 Rectangle getViewport()
          Returns the current viewport state.
 int getWidth()
          Returns the width of the renderer's drawable surface.
 void init(org.lwjgl.opengl.Drawable drawable, int width, int height)
          Initializes the renderer.
 void invalidateAlphaState()
          Invalidates the alpha state, forcing it to be reapplied.
 void invalidateArrayState()
          Invalidates the array state, forcing it to be reapplied.
 void invalidateColorMaskState()
          Invalidates the color mask state, forcing it to be reapplied.
 void invalidateColorState()
          Invalidates the color state, forcing it to be reapplied.
 void invalidateCullState()
          Invalidates the back-face culling state, forcing it to be reapplied.
 void invalidateDepthState()
          Invalidates the depth state, forcing it to be reapplied.
 void invalidateFogState()
          Invalidates the fog state, forcing it to be reapplied.
 void invalidateLightState()
          Invalidates the light state, forcing it to be reapplied.
 void invalidateLineState()
          Invalidates the line state, forcing it to be reapplied.
 void invalidateMaterialState()
          Invalidates the material state, forcing it to be reapplied.
 void invalidatePointState()
          Invalidates the point state, forcing it to be reapplied.
 void invalidatePolygonState()
          Invalidates the polygon state, forcing it to be reapplied.
 void invalidateShaderState()
          Invalidates the shader state, forcing it to be reapplied.
 void invalidateStencilState()
          Invalidates the stencil state, forcing it to be reapplied.
 void invalidateTextureState()
          Invalidates the texture state, forcing it to be reapplied.
 void invalidateTransformState()
          Invalidates the transform state, forcing it to be reapplied.
 boolean isOrtho()
          Returns the ortho projection parameter.
 void removeObserver(Renderer.Observer observer)
          Removes an observer from the list.
 void render(List<Batch> batches)
          Renders the provided list of batches.
 void resetStats()
          Resets the per-frame stats.
 void setAlphaState(int alphaTestFunc, float alphaTestRef, int srcBlendFactor, int destBlendFactor)
          Sets the alpha testing and blending state.
 void setArrayState(int firstVertexAttribIndex, ClientArray[] vertexAttribArrays, ClientArray[] texCoordArrays, ClientArray colorArray, ClientArray normalArray, ClientArray vertexArray, BufferObject elementArrayBuffer)
          Sets the client array state.
 void setClearColor(Color4f color)
          Sets the clear color.
 void setClearDepth(float depth)
          Sets the clear depth.
 void setClearStencil(int stencil)
          Sets the clear stencil value.
 void setClipPlanes(Plane[] planes)
          Sets the user clip planes.
 void setColorMaskState(boolean red, boolean green, boolean blue, boolean alpha)
          Sets the color mask state.
 void setColorState(Color4f color)
          Sets the draw color state.
 void setColorState(float r, float g, float b, float a)
          Sets the draw color state.
 void setCullState(int cullFace)
          Sets the back-face culling state.
 void setDepthState(int depthTestFunc, boolean depthMask)
          Sets the depth buffer testing/writing state.
 void setFogState(int fogMode, float fogDensity, Color4f fogColor)
          Sets the fog state.
 void setFogState(int fogMode, float fogStart, float fogEnd, Color4f fogColor)
          Sets the linear fog state.
 void setFrontFace(int face)
          Sets the front face.
 void setLightState(Light[] lights, Color4f globalAmbient)
          Sets the light state.
 void setLineState(float lineWidth)
          Sets the line state.
 void setMaterialState(Color4f frontAmbient, Color4f frontDiffuse, Color4f frontSpecular, Color4f frontEmission, float frontShininess, Color4f backAmbient, Color4f backDiffuse, Color4f backSpecular, Color4f backEmission, float backShininess, int colorMaterialMode, int colorMaterialFace, boolean twoSide, boolean localViewer, boolean separateSpecular, boolean flatShading)
          Sets the material state.
 void setMatrixMode(int matrixMode)
          Sets the matrix mode.
 void setNormalize(boolean normalize, boolean rescaleNormal)
          Sets the normalization parameters.
 void setPointState(float pointSize)
          Sets the point state.
 void setPolygonState(int frontPolygonMode, int backPolygonMode, float polygonOffsetFactor, float polygonOffsetUnits)
          Sets the polygon state.
 void setProjection(float left, float right, float bottom, float top, float near, float far, Vector3f nearFarNormal, boolean ortho)
          Sets the projection matrix.
 void setScissor(Rectangle box)
          Sets the scissor box.
 void setShaderState(Program program, boolean vertexProgramTwoSide)
          Sets the GLSL shader state.
 void setSize(int width, int height)
          Notes that the size of the renderer's drawable surface has changed.
 void setState(RenderState state)
          Sets a single render state.
 void setStates(RenderState[] states)
          Sets an entire group of states at once.
 void setStencilState(int stencilTestFunc, int stencilTestRef, int stencilTestMask, int stencilFailOp, int stencilDepthFailOp, int stencilPassOp, int stencilWriteMask)
          Sets the stencil state.
 void setTextureState(TextureUnit[] units)
          Sets the texture state.
 void setTransformState(Transform3D modelview)
          Sets the transform state.
 void setViewport(int x, int y, int width, int height)
          Sets the viewport state.
 void setViewport(Rectangle viewport)
          Sets the viewport state.
 void startQuery(Query query)
          Starts a query.
 void stopQuery(Query query)
          Stops a query.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Renderer

public Renderer()
Method Detail

init

public void init(org.lwjgl.opengl.Drawable drawable,
                 int width,
                 int height)
Initializes the renderer.

Parameters:
drawable - the drawable surface with which this renderer will be used.
width - the initial viewport width.
height - the initial viewport height.

getDrawable

public org.lwjgl.opengl.Drawable getDrawable()
Returns a reference to the drawable target of this renderer.


setSize

public void setSize(int width,
                    int height)
Notes that the size of the renderer's drawable surface has changed. This does not change the viewport, scissor region, etc.; it simply records the change and notifies the observers.


getWidth

public int getWidth()
Returns the width of the renderer's drawable surface.


getHeight

public int getHeight()
Returns the height of the renderer's drawable surface.


addObserver

public void addObserver(Renderer.Observer observer)
Adds an observer to the list of objects interested in state changes. Note that only a weak reference to the observer will be retained, and thus this will not prevent the observer from being garbage-collected.


removeObserver

public void removeObserver(Renderer.Observer observer)
Removes an observer from the list.


getAlphaBits

public int getAlphaBits()
Returns the number of alpha bit planes in the frame buffer.


getStencilBits

public int getStencilBits()
Returns the number of stencil bit planes in the frame buffer.


getMaxClipPlanes

public int getMaxClipPlanes()
Returns the maximum number of user clip planes supported.


getMaxLights

public int getMaxLights()
Returns the maximum number of lights supported.


getMaxTextureUnits

public int getMaxTextureUnits()
Returns the maximum number of texture units usable with the fixed-function pipeline.


getMaxTextureImageUnits

public int getMaxTextureImageUnits()
Returns the maximum number of texture units usable with the programmable pipeline.


getMaxVertexAttribs

public int getMaxVertexAttribs()
Returns the maximum number of vertex attributes available to vertex shaders.


getTextureChangeCount

public int getTextureChangeCount()
Returns the number of texture changes since the last call to resetStats().


getBatchCount

public int getBatchCount()
Returns the number of batches rendered since the last call to resetStats().


getPrimitiveCount

public int getPrimitiveCount()
Returns the number of primitives rendered since the last call to resetStats().


resetStats

public void resetStats()
Resets the per-frame stats.


getBufferObjectCount

public int getBufferObjectCount()
Returns the number of active buffer objects.


getBufferObjectBytes

public int getBufferObjectBytes()
Returns the total number of bytes in buffer objects.


getDisplayListCount

public int getDisplayListCount()
Returns the number of active display lists.


getShaderObjectCount

public int getShaderObjectCount()
Returns the number of active shader objects.


getTextureCount

public int getTextureCount()
Returns the number of active textures.


getTextureBytes

public int getTextureBytes()
Returns the total number of bytes in textures.


cleanup

public void cleanup()
Gives the renderer a chance to perform any periodic cleanup necessary.


setClearColor

public void setClearColor(Color4f color)
Sets the clear color.


getClearColor

public Color4f getClearColor()
Returns a reference to the clear color.


setClearDepth

public void setClearDepth(float depth)
Sets the clear depth.


getClearDepth

public float getClearDepth()
Returns the clear depth.


setClearStencil

public void setClearStencil(int stencil)
Sets the clear stencil value.


getClearStencil

public int getClearStencil()
Returns the clear stencil value.


setViewport

public void setViewport(Rectangle viewport)
Sets the viewport state.


setViewport

public void setViewport(int x,
                        int y,
                        int width,
                        int height)
Sets the viewport state.


getViewport

public Rectangle getViewport()
Returns the current viewport state.


setProjection

public void setProjection(float left,
                          float right,
                          float bottom,
                          float top,
                          float near,
                          float far,
                          Vector3f nearFarNormal,
                          boolean ortho)
Sets the projection matrix.


getLeft

public float getLeft()
Returns the left projection parameter.


getRight

public float getRight()
Returns the right projection parameter.


getBottom

public float getBottom()
Returns the bottom projection parameter.


getTop

public float getTop()
Returns the top projection parameter.


getNear

public float getNear()
Returns the near projection parameter.


getFar

public float getFar()
Returns the far projection parameter.


getNearFarNormal

public Vector3f getNearFarNormal()
Returns a reference to the near/far normal projection parameter.


isOrtho

public boolean isOrtho()
Returns the ortho projection parameter.


setClipPlanes

public void setClipPlanes(Plane[] planes)
Sets the user clip planes.

Parameters:
planes - the array of clip planes to set, or null to disable all planes.

setScissor

public void setScissor(Rectangle box)
Sets the scissor box.

Parameters:
box - the scissor box, or null to disable the scissor test.

getScissor

public Rectangle getScissor()
Returns a reference to the scissor box, or null if scissor testing is disabled.


setFrontFace

public void setFrontFace(int face)
Sets the front face.


getFrontFace

public int getFrontFace()
Returns the current front face.


setNormalize

public void setNormalize(boolean normalize,
                         boolean rescaleNormal)
Sets the normalization parameters.


startQuery

public void startQuery(Query query)
Starts a query.


stopQuery

public void stopQuery(Query query)
Stops a query.


setStates

public void setStates(RenderState[] states)
Sets an entire group of states at once.


setState

public void setState(RenderState state)
Sets a single render state.


setAlphaState

public void setAlphaState(int alphaTestFunc,
                          float alphaTestRef,
                          int srcBlendFactor,
                          int destBlendFactor)
Sets the alpha testing and blending state. If alphaTestFunc is GL11.GL_ALWAYS, alpha testing will be disabled. If srcBlendFactor is GL11.GL_ONE and destBlendFactor is GL11.GL_ZERO, blending will be disabled.


invalidateAlphaState

public void invalidateAlphaState()
Invalidates the alpha state, forcing it to be reapplied.


setArrayState

public void setArrayState(int firstVertexAttribIndex,
                          ClientArray[] vertexAttribArrays,
                          ClientArray[] texCoordArrays,
                          ClientArray colorArray,
                          ClientArray normalArray,
                          ClientArray vertexArray,
                          BufferObject elementArrayBuffer)
Sets the client array state.


invalidateArrayState

public void invalidateArrayState()
Invalidates the array state, forcing it to be reapplied.


setColorState

public void setColorState(Color4f color)
Sets the draw color state.


setColorState

public void setColorState(float r,
                          float g,
                          float b,
                          float a)
Sets the draw color state.


invalidateColorState

public void invalidateColorState()
Invalidates the color state, forcing it to be reapplied.


setColorMaskState

public void setColorMaskState(boolean red,
                              boolean green,
                              boolean blue,
                              boolean alpha)
Sets the color mask state.


invalidateColorMaskState

public void invalidateColorMaskState()
Invalidates the color mask state, forcing it to be reapplied.


setCullState

public void setCullState(int cullFace)
Sets the back-face culling state.


invalidateCullState

public void invalidateCullState()
Invalidates the back-face culling state, forcing it to be reapplied.


setDepthState

public void setDepthState(int depthTestFunc,
                          boolean depthMask)
Sets the depth buffer testing/writing state. If depthTestFunc is GL11.GL_ALWAYS and depthMask is false, depth testing will be disabled.


invalidateDepthState

public void invalidateDepthState()
Invalidates the depth state, forcing it to be reapplied.


setFogState

public void setFogState(int fogMode,
                        float fogDensity,
                        Color4f fogColor)
Sets the fog state. If fogMode is -1, fog will be disabled.


setFogState

public void setFogState(int fogMode,
                        float fogStart,
                        float fogEnd,
                        Color4f fogColor)
Sets the linear fog state. If fogMode is -1, fog will be disabled.


invalidateFogState

public void invalidateFogState()
Invalidates the fog state, forcing it to be reapplied.


setLightState

public void setLightState(Light[] lights,
                          Color4f globalAmbient)
Sets the light state. If lights is null, lighting will be disabled.


invalidateLightState

public void invalidateLightState()
Invalidates the light state, forcing it to be reapplied.


setLineState

public void setLineState(float lineWidth)
Sets the line state.


invalidateLineState

public void invalidateLineState()
Invalidates the line state, forcing it to be reapplied.


setMaterialState

public void setMaterialState(Color4f frontAmbient,
                             Color4f frontDiffuse,
                             Color4f frontSpecular,
                             Color4f frontEmission,
                             float frontShininess,
                             Color4f backAmbient,
                             Color4f backDiffuse,
                             Color4f backSpecular,
                             Color4f backEmission,
                             float backShininess,
                             int colorMaterialMode,
                             int colorMaterialFace,
                             boolean twoSide,
                             boolean localViewer,
                             boolean separateSpecular,
                             boolean flatShading)
Sets the material state.


invalidateMaterialState

public void invalidateMaterialState()
Invalidates the material state, forcing it to be reapplied.


setPointState

public void setPointState(float pointSize)
Sets the point state.


invalidatePointState

public void invalidatePointState()
Invalidates the point state, forcing it to be reapplied.


setPolygonState

public void setPolygonState(int frontPolygonMode,
                            int backPolygonMode,
                            float polygonOffsetFactor,
                            float polygonOffsetUnits)
Sets the polygon state.


invalidatePolygonState

public void invalidatePolygonState()
Invalidates the polygon state, forcing it to be reapplied.


setShaderState

public void setShaderState(Program program,
                           boolean vertexProgramTwoSide)
Sets the GLSL shader state.


invalidateShaderState

public void invalidateShaderState()
Invalidates the shader state, forcing it to be reapplied.


setStencilState

public void setStencilState(int stencilTestFunc,
                            int stencilTestRef,
                            int stencilTestMask,
                            int stencilFailOp,
                            int stencilDepthFailOp,
                            int stencilPassOp,
                            int stencilWriteMask)
Sets the stencil state.


invalidateStencilState

public void invalidateStencilState()
Invalidates the stencil state, forcing it to be reapplied.


setTextureState

public void setTextureState(TextureUnit[] units)
Sets the texture state.


invalidateTextureState

public void invalidateTextureState()
Invalidates the texture state, forcing it to be reapplied.


setTransformState

public void setTransformState(Transform3D modelview)
Sets the transform state.


invalidateTransformState

public void invalidateTransformState()
Invalidates the transform state, forcing it to be reapplied.


setMatrixMode

public void setMatrixMode(int matrixMode)
Sets the matrix mode.


render

public void render(List<Batch> batches)
Renders the provided list of batches.



Copyright © 2011. All Rights Reserved.