Class GLRenderer
- All Implemented Interfaces:
- Renderer
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidapplyRenderState(RenderState state) Applies the givenRenderState, making the necessary GL calls so that the state is applied.protected voidbindProgram(Shader shader) voidcleanup()Deletes all previously usedNative Objectson this Renderer, and then resets the native objects.voidclearBuffers(boolean color, boolean depth, boolean stencil) Clears certain channels of the currently bound framebuffer.voidClears the clipping rectangle set withRenderer.setClipRect(int, int, int, int).voidintconvertElementMode(Mesh.Mode mode) Convert a mesh mode to the corresponding GL value.intvoidcopyFrameBuffer(FrameBuffer src, FrameBuffer dst) Copy the source buffer to the destination buffer, including both color and depth.voidcopyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth) Copies contents from src to dst, scaling if necessary.voidcopyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyColor, boolean copyDepth) Copies contents from src to dst, scaling if necessary.voidDeletes a vertex buffer from the GPU.voidDeletes the buffer object from the GPU.voidDeletes a framebuffer and all attached renderbuffers.voiddeleteImage(Image image) Deletes a texture from the GPU.voiddeleteShader(Shader shader) Deletes a shader.voidDeletes the provided shader source.voiddrawTriangleArray(Mesh.Mode mode, int count, int vertCount) voiddrawTriangleList(VertexBuffer indexBuf, Mesh mesh, int count) static intextractVersion(String version) int[]generateProfilingTasks(int numTasks) Generates a pool of gpu queries meant to use as profiling tasks.booleanGets the alpha to coverage state.getCaps()Gets the capabilities of the renderer.Returns the current FrameBuffer that is being rendered to.intGets the default anisotropic filter level for textures.Vector2f[]Gets the limits of the renderer.floatDetermine the maximum allowed width for lines.longgetProfilingTime(int taskId) Returns the time in nanoseconds elapsed for the task with the given id.Copies the render statistics.voidDetects available capabilities of the GPU.voidInvalidates the current rendering state.booleanTest whether images with the sRGB flag will be linearized when read by a shader.booleanTest whether colors rendered to the main framebuffer undergo linear-to-sRGB conversion.booleanisTaskResultAvailable(int taskId) Checks if the profiling results are available.static booleanvoidmodifyTexture(Texture2D dest, Image src, int destX, int destY, int srcX, int srcY, int areaW, int areaH) Copy a part of an image to a texture 2d.voidmodifyTexture(Texture tex, Image pixels, int x, int y) Deprecated.Use modifyTexture(Texture2D dest, Image src, int destX, int destY, int srcX, int srcY, int areaW, int areaH)voidvoidCalled when a new frame has been rendered.voidpushDebugGroup(String name) voidreadFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf) Reads the pixels currently stored in the specified framebuffer into the given ByteBuffer object.voidreadFrameBufferWithFormat(FrameBuffer fb, ByteBuffer byteBuf, Image.Format format) Reads the pixels currently stored in the specified framebuffer into the given ByteBuffer object.voidrenderMesh(Mesh mesh, int lod, int count, VertexBuffer[] instanceData) Renderscountmeshes, with the geometry data supplied and per-instance data supplied.voidResets all previously usedNative Objectson this Renderer.protected voidresetUniformLocations(Shader shader) voidsetAlphaToCoverage(boolean value) Sets the alpha to coverage state.voidsetBackgroundColor(ColorRGBA color) Sets the background (aka clear) color.voidsetClipRect(int x, int y, int width, int height) Specifies a clipping rectangle.voidsetDebugEnabled(boolean v) voidsetDefaultAnisotropicFilter(int level) Sets the default anisotropic filter level for textures.voidsetDepthRange(float start, float end) \ |* Render State *| \voidSets the framebuffer that will be drawn to.voidsetGenerateMipmapsForFrameBuffer(boolean v) Enable/Disable default automatic generation of mipmaps for framebuffersvoidsetLinearizeSrgbImages(boolean linearize) voidSets the framebuffer that will be set instead of the main framebuffer when a call to setFrameBuffer(null) is made.voidsetMainFrameBufferSrgb(boolean enableSrgb) Specifies whether color values in the main framebuffer are in SRGB format.voidvoidSets the shader to use for rendering.voidsetShaderStorageBufferObject(int bindingPoint, BufferObject bufferObject) voidsetTexture(int unit, Texture tex) Assigns a Texture to the specified texture unit.voidsetUniformBufferObject(int bindingPoint, BufferObject bufferObject) voidvoidsetVertexAttrib(VertexBuffer vb, VertexBuffer idb) voidsetViewPort(int x, int y, int w, int h) \ |* Camera and World transforms *| \voidstartProfiling(int taskId) Starts a time profiling task on the GPU.voidWill stop the last profiling task started with startProfiling.voidUploads a vertex buffer to the GPU.voidvoidvoidprotected voidupdateShaderBufferBlock(Shader shader, ShaderBufferBlock bufferBlock) Updates the buffer block for the shader.protected voidupdateShaderBufferBlocks(Shader shader) Updates all shader's buffer blocks.voidupdateShaderData(Shader shader) voidvoidUploads data of the buffer object on the GPU.protected voidupdateShaderUniforms(Shader shader) voidupdateTexImageData(Image img, Texture.Type type, int unit, boolean scaleToPot) Uploads the given image to the GL driver.protected voidupdateUniform(Shader shader, Uniform uniform) voidUploads data of the buffer object on the GPU.protected voidupdateUniformLocation(Shader shader, Uniform uniform) Update the location of the specified Uniform in the specified Shader.voidupdateVertexArray(Mesh mesh, VertexBuffer instanceData) 
- 
Constructor Details- 
GLRenderer
 
