com.jme3.renderer.android
Class OGLESShaderRenderer

java.lang.Object
  extended by com.jme3.renderer.android.OGLESShaderRenderer
All Implemented Interfaces:
Renderer

public class OGLESShaderRenderer
extends java.lang.Object
implements Renderer


Constructor Summary
OGLESShaderRenderer()
           
 
Method Summary
 void applyRenderState(RenderState state)
          Applies the given RenderState, making the necessary GL calls so that the state is applied.
protected  void bindProgram(Shader shader)
           
 void cleanup()
          Deletes all previously used Native Objects on this Renderer, and then resets the native objects.
 void clearBuffers(boolean color, boolean depth, boolean stencil)
          Clears certain channels of the currently bound framebuffer.
 void clearClipRect()
          Clears the clipping rectangle set with Renderer.setClipRect(int, int, int, int).
 void clearTextureUnits()
           
 void clearVertexAttribs()
           
 int convertElementMode(Mesh.Mode mode)
          \ |* Render Calls *| \
 int convertShaderType(Shader.ShaderType type)
           
 void copyFrameBuffer(FrameBuffer src, FrameBuffer dst)
          \ |* Framebuffers *| \
 void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth)
          Copies contents from src to dst, scaling if necessary.
 void deleteBuffer(VertexBuffer vb)
          Deletes a vertex buffer from the GPU.
 void deleteFrameBuffer(FrameBuffer fb)
          Deletes a framebuffer and all attached renderbuffers
 void deleteImage(Image image)
          Deletes a texture from the GPU.
 void deleteShader(Shader shader)
          Deletes a shader.
 void deleteShaderSource(Shader.ShaderSource source)
          Deletes the provided shader source.
 void drawTriangleArray(Mesh.Mode mode, int count, int vertCount)
           
 void drawTriangleList_Array(VertexBuffer indexBuf, Mesh mesh, int count)
          drawTriangleList_Array uses Vertex Array
 void drawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count)
           
 java.util.EnumSet<Caps> getCaps()
          Get the capabilities of the renderer.
 Statistics getStatistics()
          The statistics allow tracking of how data per frame, such as number of objects rendered, number of triangles, etc.
 void initialize()
           
 void invalidateState()
          Invalidates the current rendering state.
 void onFrame()
          Called when a new frame has been rendered.
 void readFrameBuffer(FrameBuffer fb, java.nio.ByteBuffer byteBuf)
          Reads the pixels currently stored in the specified framebuffer into the given ByteBuffer object.
 void renderMesh(Mesh mesh, int lod, int count)
          Renders count meshes, with the geometry data supplied.
 void resetGLObjects()
          resetGLObjects should be called when die GLView gets recreated to reset all GPU objects
protected  void resetUniformLocations(Shader shader)
           
 void setAlphaToCoverage(boolean value)
          Sets the alpha to coverage state.
 void setBackgroundColor(ColorRGBA color)
          Sets the background (aka clear) color.
 void setClipRect(int x, int y, int width, int height)
          Specifies a clipping rectangle.
 void setDepthRange(float start, float end)
          \ |* Render State *| \
 void setFrameBuffer(FrameBuffer fb)
          Sets the framebuffer that will be drawn to.
 void setLighting(LightList list)
          Set lighting state.
 void setMainFrameBufferOverride(FrameBuffer fb)
          Set the framebuffer that will be set instead of the main framebuffer when a call to setFrameBuffer(null) is made.
 void setShader(Shader shader)
          Sets the shader to use for rendering.
 void setTexture(int unit, Texture tex)
          Sets the texture to use for the given texture unit.
 void setVertexAttrib_Array(VertexBuffer vb)
          setVertexAttrib_Array uses Vertex Array
 void setVertexAttrib_Array(VertexBuffer vb, VertexBuffer idb)
          setVertexAttrib_Array uses Vertex Array
 void setVertexAttrib(VertexBuffer vb)
           
 void setVertexAttrib(VertexBuffer vb, VertexBuffer idb)
           
 void setViewPort(int x, int y, int w, int h)
          \ |* Camera and World transforms *| \
 void setViewProjectionMatrices(Matrix4f viewMatrix, Matrix4f projMatrix)
          Sets the view and projection matrices to use.
 void setWorldMatrix(Matrix4f worldMatrix)
          Set the world matrix to use.
 void updateBufferData(VertexBuffer vb)
          Uploads a vertex buffer to the GPU.
 void updateFrameBuffer(FrameBuffer fb)
           
 void updateFrameBufferAttachment(FrameBuffer fb, FrameBuffer.RenderBuffer rb)
           
