com.jogamp.opengl.util
Class FBObject

java.lang.Object
  extended by com.jogamp.opengl.util.FBObject

public class FBObject
extends Object


Constructor Summary
FBObject(int width, int height)
           
 
Method Summary
 boolean attachDepthBuffer(GL gl, int depthComponentType)
          Attaches one Depth Buffer to this FBO's instance.
 boolean attachStencilBuffer(GL gl, int stencilComponentType)
          Attaches one Stencil Buffer to this FBO's instance.
 int attachTexture2D(GL gl, int texUnit, int magFilter, int minFilter, int wrapS, int wrapT)
          Attaches a[nother] Texture2D Color Buffer to this FBO's instance, selecting the texture data type and format automatically.
 int attachTexture2D(GL gl, int texUnit, int textureInternalFormat, int textureDataFormat, int textureDataType, int magFilter, int minFilter, int wrapS, int wrapT)
          Attaches a[nother] Texture2D Color Buffer to this FBO's instance, selecting the texture data type and format automatically.
 void bind(GL gl)
          Bind this FBO
 void destroy(GL gl)
           
 int getColorAttachmentNumber()
           
 int getDepthBuffer()
           
 int getFBName()
           
 int getHeight()
           
 int getStatus()
           
 String getStatusString()
           
static String getStatusString(int fbStatus)
           
 int getStencilBuffer()
           
 int getTextureName(int idx)
           
 int getTextureNumber()
           
 int getTextureUnit(int idx)
           
 int getWidth()
           
 void init(GL gl)
          Initializes this FBO's instance with it's texture.
 boolean isBound()
           
 boolean isStatusValid()
           
 String toString()
           
 void unbind(GL gl)
          Unbind FBO, ie bind 'non' FBO 0
 void unuse(GL gl)
          Unbind texture, ie bind 'non' texture 0
 void use(GL gl, int texIdx)
          Bind the texture with given index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FBObject

public FBObject(int width,
                int height)
Method Detail

isStatusValid

public boolean isStatusValid()
Returns:
true if the FB status is valid, otherwise false
See Also:
getStatus()

getStatus

public int getStatus()
Returns:
The FB status. GL.GL_FRAMEBUFFER_COMPLETE if ok, otherwise return GL FBO error state or -1
See Also:
#validateStatus()

getStatusString

public String getStatusString()

getStatusString

public static final String getStatusString(int fbStatus)

init

public void init(GL gl)
          throws GLException
Initializes this FBO's instance with it's texture.

Leaves the FBO bound!

Parameters:
gl - the current GL context
Throws:
GLException - in case of an error

attachTexture2D

public int attachTexture2D(GL gl,
                           int texUnit,
                           int magFilter,
                           int minFilter,
                           int wrapS,
                           int wrapT)
                    throws GLException
Attaches a[nother] Texture2D Color Buffer to this FBO's instance, selecting the texture data type and format automatically.

This may be done as many times as many color attachments are supported, see GL2GL3.GL_MAX_COLOR_ATTACHMENTS.

Assumes a bound FBO

Leaves the FBO bound!

Parameters:
gl - the current GL context
texUnit - the desired texture unit ranging from [0..GL2ES1.GL_MAX_TEXTURE_UNITS-1], or -1 if no unit shall be activate at use(GL, int)
magFilter - if > 0 value for GL.GL_TEXTURE_MAG_FILTER
minFilter - if > 0 value for GL.GL_TEXTURE_MIN_FILTER
wrapS - if > 0 value for GL.GL_TEXTURE_WRAP_S
wrapT - if > 0 value for GL.GL_TEXTURE_WRAP_T
Returns:
idx of the new attached texture, otherwise -1
Throws:
GLException - in case of an error

attachTexture2D

public int attachTexture2D(GL gl,
                           int texUnit,
                           int textureInternalFormat,
                           int textureDataFormat,
                           int textureDataType,
                           int magFilter,
                           int minFilter,
                           int wrapS,
                           int wrapT)
                    throws GLException
Attaches a[nother] Texture2D Color Buffer to this FBO's instance, selecting the texture data type and format automatically.