- 
- 
Method Details- 
setGenerateMipmapsForFrameBufferpublic void setGenerateMipmapsForFrameBuffer(boolean v) Enable/Disable default automatic generation of mipmaps for framebuffers- Parameters:
- v- Default is true
 
- 
setDebugEnabledpublic void setDebugEnabled(boolean v) 
- 
popDebugGrouppublic void popDebugGroup()- Specified by:
- popDebugGroupin interface- Renderer
 
- 
pushDebugGroup- Specified by:
- pushDebugGroupin interface- Renderer
 
- 
getStatisticsDescription copied from interface:RendererCopies the render statistics.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:
- getStatisticsin interface- Renderer
- Returns:
- a new instance
 
- 
getCapsDescription copied from interface:RendererGets the capabilities of the renderer.
- 
getLimitsDescription copied from interface:RendererGets the limits of the renderer.
- 
isWebGL
- 
extractVersion
- 
initializepublic void initialize()Description copied from interface:RendererDetects available capabilities of the GPU. Must be called prior to any other Renderer methods.- Specified by:
- initializein interface- Renderer
 
- 
invalidateStatepublic void invalidateState()Description copied from interface:RendererInvalidates the current rendering state. Should be called after the GL state was changed manually or through an external library.- Specified by:
- invalidateStatein interface- Renderer
 
- 
resetGLObjectspublic void resetGLObjects()Description copied from interface:RendererResets all previously usedNative Objectson this Renderer. The state of the native objects is reset in such way, that using them again will cause the renderer to reupload them. Call this method when you know the GL context is going to shut down.- Specified by:
- resetGLObjectsin interface- Renderer
- See Also:
 
- 
cleanuppublic void cleanup()Description copied from interface:RendererDeletes all previously usedNative Objectson this Renderer, and then resets the native objects.
- 
setDepthRangepublic void setDepthRange(float start, float end) \ |* Render State *| \- Specified by:
- setDepthRangein interface- Renderer
- Parameters:
- start- The range start
- end- The range end
 