protected  void updateNameBuffer()
           
 void updateRenderTexture(FrameBuffer fb, FrameBuffer.RenderBuffer rb)
           
 void updateShaderData(Shader shader)
           
 void updateShaderSourceData(Shader.ShaderSource source)
           
protected  void updateShaderUniforms(Shader shader)
           
 void updateTexImageData(Image img, Texture.Type type, boolean needMips)
          updateTexImageData activates and binds the texture
protected  void updateUniform(Shader shader, Uniform uniform)
           
protected  void updateUniformLocation(Shader shader, Uniform uniform)
          \ |* Shaders *| \
 void updateVertexArray(Mesh mesh)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OGLESShaderRenderer

public OGLESShaderRenderer()
Method Detail

updateNameBuffer

protected void updateNameBuffer()

getStatistics

public Statistics getStatistics()
Description copied from interface: Renderer
The statistics allow tracking of how data per frame, such as number of objects rendered, number of triangles, etc. These are updated when the Renderer's methods are used, make sure to call Statistics.clearFrame() at the appropriate time to get accurate info per frame.

Specified by:
getStatistics in interface Renderer

getCaps

public java.util.EnumSet<Caps> getCaps()
Description copied from interface: Renderer
Get the capabilities of the renderer.

Specified by:
getCaps in interface Renderer
Returns:
The capabilities of the renderer.

initialize

public void initialize()

resetGLObjects

public void resetGLObjects()
resetGLObjects should be called when die GLView gets recreated to reset all GPU objects

Specified by:
resetGLObjects in interface Renderer
See Also:
NativeObject.resetObject()

cleanup

public void cleanup()
Description copied from interface: Renderer
Deletes all previously used Native Objects on this Renderer, and then resets the native objects.

Specified by:
cleanup in interface Renderer
See Also:
Renderer.resetGLObjects(), NativeObject#deleteObject(com.jme3.renderer.Renderer)

setDepthRange

public void setDepthRange(float start,
                          float end)
\ |* Render State *| \

Specified by:
setDepthRange in interface Renderer
Parameters:
start - The range start
end - The range end

clearBuffers

public void clearBuffers(boolean color,
                         boolean depth,
                         boolean stencil)
Description copied from interface: Renderer
Clears certain channels of the currently bound framebuffer.

Specified by:
clearBuffers in interface Renderer
Parameters:
color - True if to clear colors (RGBA)
depth - True if to clear depth/z
stencil - True if to clear stencil buffer (if available, otherwise ignored)

setBackgroundColor

public void setBackgroundColor(ColorRGBA color)
Description copied from interface: Renderer
Sets the background (aka clear) color.

Specified by:
setBackgroundColor in interface Renderer
Parameters:
color - The background color to set

applyRenderState

public void applyRenderState(RenderState state)
Description copied from interface: Renderer
Applies the given RenderState, making the necessary GL calls so that the state is applied.

Specified by:
applyRenderState in interface Renderer

setViewPort

public void setViewPort(int x,
                        int y,
                        int w,
                        int h)
\ |* Camera and World transforms *| \

Specified by:
setViewPort in interface Renderer
Parameters:
x - The x coordinate of the viewport
y - The y coordinate of the viewport
w - Width of the viewport
h - Height of the viewport

setClipRect

public void setClipRect(int x,
                        int y,
                        int width,
                        int height)
Description copied from interface: Renderer
Specifies a clipping rectangle. For all future rendering commands, no pixels will be allowed to be rendered outside of the clip rectangle.

Specified by:
setClipRect in interface Renderer
Parameters:
x - The x coordinate of the clip rect
y - The y coordinate of the clip rect
width - Width of the clip rect
height - Height of the clip rect

clearClipRect

public void clearClipRect()
Description copied from interface: Renderer
Clears the clipping rectangle set with Renderer.setClipRect(int, int, int, int).

