Class TLspTextureRenderTarget

java.lang.Object
com.luciad.view.lightspeed.util.opengl.rendertarget.TLspTextureRenderTarget
All Implemented Interfaces:
ILspRenderTarget

public class TLspTextureRenderTarget extends Object implements 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

    Constructors
    Constructor
    Description
    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.
    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 Type
    Method
    Description
    void
    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
    Returns ILcdGL.GL_TEXTURE_2D
    int
    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
    Binds the texture for use.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 target
      aHeight - the height of the offscreen render target
      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).
    • 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 target
      aHeight - the height of the offscreen render target
      aTextureInternalFormat - 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

      public void init(ILcdGLDrawable aGLDrawable)
      Description copied from interface: ILspRenderTarget
      Initializes the render target.
      Specified by:
      init in interface ILspRenderTarget
      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

      public void destroy(ILcdGLDrawable aGLDrawable)
      Description copied from interface: ILspRenderTarget
      Destroys the render target.
      Specified by:
      destroy in interface ILspRenderTarget
      Parameters:
      aGLDrawable - the drawable for which the render target will be used
    • bind

      public void bind(ILcdGLDrawable aGLDrawable)
      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 the render target stack's push mechanism instead.

      Specified by:
      bind in interface ILspRenderTarget
      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

      public void unbind(ILcdGLDrawable aGLDrawable)
      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 the render target stack's pop mechanism instead.

      Specified by:
      unbind in interface ILspRenderTarget
      Parameters:
      aGLDrawable - the drawable for which the render target will be used
    • useColorTexture

      public void useColorTexture(ILcdGLDrawable aGLDrawable)
      Binds the texture for use. A typical use case is to perform intermediate rendering to this render target (by using TLspRenderTargetStack.pushRenderTarget(ILspRenderTarget) and TLspRenderTargetStack.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()
      Returns ILcdGL.GL_TEXTURE_2D
      Returns:
      ILcdGL.GL_TEXTURE_2D