- 
clearBufferspublic void clearBuffers(boolean color, boolean depth, boolean stencil) Description copied from interface:RendererClears certain channels of the currently bound framebuffer.- Specified by:
- clearBuffersin 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)
 
- 
setBackgroundColorDescription copied from interface:RendererSets the background (aka clear) color.- Specified by:
- setBackgroundColorin interface- Renderer
- Parameters:
- color- The background color to set
 
- 
setDefaultAnisotropicFilterpublic void setDefaultAnisotropicFilter(int level) Description copied from interface:RendererSets the default anisotropic filter level for textures.If the texture anisotropic filteris set to 0, then the default level is used. Otherwise, if the texture level is 1 or greater, then the texture's value overrides the default value.- Specified by:
- setDefaultAnisotropicFilterin interface- Renderer
- Parameters:
- level- The default anisotropic filter level to use. Default: 1.
 
- 
setAlphaToCoveragepublic void setAlphaToCoverage(boolean value) Description copied from interface:RendererSets 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:
- setAlphaToCoveragein interface- Renderer
- Parameters:
- value- true to enable alpha coverage, otherwise false
 
- 
applyRenderStateDescription copied from interface:RendererApplies the givenRenderState, making the necessary GL calls so that the state is applied.- Specified by:
- applyRenderStatein interface- Renderer
- Parameters:
- state- the RenderState to apply
 
- 
setViewPortpublic void setViewPort(int x, int y, int w, int h) \ |* Camera and World transforms *| \- Specified by:
- setViewPortin 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
 
- 
setClipRectpublic void setClipRect(int x, int y, int width, int height) Description copied from interface:RendererSpecifies a clipping rectangle. For all future rendering commands, no pixels will be allowed to be rendered outside of the clip rectangle.- Specified by:
- setClipRectin 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
 
- 
clearClipRectpublic void clearClipRect()Description copied from interface:RendererClears the clipping rectangle set withRenderer.setClipRect(int, int, int, int).- Specified by:
- clearClipRectin interface- Renderer
 
- 
postFramepublic void postFrame()Description copied from interface:RendererCalled when a new frame has been rendered. Currently, this will simply delete any OpenGL objects from the GPU which have been garbage collected by the GC.
- 
bindProgram
- 
updateUniformLocationUpdate the location of the specified Uniform in the specified Shader.- Parameters:
- shader- the Shader containing the Uniform (not null)
- uniform- the Uniform to update (not null)
 
- 
updateUniform
- 
updateShaderBufferBlockUpdates the buffer block for the shader.- Parameters:
- shader- the shader.
- bufferBlock- the storage block.
 
- 
updateShaderUniforms
- 
updateShaderBufferBlocksUpdates all shader's buffer blocks.- Parameters:
- shader- the shader.
 
- 
resetUniformLocations
- 
convertShaderType
- 
updateShaderSourceData
- 
updateShaderData
- 
setShaderDescription copied from interface:RendererSets 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.
- 
deleteShaderSourceDescription copied from interface:RendererDeletes the provided shader source.- Specified by:
- deleteShaderSourcein interface- Renderer
- Parameters:
- source- The ShaderSource to delete.
 
- 
deleteShaderDescription copied from interface:RendererDeletes a shader. This method also deletes the attached shader sources.- Specified by:
- deleteShaderin interface- Renderer
- Parameters:
- shader- Shader to delete.
- See Also:
 
- 
copyFrameBufferCopy the source buffer to the destination buffer, including both color and depth.- Parameters:
- src- the source buffer (unaffected)
- dst- the destination buffer
 
- 
copyFrameBufferDescription copied from interface:RendererCopies contents from src to dst, scaling if necessary. set copyDepth to false to only copy the color buffers.- Specified by:
- copyFrameBufferin interface- Renderer
- Parameters:
- src- the source FrameBuffer (unaffected)
- dst- the destination FrameBuffer (modified)
- copyDepth- true→copy depth info, false→don't copy it
 
