|
@@ -50,18 +50,18 @@ import java.util.EnumSet;
|
|
|
/**
|
|
|
* The <code>Renderer</code> is responsible for taking rendering commands and
|
|
|
* executing them on the underlying video hardware.
|
|
|
- *
|
|
|
+ *
|
|
|
* @author Kirill Vainer
|
|
|
*/
|
|
|
public interface Renderer {
|
|
|
|
|
|
/**
|
|
|
- * Detects available capabilities of the GPU.
|
|
|
- *
|
|
|
+ * Detects available capabilities of the GPU.
|
|
|
+ *
|
|
|
* Must be called prior to any other Renderer methods.
|
|
|
*/
|
|
|
public void initialize();
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Get the capabilities of the renderer.
|
|
|
* @return The capabilities of the renderer.
|
|
@@ -102,7 +102,7 @@ public interface Renderer {
|
|
|
|
|
|
/**
|
|
|
* Sets the background (aka clear) color.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param color The background color to set
|
|
|
*/
|
|
|
public void setBackgroundColor(ColorRGBA color);
|
|
@@ -116,7 +116,7 @@ public interface Renderer {
|
|
|
/**
|
|
|
* Set the range of the depth values for objects. All rendered
|
|
|
* objects will have their depth clamped to this range.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param start The range start
|
|
|
* @param end The range end
|
|
|
*/
|
|
@@ -124,7 +124,7 @@ public interface Renderer {
|
|
|
|
|
|
/**
|
|
|
* Called 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.
|
|
|
*/
|
|
@@ -132,7 +132,7 @@ public interface Renderer {
|
|
|
|
|
|
/**
|
|
|
* Set the viewport location and resolution on the screen.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param x The x coordinate of the viewport
|
|
|
* @param y The y coordinate of the viewport
|
|
|
* @param width Width of the viewport
|
|
@@ -144,7 +144,7 @@ public interface Renderer {
|
|
|
* Specifies a clipping rectangle.
|
|
|
* For all future rendering commands, no pixels will be allowed
|
|
|
* to be rendered outside of the clip rectangle.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param x The x coordinate of the clip rect
|
|
|
* @param y The y coordinate of the clip rect
|
|
|
* @param width Width of the clip rect
|
|
@@ -153,7 +153,7 @@ public interface Renderer {
|
|
|
public void setClipRect(int x, int y, int width, int height);
|
|
|
|
|
|
/**
|
|
|
- * Clears the clipping rectangle set with
|
|
|
+ * Clears the clipping rectangle set with
|
|
|
* {@link #setClipRect(int, int, int, int) }.
|
|
|
*/
|
|
|
public void clearClipRect();
|
|
@@ -161,9 +161,9 @@ public 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
|
|
|
+ * and linked. If it has been uploaded, then the
|
|
|
* uniform data is updated and the shader is set.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param shader The shader to use for rendering.
|
|
|
*/
|
|
|
public void setShader(Shader shader);
|
|
@@ -171,21 +171,19 @@ public interface Renderer {
|
|
|
/**
|
|
|
* Deletes a shader. This method also deletes
|
|
|
* the attached shader sources.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param shader Shader to delete.
|
|
|
- * @see #deleteShaderSource(com.jme3.shader.Shader.ShaderSource)
|
|
|
+ * @see #deleteShaderSource(com.jme3.shader.Shader.ShaderSource)
|
|
|
*/
|
|
|
public void deleteShader(Shader shader);
|
|
|
|
|
|
/**
|
|
|
* Deletes the provided shader source.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param source The ShaderSource to delete.
|
|
|
*/
|
|
|
public void deleteShaderSource(ShaderSource source);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* Copies contents from src to dst, scaling if necessary.
|
|
|
* set copyDepth to false to only copy the color buffers.
|
|
@@ -193,50 +191,48 @@ public interface Renderer {
|
|
|
*/
|
|
|
@Deprecated public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyDepth);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Copies contents from src to dst, scaling if necessary.
|
|
|
- */
|
|
|
+ */
|
|
|
public void copyFrameBuffer(FrameBuffer src, FrameBuffer dst, boolean copyColor, boolean copyDepth);
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Sets 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.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param fb The framebuffer to set
|
|
|
*/
|
|
|
public void setFrameBuffer(FrameBuffer fb);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Set the framebuffer that will be set instead of the main framebuffer
|
|
|
* when a call to setFrameBuffer(null) is made.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param fb The framebuffer to override the main framebuffer.
|
|
|
*/
|
|
|
public void setMainFrameBufferOverride(FrameBuffer fb);
|
|
|
|
|
|
/**
|
|
|
* Reads 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
|
|
|
+ * 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.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param fb The framebuffer to read from
|
|
|
* @param byteBuf The bytebuffer to transfer color data to
|
|
|
*/
|
|
|
public void readFrameBuffer(FrameBuffer fb, ByteBuffer byteBuf);
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Reads the pixels currently stored in the specified framebuffer
|
|
|
- * into the given ByteBuffer object.
|
|
|
- * Only color pixels are transferred, with the given format.
|
|
|
+ * 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.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param fb The framebuffer to read from
|
|
|
* @param byteBuf The bytebuffer to transfer color data to
|
|
|
* @param format the image format to use when reading the frameBuffer.
|
|
@@ -254,9 +250,9 @@ public interface Renderer {
|
|
|
public void setTexture(int unit, Texture tex);
|
|
|
|
|
|
/**
|
|
|
- * Modify the given Texture with the given Image.
|
|
|
+ * Modify 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.
|
|
|
*
|
|
|
* @param tex the Texture that will be modified
|
|
@@ -273,7 +269,7 @@ public interface Renderer {
|
|
|
|
|
|
/**
|
|
|
* Uploads a vertex buffer to the GPU.
|
|
|
- *
|
|
|
+ *
|
|
|
* @param vb The vertex buffer to upload
|
|
|
*/
|
|
|
public void updateBufferData(VertexBuffer vb);
|
|
@@ -313,7 +309,7 @@ public interface Renderer {
|
|
|
* @param lod The LOD level to use, see {@link Mesh#setLodLevels(com.jme3.scene.VertexBuffer[]) }.
|
|
|
* @param count Number of mesh instances to render
|
|
|
* @param instanceData When count is greater than 1, these buffers provide
|
|
|
- * the per-instance attributes.
|
|
|
+ * the per-instance attributes.
|
|
|
*/
|
|
|
public void renderMesh(Mesh mesh, int lod, int count, VertexBuffer[] instanceData);
|
|
|
|
|
@@ -322,17 +318,17 @@ public interface 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 shutdown.
|
|
|
- *
|
|
|
- * @see NativeObject#resetObject()
|
|
|
+ *
|
|
|
+ * @see NativeObject#resetObject()
|
|
|
*/
|
|
|
public void resetGLObjects();
|
|
|
|
|
|
/**
|
|
|
* Deletes all previously used {@link NativeObject Native Objects} on this Renderer, and
|
|
|
* then resets the native objects.
|
|
|
- *
|
|
|
- * @see #resetGLObjects()
|
|
|
- * @see NativeObject#deleteObject(java.lang.Object)
|
|
|
+ *
|
|
|
+ * @see #resetGLObjects()
|
|
|
+ * @see NativeObject#deleteObject(java.lang.Object)
|
|
|
*/
|
|
|
public void cleanup();
|
|
|
|
|
@@ -353,7 +349,7 @@ public interface Renderer {
|
|
|
/**
|
|
|
* Sets the alpha to coverage state.
|
|
|
* <p>
|
|
|
- * When alpha coverage and multi-sampling is enabled,
|
|
|
+ * 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.
|
|
@@ -365,53 +361,52 @@ public interface Renderer {
|
|
|
*/
|
|
|
public void setAlphaToCoverage(boolean value);
|
|
|
|
|
|
- /**
|
|
|
- * If enabled, color values rendered to the main framebuffer undergo
|
|
|
- * linear -> sRGB conversion.
|
|
|
- *
|
|
|
- * This is identical to {@link FrameBuffer#setSrgb(boolean)} except it is toggled
|
|
|
- * for the main framebuffer instead of an offscreen buffer.
|
|
|
- *
|
|
|
- * This should be set together with {@link Renderer#setLinearizeSrgbImages(boolean)}
|
|
|
- *
|
|
|
- * As a shorthand, the user can set {@link AppSettings#setGammaCorrection(boolean)} to true
|
|
|
- * to toggle both {@link Renderer#setLinearizeSrgbImages(boolean)} and
|
|
|
- * {@link Renderer#setMainFrameBufferSrgb(boolean)} if the
|
|
|
- * {@link Caps#Srgb} is supported by the GPU.
|
|
|
- *
|
|
|
- * @throws RendererException If the GPU hardware does not support sRGB.
|
|
|
- *
|
|
|
- * @see FrameBuffer#setSrgb(boolean)
|
|
|
- * @see Caps#Srgb
|
|
|
- */
|
|
|
- public void setMainFrameBufferSrgb(boolean srgb);
|
|
|
+ /**
|
|
|
+ * If enabled, color values rendered to the main framebuffer undergo
|
|
|
+ * linear -> sRGB conversion.
|
|
|
+ *
|
|
|
+ * This is identical to {@link FrameBuffer#setSrgb(boolean)} except it is toggled
|
|
|
+ * for the main framebuffer instead of an offscreen buffer.
|
|
|
+ *
|
|
|
+ * This should be set together with {@link Renderer#setLinearizeSrgbImages(boolean)}
|
|
|
+ *
|
|
|
+ * As a shorthand, the user can set {@link AppSettings#setGammaCorrection(boolean)} to true
|
|
|
+ * to toggle both {@link Renderer#setLinearizeSrgbImages(boolean)} and
|
|
|
+ * {@link Renderer#setMainFrameBufferSrgb(boolean)} if the
|
|
|
+ * {@link Caps#Srgb} is supported by the GPU.
|
|
|
+ *
|
|
|
+ * @throws RendererException If the GPU hardware does not support sRGB.
|
|
|
+ *
|
|
|
+ * @see FrameBuffer#setSrgb(boolean)
|
|
|
+ * @see Caps#Srgb
|
|
|
+ */
|
|
|
+ public void setMainFrameBufferSrgb(boolean srgb);
|
|
|
|
|
|
- /**
|
|
|
- * If enabled, all {@link Image images} with the {@link Image#setColorSpace(com.jme3.texture.image.ColorSpace) sRGB flag}
|
|
|
- * set shall undergo an sRGB to linear RGB color conversion when read by a shader.
|
|
|
- *
|
|
|
- * The conversion is performed for the following formats:
|
|
|
- * - {@link com.jme3.texture.Image.Format#RGB8}
|
|
|
- * - {@link com.jme3.texture.Image.Format#RGBA8}
|
|
|
- * - {@link com.jme3.texture.Image.Format#Luminance8}
|
|
|
- * - {@link com.jme3.texture.Image.Format#Luminance8Alpha8}
|
|
|
- * - {@link com.jme3.texture.Image.Format#DXT1}
|
|
|
- * - {@link com.jme3.texture.Image.Format#DXT1A}
|
|
|
- * - {@link com.jme3.texture.Image.Format#DXT3}
|
|
|
- * - {@link com.jme3.texture.Image.Format#DXT5}
|
|
|
- *
|
|
|
- * For all other formats, no conversion is performed.
|
|
|
- *
|
|
|
- * If this option is toggled at runtime, textures must be reloaded for the change to take effect.
|
|
|
- *
|
|
|
- * @throws RendererException If the GPU hardware does not support sRGB.
|
|
|
- *
|
|
|
- * @param linearize If sRGB images undergo sRGB -> linear conversion prior to rendering.
|
|
|
- *
|
|
|
- * @see Caps#Srgb
|
|
|
- */
|
|
|
- public void setLinearizeSrgbImages(boolean linearize);
|
|
|
-
|
|
|
+ /**
|
|
|
+ * If enabled, all {@link Image images} with the {@link Image#setColorSpace(com.jme3.texture.image.ColorSpace) sRGB flag}
|
|
|
+ * set shall undergo an sRGB to linear RGB color conversion when read by a shader.
|
|
|
+ *
|
|
|
+ * The conversion is performed for the following formats:
|
|
|
+ * - {@link com.jme3.texture.Image.Format#RGB8}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#RGBA8}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#Luminance8}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#Luminance8Alpha8}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#DXT1}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#DXT1A}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#DXT3}
|
|
|
+ * - {@link com.jme3.texture.Image.Format#DXT5}
|
|
|
+ *
|
|
|
+ * For all other formats, no conversion is performed.
|
|
|
+ *
|
|
|
+ * If this option is toggled at runtime, textures must be reloaded for the change to take effect.
|
|
|
+ *
|
|
|
+ * @throws RendererException If the GPU hardware does not support sRGB.
|
|
|
+ *
|
|
|
+ * @param linearize If sRGB images undergo sRGB -> linear conversion prior to rendering.
|
|
|
+ *
|
|
|
+ * @see Caps#Srgb
|
|
|
+ */
|
|
|
+ public void setLinearizeSrgbImages(boolean linearize);
|
|
|
|
|
|
/**
|
|
|
* Generates a pool of gpu queries meant to use as profiling tasks
|
|
@@ -453,14 +448,13 @@ public interface Renderer {
|
|
|
* @return true if the results of the task with the given task id are available.
|
|
|
*/
|
|
|
public boolean isTaskResultAvailable(int taskId);
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* Gets the alpha to coverage state.
|
|
|
- *
|
|
|
+ *
|
|
|
*/
|
|
|
- public boolean getAlphaToCoverage();
|
|
|
-
|
|
|
+ public boolean getAlphaToCoverage();
|
|
|
+
|
|
|
/**
|
|
|
* Get the default anisotropic filter level for textures.
|
|
|
*
|