Open CASCADE Technology  6.9.1
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
OpenGl_FrameBuffer Class Reference

Class implements FrameBuffer Object (FBO) resource intended for off-screen rendering. More...

#include <OpenGl_FrameBuffer.hxx>

Inheritance diagram for OpenGl_FrameBuffer:
Inheritance graph
[legend]

Public Member Functions

 OpenGl_FrameBuffer (GLint theTextureFormat=GL_RGBA8)
 Empty constructor. More...
 
virtual ~OpenGl_FrameBuffer ()
 Destructor. More...
 
virtual void Release (OpenGl_Context *theGlCtx)
 Destroy object - will release GPU memory if any. More...
 
GLsizei GetSizeX () const
 Textures width. More...
 
GLsizei GetSizeY () const
 Textures height. More...
 
GLsizei GetVPSizeX () const
 Viewport width. More...
 
GLsizei GetVPSizeY () const
 Viewport height. More...
 
Standard_Boolean IsValid () const
 Returns true if current object was initialized. More...
 
Standard_Boolean Init (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theViewportSizeX, const GLsizei theViewportSizeY)
 Notice! Obsolete hardware (GeForce FX etc) doesn't support rectangular textures! There are 3 possible results if you are trying to create non power-of-two FBO on these cards: 1) FBO creation will fail, current implementation will try to generate compatible FBO; 2) FBO rendering will be done in software mode (ForceWare 'hack'); 3) FBO rendering will be incorrect (some obsolete Catalyst drivers). More...
 
Standard_Boolean InitLazy (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theViewportSizeX, const GLsizei theViewportSizeY)
 (Re-)initialize FBO with specified dimensions. More...
 
Standard_Boolean InitWithRB (const Handle< OpenGl_Context > &theGlCtx, const GLsizei theViewportSizeX, const GLsizei theViewportSizeY, const GLuint theColorRBufferFromWindow=0)
 (Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures). More...
 
Standard_Boolean InitWrapper (const Handle< OpenGl_Context > &theGlCtx)
 Initialize class from currently bound FBO. Retrieved OpenGL objects will not be destroyed on Release. More...
 
void SetupViewport (const Handle< OpenGl_Context > &theGlCtx)
 Setup viewport to render into FBO. More...
 
void ChangeViewport (const GLsizei theVPSizeX, const GLsizei theVPSizeY)
 Override viewport settings. More...
 
virtual void BindBuffer (const Handle< OpenGl_Context > &theGlCtx)
 Bind frame buffer for drawing and reading (to render into the texture). More...
 
virtual void BindDrawBuffer (const Handle< OpenGl_Context > &theGlCtx)
 Bind frame buffer for drawing GL_DRAW_FRAMEBUFFER (to render into the texture). More...
 
virtual void BindReadBuffer (const Handle< OpenGl_Context > &theGlCtx)
 Bind frame buffer for reading GL_READ_FRAMEBUFFER. More...
 
virtual void UnbindBuffer (const Handle< OpenGl_Context > &theGlCtx)
 Unbind frame buffer. More...
 
const Handle< OpenGl_Texture > & ColorTexture () const
 Returns the color texture. More...
 
const Handle< OpenGl_Texture > & DepthStencilTexture () const
 Returns the depth-stencil texture. More...
 
GLuint ColorRenderBuffer () const
 Returns the color Render Buffer. More...
 
GLuint DepthStencilRenderBuffer () const
 Returns the depth Render Buffer. More...
 
- Public Member Functions inherited from OpenGl_Resource
 OpenGl_Resource ()
 Empty constructor. More...
 
virtual ~OpenGl_Resource ()
 Destructor. Inheritors should call Clean (NULL) within it. More...
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor. More...
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing. More...
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter. More...
 
virtual ~Standard_Transient ()
 Destructor must be virtual. More...
 
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
virtual const Handle_Standard_Type & DynamicType () const
 Returns a type information object about this object. More...
 
Standard_Boolean IsInstance (const Handle_Standard_Type &theType) const
 Returns a true value if this is an instance of Type. More...
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName. More...
 
Standard_Boolean IsKind (const Handle_Standard_Type &theType) const
 Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
Standard_Boolean IsKind (const Standard_CString theTypeName) const
 Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More...
 
virtual Handle_Standard_Transient This () const
 Returns a Handle which references this object. Must never be called to objects created in stack. More...
 
Standard_Integer GetRefCount () const
 Get the reference counter of this object. More...
 

Static Public Attributes

static const GLuint NO_FRAMEBUFFER = 0
 Helpful constants. More...
 
static const GLuint NO_RENDERBUFFER = 0
 

Protected Member Functions

Standard_Boolean isValidFrameBuffer () const
 

Protected Attributes

GLsizei myVPSizeX
 viewport width (should be <= texture width) More...
 
GLsizei myVPSizeY
 viewport height (should be <= texture height) More...
 
GLint myTextFormat
 GL_RGB, GL_RGBA,... More...
 
GLuint myGlFBufferId
 FBO object ID. More...
 
GLuint myGlColorRBufferId
 color Render Buffer object (alternative to myColorTexture) More...
 
GLuint myGlDepthRBufferId
 depth-stencil Render Buffer object (alternative to myDepthStencilTexture) More...
 
bool myIsOwnBuffer
 flag indicating that FBO should be deallocated by this class More...
 
Handle< OpenGl_TexturemyColorTexture
 color texture object More...
 
Handle< OpenGl_TexturemyDepthStencilTexture
 depth-stencil texture object More...
 

Detailed Description

Class implements FrameBuffer Object (FBO) resource intended for off-screen rendering.

Constructor & Destructor Documentation