- 
copyFrameBufferDescription copied from interface:RendererCopies contents from src to dst, scaling if necessary.- Specified by:
- copyFrameBufferin interface- Renderer
- Parameters:
- src- the source FrameBuffer (unaffected)
- dst- the destination FrameBuffer (modified)
- copyColor- true→copy color info, false→don't copy it
- copyDepth- true→copy depth info, false→don't copy it
 
- 
updateRenderTexture
- 
updateFrameBufferAttachment
- 
updateFrameBuffer
- 
getFrameBufferSamplePositions
- 
setMainFrameBufferOverrideDescription copied from interface:RendererSets the framebuffer that will be set instead of the main framebuffer when a call to setFrameBuffer(null) is made.- Specified by:
- setMainFrameBufferOverridein interface- Renderer
- Parameters:
- fb- The framebuffer to override the main framebuffer.
 
- 
getCurrentFrameBufferDescription copied from interface:RendererReturns the current FrameBuffer that is being rendered to.- Specified by:
- getCurrentFrameBufferin interface- Renderer
- Returns:
- the FrameBuffer or null if rendering to the screen.
 
- 
setReadDrawBuffers
- 
setFrameBufferDescription copied from interface:RendererSets the framebuffer that will be drawn to. If the framebuffer has not been initialized yet, it will be created and its render surfaces and attached textures will be allocated.- Specified by:
- setFrameBufferin interface- Renderer
- Parameters:
- fb- The framebuffer to set
 
- 
readFrameBufferDescription copied from interface:RendererReads the pixels currently stored in the specified framebuffer into the given ByteBuffer object. Only color pixels are transferred, the format is RGBA with 8 bits per component. The given byte buffer should have at least fb.getWidth() * fb.getHeight() * 4 bytes remaining.- Specified by:
- readFrameBufferin interface- Renderer
- Parameters:
- fb- The framebuffer to read from
- byteBuf- The bytebuffer to transfer color data to
 
- 
readFrameBufferWithFormatDescription copied from interface:RendererReads the pixels currently stored in the specified framebuffer into the given ByteBuffer object. Only color pixels are transferred, with the given format. The given byte buffer should have at least fb.getWidth() * fb.getHeight() * 4 bytes remaining.- Specified by:
- readFrameBufferWithFormatin interface- Renderer
- Parameters:
- fb- The framebuffer to read from
- byteBuf- The bytebuffer to transfer color data to
- format- the image format to use when reading the frameBuffer.
 
- 
deleteFrameBufferDescription copied from interface:RendererDeletes a framebuffer and all attached renderbuffers.- Specified by:
- deleteFrameBufferin interface- Renderer
- Parameters:
- fb- the FrameBuffer to be deleted
 
- 
updateTexImageDataUploads the given image to the GL driver.- Parameters:
- img- The image to upload
- type- How the data in the image argument should be interpreted.
- unit- The texture slot to be used to upload the image, not important
- scaleToPot- If true, the image will be scaled to power-of-2 dimensions before being uploaded.
 
- 
setTextureDescription copied from interface:RendererAssigns a Texture to the specified texture unit.- Specified by:
- setTexturein interface- Renderer
- Parameters:
- unit- the index of the texture unit (≥0)
- tex- the Texture to assign
- Throws:
- TextureUnitException- if the texture unit doesn't exist
 
- 
setUniformBufferObject- Specified by:
- setUniformBufferObjectin interface- Renderer
 
- 
setShaderStorageBufferObject- Specified by:
- setShaderStorageBufferObjectin interface- Renderer
 
- 
modifyTextureDeprecated.Use modifyTexture(Texture2D dest, Image src, int destX, int destY, int srcX, int srcY, int areaW, int areaH)Description copied from interface:RendererModifies the given Texture with the given Image. The image will be put at x and y into the texture. NOTE: this is only supported for uncompressed 2D images without mipmaps.- Specified by:
- modifyTexturein interface- Renderer
- Parameters:
- tex- the Texture that will be modified
- pixels- the source Image data to copy data from
- x- the x position to put the image into the texture
- y- the y position to put the image into the texture
 