Specified by:
clearClipRect in interface Renderer

onFrame

public void onFrame()
Description copied from interface: Renderer
Called when a new frame has been rendered.

Specified by:
onFrame in interface Renderer

setWorldMatrix

public void setWorldMatrix(Matrix4f worldMatrix)
Description copied from interface: Renderer
Set the world matrix to use. Does nothing if the Renderer is shader based.

Specified by:
setWorldMatrix in interface Renderer
Parameters:
worldMatrix - World matrix to use.

setViewProjectionMatrices

public void setViewProjectionMatrices(Matrix4f viewMatrix,
                                      Matrix4f projMatrix)
Description copied from interface: Renderer
Sets the view and projection matrices to use. Does nothing if the Renderer is shader based.

Specified by:
setViewProjectionMatrices in interface Renderer
Parameters:
viewMatrix - The view matrix to use.
projMatrix - The projection matrix to use.

updateUniformLocation

protected void updateUniformLocation(Shader shader,
                                     Uniform uniform)
\ |* Shaders *| \


bindProgram

protected void bindProgram(Shader shader)

updateUniform

protected void updateUniform(Shader shader,
                             Uniform uniform)

updateShaderUniforms

protected void updateShaderUniforms(Shader shader)

resetUniformLocations

protected void resetUniformLocations(Shader shader)

setLighting

public void setLighting(LightList list)
Description copied from interface: Renderer
Set lighting state. Does nothing if the renderer is shader based. The lights should be provided in world space. Specify null to disable lighting.

Specified by:
setLighting in interface Renderer
Parameters:
list - The light list to set.

convertShaderType

public int convertShaderType(Shader.ShaderType type)

updateShaderSourceData

public void updateShaderSourceData(Shader.ShaderSource source)

updateShaderData

public void updateShaderData(Shader shader)

setShader

public void setShader(Shader shader)
Description copied from interface: Renderer
Sets the shader to use for rendering. If the shader has not been uploaded yet, it is compiled and linked. If it has been uploaded, then the uniform data is updated and the shader is set.

Specified by:
setShader in interface Renderer
Parameters:
shader - The shader to use for rendering.

deleteShaderSource

public void deleteShaderSource(Shader.ShaderSource source)
Description copied from interface: Renderer
Deletes the provided shader source.

Specified by:
deleteShaderSource in interface Renderer
Parameters:
source - The ShaderSource to delete.

deleteShader

public void deleteShader(Shader shader)
Description copied from interface: Renderer
Deletes a shader. This method also deletes the attached shader sources.

Specified by:
deleteShader in interface Renderer
Parameters:
shader - Shader to delete.

copyFrameBuffer

public void copyFrameBuffer(FrameBuffer src,
                            FrameBuffer dst)
\ |* Framebuffers *| \

Specified by:
copyFrameBuffer in interface Renderer

copyFrameBuffer

public void copyFrameBuffer(FrameBuffer src,
                            FrameBuffer dst,
                            boolean copyDepth)
Description copied from interface: Renderer
Copies contents from src to dst, scaling if necessary. set copyDepth to false to only copy the color buffers.

Specified by:
copyFrameBuffer in interface Renderer

updateRenderTexture

public void updateRenderTexture(FrameBuffer fb,
                                FrameBuffer.RenderBuffer rb)

updateFrameBufferAttachment

public void updateFrameBufferAttachment(FrameBuffer fb,
                                        FrameBuffer.RenderBuffer rb)

updateFrameBuffer

public void updateFrameBuffer(FrameBuffer fb)

setMainFrameBufferOverride

public void setMainFrameBufferOverride(FrameBuffer fb)
Description copied from interface: Renderer
Set the framebuffer that will be set instead of the main framebuffer when a call to setFrameBuffer(null) is made.

Specified by:
setMainFrameBufferOverride in interface Renderer

setFrameBuffer

public void setFrameBuffer(FrameBuffer fb)
Description copied from interface: Renderer
Sets the framebuffer that will be drawn to.

Specified by:
setFrameBuffer in interface Renderer

readFrameBuffer

public void readFrameBuffer(FrameBuffer fb,
                            java.nio.ByteBuffer byteBuf)
