Class TLspTextureRenderTarget
java.lang.Object
com.luciad.view.lightspeed.util.opengl.rendertarget.TLspTextureRenderTarget
- All Implemented Interfaces:
ILspRenderTarget
A render target that draws into an OpenGL frame buffer object (FBO)
which can subsequently be used as a texture.
A typical use case is to perform two-pass rendering:
First pass: render to render target
view.pushRenderTarget(target); // perform GL rendering to the render target view.popRenderTarget(target);Second pass: use render target's texture
target.useColorTexture(view.getGLDrawable()); // Draw screen-space quad.
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionTLspTextureRenderTarget
(int aWidth, int aHeight, int aMSAASamples, boolean aWithDepthStencilBuffer) Constructs a render target with the given dimensions and an internal representation that matches the main view.TLspTextureRenderTarget
(int aWidth, int aHeight, int aTextureInternalFormat, int aTextureDataFormat, int aTextureDataType, int aMSAASamples, boolean aWithDepthStencilBuffer) Constructs a render target with the given dimensions and a custom internal representation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
bind
(ILcdGLDrawable aGLDrawable) Binds the render target for use.void
destroy
(ILcdGLDrawable aGLDrawable) Destroys the render target.int
Gets the texture id.int
Gets the OpenGL frame buffer object that is used by this render target.int
Gets the height in pixels of this render target.int
ReturnsILcdGL.GL_TEXTURE_2D
int
getWidth()
Gets the width in pixels of this render target.void
init
(ILcdGLDrawable aGLDrawable) Initializes the render target.void
unbind
(ILcdGLDrawable aGLDrawable) Unbinds the render target.void
useColorTexture
(ILcdGLDrawable aGLDrawable) Binds the texture for use.
-
Constructor Details
-
TLspTextureRenderTarget
public TLspTextureRenderTarget(int aWidth, int aHeight, int aMSAASamples, boolean aWithDepthStencilBuffer) Constructs a render target with the given dimensions and an internal representation that matches the main view. Note that using multi-sampling significantly increases video memory usage.- Parameters:
aWidth
- the width of the offscreen render targetaHeight
- the height of the offscreen render targetaMSAASamples
- the number of samples to use for multi-sampling anti-aliasing. The values 1,2,4 are common.aWithDepthStencilBuffer
- whether to use a combined depth-stencil buffer- Throws:
IllegalArgumentException
- if the width, height, or number of samples is negative (zero inclusive).
-
TLspTextureRenderTarget
public TLspTextureRenderTarget(int aWidth, int aHeight, int aTextureInternalFormat, int aTextureDataFormat, int aTextureDataType, int aMSAASamples, boolean aWithDepthStencilBuffer) Constructs a render target with the given dimensions and a custom internal representation. Note that using multi-sampling significantly increases video memory usage.- Parameters:
aWidth
- the width of the offscreen render targetaHeight
- the height of the offscreen render targetaTextureInternalFormat
- the internal texture format (e.g.,ILcdGL.GL_RGBA8
)aTextureDataFormat
- the texture data format (e.g.,ILcdGL.GL_RGBA
)aTextureDataType
- the texture data type (e.g.,ILcdGL.GL_UNSIGNED_BYTE
)aMSAASamples
- the number of samples to use for multi-sampling anti-aliasing. The values 1,2,4 are common.aWithDepthStencilBuffer
- whether to use a combined depth-stencil buffer- Throws:
IllegalArgumentException
- if the width, height, or number of samples is negative (zero inclusive).
-
-
Method Details
-
init
Description copied from interface:ILspRenderTarget
Initializes the render target.- Specified by:
init
in interfaceILspRenderTarget
- Parameters:
aGLDrawable
- the drawable for which the render target will be used
-
getFBObjectName
public int getFBObjectName()Gets the OpenGL frame buffer object that is used by this render target.- Returns:
- the OpenGL FBO name
-
getWidth
public int getWidth()Gets the width in pixels of this render target.- Returns:
- the width
-
getHeight
public int getHeight()Gets the height in pixels of this render target.- Returns:
- the height
-
destroy
Description copied from interface:ILspRenderTarget
Destroys the render target.- Specified by:
destroy
in interfaceILspRenderTarget
- Parameters:
aGLDrawable
- the drawable for which the render target will be used
-
bind
Description copied from interface:ILspRenderTarget
Binds the render target for use. This means that subsequent paints will be directed to this render target. This method should preferably not be used directly, since binding a render target automatically unbinds another possibly bound render target. Use therender target stack
's push mechanism instead.- Specified by:
bind
in interfaceILspRenderTarget
- Parameters:
aGLDrawable
- the drawable for which the render target will be used
-
getColorTextureName
public int getColorTextureName()Gets the texture id.- Returns:
- the texture id
-
unbind
Description copied from interface:ILspRenderTarget
Unbinds the render target. This means that subsequent paints will be directed to the main view. This method should preferably not be used directly, since unbinding a render target automatically binds the main view (the 0 frame buffer) as a render target, instead of the previously bound render target. Use therender target stack
's pop mechanism instead.- Specified by:
unbind
in interfaceILspRenderTarget
- Parameters:
aGLDrawable
- the drawable for which the render target will be used
-
useColorTexture
Binds the texture for use. A typical use case is to perform intermediate rendering to this render target (by usingTLspRenderTargetStack.pushRenderTarget(ILspRenderTarget)
andTLspRenderTargetStack.popRenderTarget()
) and by later on using the resulting texture, e.g., applied to a screen-aligned quad. This method binds the resulting texture for use, it does not bind the render target.- Parameters:
aGLDrawable
- the drawable this texture will be used on
-
getTarget
public int getTarget()ReturnsILcdGL.GL_TEXTURE_2D
- Returns:
ILcdGL.GL_TEXTURE_2D
-