- 
modifyTexturepublic void modifyTexture(Texture2D dest, Image src, int destX, int destY, int srcX, int srcY, int areaW, int areaH) Copy a part of an image to a texture 2d.- Parameters:
- dest- The destination image, where the source will be copied
- src- The source image that contains the data to copy
- destX- First pixel of the destination image from where the src image will be drawn (x component)
- destY- First pixel of the destination image from where the src image will be drawn (y component)
- srcX- First pixel to copy (x component)
- srcY- First pixel to copy (y component)
- areaW- Width of the area to copy
- areaH- Height of the area to copy
 
- 
deleteImageDescription copied from interface:RendererDeletes a texture from the GPU.- Specified by:
- deleteImagein interface- Renderer
- Parameters:
- image- the texture to delete
 
- 
updateBufferDataDescription copied from interface:RendererUploads a vertex buffer to the GPU.- Specified by:
- updateBufferDatain interface- Renderer
- Parameters:
- vb- The vertex buffer to upload
 
- 
updateShaderStorageBufferObjectDataDescription copied from interface:RendererUploads data of the buffer object on the GPU.- Specified by:
- updateShaderStorageBufferObjectDatain interface- Renderer
- Parameters:
- bo- the buffer object to upload.
 
- 
updateUniformBufferObjectDataDescription copied from interface:RendererUploads data of the buffer object on the GPU.- Specified by:
- updateUniformBufferObjectDatain interface- Renderer
- Parameters:
- bo- the buffer object to upload.
 
- 
deleteBufferDescription copied from interface:RendererDeletes a vertex buffer from the GPU.- Specified by:
- deleteBufferin interface- Renderer
- Parameters:
- vb- The vertex buffer to delete
 
- 
deleteBufferDescription copied from interface:RendererDeletes the buffer object from the GPU.- Specified by:
- deleteBufferin interface- Renderer
- Parameters:
- bo- the buffer object to delete.
 
- 
clearVertexAttribspublic void clearVertexAttribs()
- 
setVertexAttrib
- 
setVertexAttrib
- 
drawTriangleArray
- 
drawTriangleList
- 
convertElementModeConvert a mesh mode to the corresponding GL value.- Parameters:
- mode- input enum value (not null)
- Returns:
- the corresponding GL value
 
- 
updateVertexArray
- 
renderMeshDescription copied from interface:RendererRenderscountmeshes, with the geometry data supplied and per-instance data supplied. The shader which is currently set withsetShaderis responsible for transforming the input vertices into clip space and shading it based on the given vertex attributes. The integer variable gl_InstanceID can be used to access the current instance of the mesh being rendered inside the vertex shader. If the instance data is non-null, then it is submitted as a per-instance vertex attribute to the shader.- Specified by:
- renderMeshin 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
- instanceData- When count is greater than 1, these buffers provide the per-instance attributes.
 
- 
setMainFrameBufferSrgbpublic void setMainFrameBufferSrgb(boolean enableSrgb) Description copied from interface:RendererSpecifies whether color values in the main framebuffer are in SRGB format.If enabled, color values rendered to the main framebuffer undergo linear -> sRGB conversion. This is identical to FrameBuffer.setSrgb(boolean)except it is toggled for the main framebuffer instead of an offscreen buffer.This should be set together with Renderer.setLinearizeSrgbImages(boolean)As a shorthand, the user can set AppSettings.setGammaCorrection(boolean)to true to toggle bothRenderer.setLinearizeSrgbImages(boolean)andRenderer.setMainFrameBufferSrgb(boolean)if theCaps.Srgbis supported by the GPU.- Specified by:
- setMainFrameBufferSrgbin interface- Renderer
- Parameters:
- enableSrgb- true for sRGB colorspace, false for linear colorspace
- See Also:
 
- 
setLinearizeSrgbImagespublic void setLinearizeSrgbImages(boolean linearize) Description copied from interface:RendererIf enabled, allimageswith thesRGB flagset shall undergo an sRGB to linear RGB color conversion when read by a shader.The conversion is performed for the following formats: - Image.Format.RGB8-Image.Format.RGBA8-Image.Format.Luminance8-Image.Format.Luminance8Alpha8-Image.Format.DXT1-Image.Format.DXT1A-Image.Format.DXT3-Image.Format.DXT5For all other formats, no conversion is performed. If this option is toggled at runtime, textures must be reloaded for the change to take effect. - Specified by:
- setLinearizeSrgbImagesin interface- Renderer
- Parameters:
- linearize- If sRGB images undergo sRGB -> linear conversion prior to rendering.
- See Also:
 
- 
generateProfilingTaskspublic int[] generateProfilingTasks(int numTasks) Description copied from interface:RendererGenerates a pool of gpu queries meant to use as profiling tasks.- Specified by:
- generateProfilingTasksin interface- Renderer
- Parameters:
- numTasks- the number of task ids to generate
- Returns:
- an array of tasks ids.
 
- 
startProfilingpublic void startProfiling(int taskId) Description copied from interface:RendererStarts a time profiling task on the GPU. This will profile all operations called between startProfiling and stopProfiling- Specified by:
- startProfilingin interface- Renderer
- Parameters:
- taskId- the id of the task to start profiling.
 
- 
stopProfilingpublic void stopProfiling()Description copied from interface:RendererWill stop the last profiling task started with startProfiling.- Specified by:
- stopProfilingin interface- Renderer
 
- 
getProfilingTimepublic long getProfilingTime(int taskId) Description copied from interface:RendererReturns the time in nanoseconds elapsed for the task with the given id. Note that the result may not be available right after stopProfiling has been called. You need to check if the result is available with isTaskResultAvailable. Also note that it's guaranteed that the result will be available on next frame. If you use getProfilingTime on the next frame you called stopProfiling, you don't need to check the result availability with isTaskResultAvailable- Specified by:
- getProfilingTimein interface- Renderer
- Parameters:
- taskId- the id of the task given by startProfiling.
- Returns:
- the time in nanosecond of the profiling task with the given id.
 
- 
isTaskResultAvailablepublic boolean isTaskResultAvailable(int taskId) Description copied from interface:RendererChecks if the profiling results are available.- Specified by:
- isTaskResultAvailablein interface- Renderer
- Parameters:
- taskId- the id of the task provided by startProfiling
- Returns:
- true if the results of the task with the given task id are available.
 
- 
getAlphaToCoveragepublic boolean getAlphaToCoverage()Description copied from interface:RendererGets the alpha to coverage state.- Specified by:
- getAlphaToCoveragein interface- Renderer
- Returns:
- true if alpha coverage is enabled, otherwise false
 
- 
getDefaultAnisotropicFilterpublic int getDefaultAnisotropicFilter()Description copied from interface:RendererGets the default anisotropic filter level for textures.- Specified by:
- getDefaultAnisotropicFilterin interface- Renderer
- Returns:
- the default filter level
 
- 
getMaxLineWidthpublic float getMaxLineWidth()Determine the maximum allowed width for lines.- Specified by:
- getMaxLineWidthin interface- Renderer
- Returns:
- the maximum width (in pixels)
 
- 
isLinearizeSrgbImagespublic boolean isLinearizeSrgbImages()Test whether images with the sRGB flag will be linearized when read by a shader.- Specified by:
- isLinearizeSrgbImagesin interface- Renderer
- Returns:
- true for linearization, false for no linearization
 
- 
isMainFrameBufferSrgbpublic boolean isMainFrameBufferSrgb()Test whether colors rendered to the main framebuffer undergo linear-to-sRGB conversion.- Specified by:
- isMainFrameBufferSrgbin interface- Renderer
- Returns:
- true for conversion, false for no conversion
 
 
-