Description copied from interface: Renderer
Reads the pixels currently stored in the specified framebuffer into the given ByteBuffer object. Only color pixels are transferred, the format is BGRA with 8 bits per component. The given byte buffer should have at least fb.getWidth() * fb.getHeight() * 4 bytes remaining.

Specified by:
readFrameBuffer in interface Renderer
Parameters:
fb - The framebuffer to read from
byteBuf - The bytebuffer to transfer color data to

deleteFrameBuffer

public void deleteFrameBuffer(FrameBuffer fb)
Description copied from interface: Renderer
Deletes a framebuffer and all attached renderbuffers

Specified by:
deleteFrameBuffer in interface Renderer

updateTexImageData

public void updateTexImageData(Image img,
                               Texture.Type type,
                               boolean needMips)
updateTexImageData activates and binds the texture

Parameters:
img -
type -
needMips -

setTexture

public void setTexture(int unit,
                       Texture tex)
Description copied from interface: Renderer
Sets the texture to use for the given texture unit.

Specified by:
setTexture in interface Renderer

clearTextureUnits

public void clearTextureUnits()

deleteImage

public void deleteImage(Image image)
Description copied from interface: Renderer
Deletes a texture from the GPU.

Specified by:
deleteImage in interface Renderer

updateBufferData

public void updateBufferData(VertexBuffer vb)
Description copied from interface: Renderer
Uploads a vertex buffer to the GPU.

Specified by:
updateBufferData in interface Renderer
Parameters:
vb - The vertex buffer to upload

deleteBuffer

public void deleteBuffer(VertexBuffer vb)
Description copied from interface: Renderer
Deletes a vertex buffer from the GPU.

Specified by:
deleteBuffer in interface Renderer
Parameters:
vb - The vertex buffer to delete

clearVertexAttribs

public void clearVertexAttribs()

setVertexAttrib

public void setVertexAttrib(VertexBuffer vb,
                            VertexBuffer idb)

setVertexAttrib

public void setVertexAttrib(VertexBuffer vb)

drawTriangleArray

public void drawTriangleArray(Mesh.Mode mode,
                              int count,
                              int vertCount)

drawTriangleList

public void drawTriangleList(VertexBuffer indexBuf,
                             Mesh mesh,
                             int count)

convertElementMode

public int convertElementMode(Mesh.Mode mode)
\ |* Render Calls *| \


updateVertexArray

public void updateVertexArray(Mesh mesh)

renderMesh

public void renderMesh(Mesh mesh,
                       int lod,
                       int count)
Description copied from interface: Renderer
Renders count meshes, with the geometry data supplied. The shader which is currently set with setShader is responsible for transforming the input verticies into clip space and shading it based on the given vertex attributes. The int variable gl_InstanceID can be used to access the current instance of the mesh being rendered inside the vertex shader.

Specified by:
renderMesh in interface Renderer
Parameters:
mesh - The mesh to render
lod - The LOD level to use, see Mesh.setLodLevels(com.jme3.scene.VertexBuffer[]).
count - Number of mesh instances to render

drawTriangleList_Array

public void drawTriangleList_Array(VertexBuffer indexBuf,
                                   Mesh mesh,
                                   int count)
drawTriangleList_Array uses Vertex Array

Parameters:
indexBuf -
mesh -
count -

setVertexAttrib_Array

public void setVertexAttrib_Array(VertexBuffer vb,
                                  VertexBuffer idb)
setVertexAttrib_Array uses Vertex Array

Parameters:
vb -
idb -

setVertexAttrib_Array

public void setVertexAttrib_Array(VertexBuffer vb)
setVertexAttrib_Array uses Vertex Array

Parameters:
vb -

setAlphaToCoverage

public void setAlphaToCoverage(boolean value)
Description copied from interface: Renderer
Sets the alpha to coverage state.

When alpha coverage and multi-sampling is enabled, each pixel will contain alpha coverage in all of its subsamples, which is then combined when other future alpha-blended objects are rendered.

Alpha-to-coverage is useful for rendering transparent objects without having to worry about sorting them.

Specified by:
setAlphaToCoverage in interface Renderer

invalidateState

public void invalidateState()
Description copied from interface: Renderer
Invalidates the current rendering state. Should be called after the GL state was changed manually or through an external library.

Specified by:
invalidateState in interface Renderer