This may be done as many times as many color attachments are supported, see GL2GL3.GL_MAX_COLOR_ATTACHMENTS.

Assumes a bound FBO

Leaves the FBO bound!

Parameters:
gl - the current GL context
texUnit - the desired texture unit ranging from [0..GL2ES1.GL_MAX_TEXTURE_UNITS-1], or -1 if no unit shall be activate at use(GL, int)
textureInternalFormat - internalFormat parameter to GL.glTexImage2D(int, int, int, int, int, int, int, int, long)
textureDataFormat - format parameter to GL.glTexImage2D(int, int, int, int, int, int, int, int, long)
textureDataType - type parameter to GL.glTexImage2D(int, int, int, int, int, int, int, int, long)
magFilter - if > 0 value for GL.GL_TEXTURE_MAG_FILTER
minFilter - if > 0 value for GL.GL_TEXTURE_MIN_FILTER
wrapS - if > 0 value for GL.GL_TEXTURE_WRAP_S
wrapT - if > 0 value for GL.GL_TEXTURE_WRAP_T
Returns:
index of the texture colorbuffer if bound and configured successfully, otherwise -1
Throws:
GLException - in case the texture colorbuffer couldn't be allocated

attachDepthBuffer

public boolean attachDepthBuffer(GL gl,
                                 int depthComponentType)
                          throws GLException
Attaches one Depth Buffer to this FBO's instance.

This may be done only one time.

Assumes a bound FBO

Leaves the FBO bound!

Parameters:
gl - the current GL context
depthComponentType - GL.GL_DEPTH_COMPONENT16, GL.GL_DEPTH_COMPONENT24 or GL.GL_DEPTH_COMPONENT32
Returns:
true if the depth renderbuffer could be bound and configured, otherwise false
Throws:
GLException - in case the depth renderbuffer couldn't be allocated or one is already attached.

attachStencilBuffer

public boolean attachStencilBuffer(GL gl,
                                   int stencilComponentType)
                            throws GLException
Attaches one Stencil Buffer to this FBO's instance.

This may be done only one time.

Assumes a bound FBO

Leaves the FBO bound!

Parameters:
gl - the current GL context
stencilComponentType - GL.GL_STENCIL_INDEX1, GL.GL_STENCIL_INDEX4 or GL.GL_STENCIL_INDEX8
Returns:
true if the stencil renderbuffer could be bound and configured, otherwise false
Throws:
GLException - in case the stencil renderbuffer couldn't be allocated or one is already attached.

destroy

public void destroy(GL gl)
Parameters:
gl - the current GL context

bind

public void bind(GL gl)
Bind this FBO

In case you have attached more than one color buffer, you may want to setup GL2GL3.glDrawBuffers(int, int[], int).

Parameters:
gl - the current GL context

unbind

public void unbind(GL gl)
Unbind FBO, ie bind 'non' FBO 0

Parameters:
gl - the current GL context

use

public void use(GL gl,
                int texIdx)
Bind the texture with given index.

If a valid texture unit was named via attachTexture2D(..), the unit is activated via glActiveTexture(GL.GL_TEXTURE0 + unit).

Parameters:
gl - the current GL context
texIdx - index of the texture to use, prev. attached w/ attachTexture2D(..)

unuse

public void unuse(GL gl)
Unbind texture, ie bind 'non' texture 0


isBound

public final boolean isBound()

getWidth

public final int getWidth()

getHeight

public final int getHeight()

getFBName

public final int getFBName()

getTextureNumber

public final int getTextureNumber()

getTextureName

public final int getTextureName(int idx)

getTextureUnit

public final int getTextureUnit(int idx)
Returns:
the named texture unit ranging from [0..GL2ES1.GL_MAX_TEXTURE_UNITS-1], or -1 if no unit was desired.

getColorAttachmentNumber

public final int getColorAttachmentNumber()

getStencilBuffer

public final int getStencilBuffer()

getDepthBuffer

public final int getDepthBuffer()

toString

public final String toString()
Overrides:
toString in class Object


Copyright 2010 JogAmp Community.