OpenGl_FrameBuffer::OpenGl_FrameBuffer ( GLint  theTextureFormat = GL_RGBA8)

Empty constructor.

virtual OpenGl_FrameBuffer::~OpenGl_FrameBuffer ( )
virtual

Destructor.

Member Function Documentation

virtual void OpenGl_FrameBuffer::BindBuffer ( const Handle< OpenGl_Context > &  theGlCtx)
virtual

Bind frame buffer for drawing and reading (to render into the texture).

virtual void OpenGl_FrameBuffer::BindDrawBuffer ( const Handle< OpenGl_Context > &  theGlCtx)
virtual

Bind frame buffer for drawing GL_DRAW_FRAMEBUFFER (to render into the texture).

virtual void OpenGl_FrameBuffer::BindReadBuffer ( const Handle< OpenGl_Context > &  theGlCtx)
virtual

Bind frame buffer for reading GL_READ_FRAMEBUFFER.

void OpenGl_FrameBuffer::ChangeViewport ( const GLsizei  theVPSizeX,
const GLsizei  theVPSizeY 
)

Override viewport settings.

GLuint OpenGl_FrameBuffer::ColorRenderBuffer ( ) const
inline

Returns the color Render Buffer.

const Handle< OpenGl_Texture >& OpenGl_FrameBuffer::ColorTexture ( ) const
inline

Returns the color texture.

GLuint OpenGl_FrameBuffer::DepthStencilRenderBuffer ( ) const
inline

Returns the depth Render Buffer.

const Handle< OpenGl_Texture >& OpenGl_FrameBuffer::DepthStencilTexture ( ) const
inline

Returns the depth-stencil texture.

GLsizei OpenGl_FrameBuffer::GetSizeX ( ) const
inline

Textures width.

GLsizei OpenGl_FrameBuffer::GetSizeY ( ) const
inline

Textures height.

GLsizei OpenGl_FrameBuffer::GetVPSizeX ( ) const
inline

Viewport width.

GLsizei OpenGl_FrameBuffer::GetVPSizeY ( ) const
inline

Viewport height.

Standard_Boolean OpenGl_FrameBuffer::Init ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theViewportSizeX,
const GLsizei  theViewportSizeY 
)

Notice! Obsolete hardware (GeForce FX etc) doesn't support rectangular textures! There are 3 possible results if you are trying to create non power-of-two FBO on these cards: 1) FBO creation will fail, current implementation will try to generate compatible FBO; 2) FBO rendering will be done in software mode (ForceWare 'hack'); 3) FBO rendering will be incorrect (some obsolete Catalyst drivers).

Standard_Boolean OpenGl_FrameBuffer::InitLazy ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theViewportSizeX,
const GLsizei  theViewportSizeY 
)

(Re-)initialize FBO with specified dimensions.

Standard_Boolean OpenGl_FrameBuffer::InitWithRB ( const Handle< OpenGl_Context > &  theGlCtx,
const GLsizei  theViewportSizeX,
const GLsizei  theViewportSizeY,
const GLuint  theColorRBufferFromWindow = 0 
)

(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).

Parameters
theGlCtxcurrently bound OpenGL context
theViewportSizeXrequired viewport size, the actual dimensions of FBO might be greater
theViewportSizeYrequired viewport size, the actual dimensions of FBO might be greater
theColorRBufferFromWindowwhen specified - should be ID of already initialized RB object, which will be released within this class
Standard_Boolean OpenGl_FrameBuffer::InitWrapper ( const Handle< OpenGl_Context > &  theGlCtx)

Initialize class from currently bound FBO. Retrieved OpenGL objects will not be destroyed on Release.

Standard_Boolean OpenGl_FrameBuffer::IsValid ( ) const
inline

Returns true if current object was initialized.

Standard_Boolean OpenGl_FrameBuffer::isValidFrameBuffer ( ) const
inlineprotected
virtual void OpenGl_FrameBuffer::Release ( OpenGl_Context theGlCtx)
virtual

Destroy object - will release GPU memory if any.

Implements OpenGl_Resource.

void OpenGl_FrameBuffer::SetupViewport ( const Handle< OpenGl_Context > &  theGlCtx)

Setup viewport to render into FBO.

virtual void OpenGl_FrameBuffer::UnbindBuffer ( const Handle< OpenGl_Context > &  theGlCtx)
virtual

Unbind frame buffer.

Field Documentation

Handle< OpenGl_Texture > OpenGl_FrameBuffer::myColorTexture
protected

color texture object

Handle< OpenGl_Texture > OpenGl_FrameBuffer::myDepthStencilTexture
protected

depth-stencil texture object

GLuint OpenGl_FrameBuffer::myGlColorRBufferId
protected

color Render Buffer object (alternative to myColorTexture)

GLuint OpenGl_FrameBuffer::myGlDepthRBufferId
protected

depth-stencil Render Buffer object (alternative to myDepthStencilTexture)

GLuint OpenGl_FrameBuffer::myGlFBufferId
protected

FBO object ID.

bool OpenGl_FrameBuffer::myIsOwnBuffer
protected

flag indicating that FBO should be deallocated by this class

GLint OpenGl_FrameBuffer::myTextFormat
protected

GL_RGB, GL_RGBA,...

GLsizei OpenGl_FrameBuffer::myVPSizeX
protected

viewport width (should be <= texture width)

GLsizei OpenGl_FrameBuffer::myVPSizeY
protected

viewport height (should be <= texture height)

const GLuint OpenGl_FrameBuffer::NO_FRAMEBUFFER = 0
static

Helpful constants.

const GLuint OpenGl_FrameBuffer::NO_RENDERBUFFER = 0
static

The documentation for this class was generated from the following file: