Open CASCADE Technology
7.7.0
|
Class implements FrameBuffer Object (FBO) resource intended for off-screen rendering. More...
#include <OpenGl_FrameBuffer.hxx>
Public Member Functions | |
OpenGl_FrameBuffer (const TCollection_AsciiString &theResourceId=TCollection_AsciiString()) | |
Empty constructor. More... | |
virtual | ~OpenGl_FrameBuffer () |
Destructor. More... | |
virtual void | Release (OpenGl_Context *theGlCtx) override |
Destroy object - will release GPU memory if any. More... | |
Standard_Integer | NbSamples () const |
Number of multisampling samples. More... | |
Standard_Integer | NbColorBuffers () const |
Number of color buffers. More... | |
bool | HasColor () const |
Return true if FBO has been created with color attachment. More... | |
bool | HasDepth () const |
Return true if FBO has been created with depth attachment. More... | |
Graphic3d_Vec2i | GetSize () const |
Return textures width x height. More... | |
Standard_Integer | GetSizeX () const |
Textures width. More... | |
Standard_Integer | GetSizeY () const |
Textures height. More... | |
Graphic3d_Vec2i | GetVPSize () const |
Return viewport width x height. More... | |
Standard_Integer | GetVPSizeX () const |
Viewport width. More... | |
Standard_Integer | GetVPSizeY () const |
Viewport height. More... | |
Graphic3d_Vec2i | GetInitVPSize () const |
Return viewport width x height. More... | |
Standard_Integer | GetInitVPSizeX () const |
Viewport width. More... | |
Standard_Integer | GetInitVPSizeY () 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 Graphic3d_Vec2i &theSize, const OpenGl_ColorFormats &theColorFormats, const Handle< OpenGl_Texture > &theDepthStencilTexture, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into single/multiple color buffer and depth textures. More... | |
Standard_Boolean | Init (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theSize, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into textures. More... | |
Standard_Boolean | Init (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theSize, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into single/multiple color buffer and depth textures. More... | |
Standard_Boolean | InitLazy (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theViewportSize, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
(Re-)initialize FBO with specified dimensions. More... | |
Standard_Boolean | InitLazy (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theViewportSize, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
(Re-)initialize FBO with specified dimensions. More... | |
Standard_Boolean | InitLazy (const Handle< OpenGl_Context > &theGlCtx, const OpenGl_FrameBuffer &theFbo, const Standard_Boolean theToKeepMsaa=true) |
(Re-)initialize FBO with properties taken from another FBO. More... | |
Standard_Boolean | InitRenderBuffer (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theSize, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=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 | InitWithRB (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theSize, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const unsigned int theColorRBufferFromWindow) |
(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... | |
Standard_Boolean | InitWrapper (const Handle< OpenGl_Context > &theGlContext, const NCollection_Sequence< Handle< OpenGl_Texture >> &theColorTextures, const Handle< OpenGl_Texture > &theDepthTexture=Handle< OpenGl_Texture >()) |
Wrap existing color textures. More... | |
void | SetupViewport (const Handle< OpenGl_Context > &theGlCtx) |
Setup viewport to render into FBO. More... | |
void | ChangeViewport (const Standard_Integer theVPSizeX, const Standard_Integer 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 Standard_Integer theColorBufferIndex=0) const |
Returns the color texture for the given color buffer index. More... | |
const Handle< OpenGl_Texture > & | DepthStencilTexture () const |
Returns the depth-stencil texture. More... | |
bool | IsColorRenderBuffer () const |
Returns TRUE if color Render Buffer is defined. More... | |
unsigned int | ColorRenderBuffer () const |
Returns the color Render Buffer. More... | |
bool | IsDepthStencilRenderBuffer () const |
Returns TRUE if depth Render Buffer is defined. More... | |
unsigned int | DepthStencilRenderBuffer () const |
Returns the depth Render Buffer. More... | |
virtual Standard_Size | EstimatedDataSize () const override |
Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules. More... | |
Standard_Boolean | initRenderBuffer (const Handle< OpenGl_Context > &theGlCtx, const Graphic3d_Vec2i &theSize, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples, const unsigned int theColorRBufferFromWindow) |
(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures). More... | |
bool | Init (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const OpenGl_ColorFormats &theColorFormats, const Handle< OpenGl_Texture > &theDepthStencilTexture, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into single/multiple color buffer and depth textures. More... | |
bool | Init (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into textures. More... | |
bool | Init (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
Initialize FBO for rendering into single/multiple color buffer and depth textures. More... | |
bool | InitLazy (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theViewportSizeX, const Standard_Integer theViewportSizeY, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
(Re-)initialize FBO with specified dimensions. More... | |
bool | InitLazy (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theViewportSizeX, const Standard_Integer theViewportSizeY, const OpenGl_ColorFormats &theColorFormats, const Standard_Integer theDepthFormat, const Standard_Integer theNbSamples=0) |
(Re-)initialize FBO with specified dimensions. More... | |
bool | InitWithRB (const Handle< OpenGl_Context > &theGlCtx, const Standard_Integer theSizeX, const Standard_Integer theSizeY, const Standard_Integer theColorFormat, const Standard_Integer theDepthFormat, const unsigned int 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... | |
Public Member Functions inherited from OpenGl_NamedResource | |
OpenGl_NamedResource (const TCollection_AsciiString &theId) | |
Empty constructor. More... | |
const TCollection_AsciiString & | ResourceId () const |
Return resource name. 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... | |
virtual void | DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const |
Dumps the content of me into the stream. More... | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (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 opencascade::handle< Standard_Type > & | DynamicType () const |
Returns a type descriptor about this object. More... | |
Standard_Boolean | IsInstance (const opencascade::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 opencascade::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... | |
Standard_Transient * | This () const |
Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
void | IncrementRefCounter () const |
Increments the reference counter of this object. More... | |
Standard_Integer | DecrementRefCounter () const |
Decrements the reference counter of this object; returns the decremented value. More... | |
Static Public Member Functions | |
static Standard_Boolean | BufferDump (const Handle< OpenGl_Context > &theGlCtx, const Handle< OpenGl_FrameBuffer > &theFbo, Image_PixMap &theImage, Graphic3d_BufferType theBufferType) |
Dump content into image. More... | |
Static Public Member Functions inherited from Standard_Transient | |
static const char * | get_type_name () |
Returns a type descriptor about this object. More... | |
static const opencascade::handle< Standard_Type > & | get_type_descriptor () |
Returns type descriptor of Standard_Transient class. More... | |
Static Public Attributes | |
static const unsigned int | NO_FRAMEBUFFER = 0 |
Helpful constants. More... | |
static const unsigned int | NO_RENDERBUFFER = 0 |
Protected Types | |
typedef NCollection_Vector< Handle< OpenGl_Texture > > | OpenGl_TextureArray |
Protected Member Functions | |
Standard_Boolean | isValidFrameBuffer () const |
Protected Attributes | |
Standard_Integer | myInitVPSizeX |
viewport width specified during initialization (kept even on failure) More... | |
Standard_Integer | myInitVPSizeY |
viewport height specified during initialization (kept even on failure) More... | |
Standard_Integer | myVPSizeX |
viewport width (should be <= texture width) More... | |
Standard_Integer | myVPSizeY |
viewport height (should be <= texture height) More... | |
Standard_Integer | myNbSamples |
number of MSAA samples More... | |
OpenGl_ColorFormats | myColorFormats |
sized format for color texture, GL_RGBA8 by default More... | |
Standard_Integer | myDepthFormat |
sized format for depth-stencil texture, GL_DEPTH24_STENCIL8 by default More... | |
unsigned int | myGlFBufferId |
FBO object ID. More... | |
unsigned int | myGlColorRBufferId |
color Render Buffer object (alternative to myColorTexture) More... | |
unsigned int | myGlDepthRBufferId |
depth-stencil Render Buffer object (alternative to myDepthStencilTexture) More... | |
bool | myIsOwnBuffer |
flag indicating that FBO should be deallocated by this class More... | |
bool | myIsOwnColor |
flag indicating that color textures should be deallocated by this class More... | |
bool | myIsOwnDepth |
flag indicating that depth texture should be deallocated by this class More... | |
OpenGl_TextureArray | myColorTextures |
color texture objects More... | |
Handle< OpenGl_Texture > | myDepthStencilTexture |
depth-stencil texture object More... | |
Protected Attributes inherited from OpenGl_NamedResource | |
TCollection_AsciiString | myResourceId |
resource name More... | |
Additional Inherited Members | |
Public Types inherited from Standard_Transient | |
typedef void | base_type |
Returns a type descriptor about this object. More... | |
Class implements FrameBuffer Object (FBO) resource intended for off-screen rendering.
|
protected |
OpenGl_FrameBuffer::OpenGl_FrameBuffer | ( | const TCollection_AsciiString & | theResourceId = TCollection_AsciiString() | ) |
Empty constructor.
|
virtual |
Destructor.
|
virtual |
Bind frame buffer for drawing and reading (to render into the texture).
Reimplemented in D3DHost_FrameBuffer.
|
virtual |
Bind frame buffer for drawing GL_DRAW_FRAMEBUFFER (to render into the texture).
|
virtual |
Bind frame buffer for reading GL_READ_FRAMEBUFFER.
|
static |
Dump content into image.
theGlCtx | bound OpenGL context |
theFbo | FBO to dump (or window buffer, if NULL) |
theImage | target image |
theBufferType | buffer type (attachment) to dump |
void OpenGl_FrameBuffer::ChangeViewport | ( | const Standard_Integer | theVPSizeX, |
const Standard_Integer | theVPSizeY | ||
) |
Override viewport settings.
|
inline |
Returns the color Render Buffer.
|
inline |
Returns the color texture for the given color buffer index.
|
inline |
Returns the depth Render Buffer.
|
inline |
Returns the depth-stencil texture.
|
overridevirtual |
Returns estimated GPU memory usage for holding data without considering overheads and allocation alignment rules.
Implements OpenGl_Resource.
|
inline |
Return viewport width x height.
|
inline |
Viewport width.
|
inline |
Viewport height.
|
inline |
Return textures width x height.
Standard_Integer OpenGl_FrameBuffer::GetSizeX | ( | ) | const |
Textures width.
Standard_Integer OpenGl_FrameBuffer::GetSizeY | ( | ) | const |
Textures height.
|
inline |
Return viewport width x height.
|
inline |
Viewport width.
|
inline |
Viewport height.
|
inline |
Return true if FBO has been created with color attachment.
|
inline |
Return true if FBO has been created with depth attachment.
Standard_Boolean OpenGl_FrameBuffer::Init | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theSize, | ||
const OpenGl_ColorFormats & | theColorFormats, | ||
const Handle< OpenGl_Texture > & | theDepthStencilTexture, | ||
const Standard_Integer | theNbSamples = 0 |
||
) |
Initialize FBO for rendering into single/multiple color buffer and depth textures.
theGlCtx | currently bound OpenGL context |
theSize | texture width x height |
theColorFormats | list of color texture sized format (0 means no color attachment), e.g. GL_RGBA8 |
theDepthStencilTexture | depth-stencil texture |
theNbSamples | MSAA number of samples (0 means normal texture) |
Standard_Boolean OpenGl_FrameBuffer::Init | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theSize, | ||
const Standard_Integer | theColorFormat, | ||
const Standard_Integer | theDepthFormat, | ||
const Standard_Integer | theNbSamples = 0 |
||
) |
Initialize FBO for rendering into textures.
theGlCtx | currently bound OpenGL context |
theSize | texture width x height |
theColorFormat | color texture sized format (0 means no color attachment), e.g. GL_RGBA8 |
theDepthFormat | depth-stencil texture sized format (0 means no depth attachment), e.g. GL_DEPTH24_STENCIL8 |
theNbSamples | MSAA number of samples (0 means normal texture) |
Standard_Boolean OpenGl_FrameBuffer::Init | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theSize, | ||
const OpenGl_ColorFormats & | theColorFormats, | ||
const Standard_Integer | theDepthFormat, | ||
const Standard_Integer | theNbSamples = 0 |
||
) |
Initialize FBO for rendering into single/multiple color buffer and depth textures.
theGlCtx | currently bound OpenGL context |
theSize | texture width x height |
theColorFormats | list of color texture sized format (0 means no color attachment), e.g. GL_RGBA8 |
theDepthFormat | depth-stencil texture sized format (0 means no depth attachment), e.g. GL_DEPTH24_STENCIL8 |
theNbSamples | MSAA number of samples (0 means normal texture) |
|
inline |
Initialize FBO for rendering into single/multiple color buffer and depth textures.
|
inline |
Initialize FBO for rendering into textures.
|
inline |
Initialize FBO for rendering into single/multiple color buffer and depth textures.
Standard_Boolean OpenGl_FrameBuffer::InitLazy | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theViewportSize, | ||
const Standard_Integer | theColorFormat, | ||
const Standard_Integer | theDepthFormat, | ||
const Standard_Integer | theNbSamples = 0 |
||
) |
(Re-)initialize FBO with specified dimensions.
Standard_Boolean OpenGl_FrameBuffer::InitLazy | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theViewportSize, | ||
const OpenGl_ColorFormats & | theColorFormats, | ||
const Standard_Integer | theDepthFormat, | ||
const Standard_Integer | theNbSamples = 0 |
||
) |
(Re-)initialize FBO with specified dimensions.
|
inline |
(Re-)initialize FBO with properties taken from another FBO.
|
inline |
(Re-)initialize FBO with specified dimensions.
|
inline |
(Re-)initialize FBO with specified dimensions.
|
inline |
(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
theGlCtx | currently bound OpenGL context |
theSize | render buffer width x height |
theColorFormats | list of color render buffer sized format, e.g. GL_RGBA8; list should define only one element |
theDepthFormat | depth-stencil render buffer sized format, e.g. GL_DEPTH24_STENCIL8 |
theNbSamples | MSAA number of samples (0 means normal render buffer) |
Standard_Boolean OpenGl_FrameBuffer::initRenderBuffer | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theSize, | ||
const OpenGl_ColorFormats & | theColorFormats, | ||
const Standard_Integer | theDepthFormat, | ||
const Standard_Integer | theNbSamples, | ||
const unsigned int | theColorRBufferFromWindow | ||
) |
(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
theGlCtx | currently bound OpenGL context |
theSize | render buffer width x height |
theColorFormats | list of color render buffer sized format, e.g. GL_RGBA8 |
theDepthFormat | depth-stencil render buffer sized format, e.g. GL_DEPTH24_STENCIL8 |
theNbSamples | MSAA number of samples (0 means normal render buffer) |
theColorRBufferFromWindow | when specified - should be ID of already initialized RB object, which will be released within this class |
Standard_Boolean OpenGl_FrameBuffer::InitWithRB | ( | const Handle< OpenGl_Context > & | theGlCtx, |
const Graphic3d_Vec2i & | theSize, | ||
const Standard_Integer | theColorFormat, | ||
const Standard_Integer | theDepthFormat, | ||
const unsigned int | theColorRBufferFromWindow | ||
) |
(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
theGlCtx | currently bound OpenGL context |
theSize | render buffer width x height |
theColorFormat | color render buffer sized format, e.g. GL_RGBA8 |
theDepthFormat | depth-stencil render buffer sized format, e.g. GL_DEPTH24_STENCIL8 |
theColorRBufferFromWindow | should be ID of already initialized RB object, which will be released within this class |
|
inline |
(Re-)initialize FBO with specified dimensions. The Render Buffer Objects will be used for Color, Depth and Stencil attachments (as opposite to textures).
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::InitWrapper | ( | const Handle< OpenGl_Context > & | theGlContext, |
const NCollection_Sequence< Handle< OpenGl_Texture >> & | theColorTextures, | ||
const Handle< OpenGl_Texture > & | theDepthTexture = Handle< OpenGl_Texture >() |
||
) |
Wrap existing color textures.
|
inline |
Returns TRUE if color Render Buffer is defined.
|
inline |
Returns TRUE if depth Render Buffer is defined.
|
inline |
Returns true if current object was initialized.
|
inlineprotected |
|
inline |
Number of color buffers.
|
inline |
Number of multisampling samples.
|
overridevirtual |
Destroy object - will release GPU memory if any.
Implements OpenGl_Resource.
Reimplemented in D3DHost_FrameBuffer.
void OpenGl_FrameBuffer::SetupViewport | ( | const Handle< OpenGl_Context > & | theGlCtx | ) |
Setup viewport to render into FBO.
|
virtual |
Unbind frame buffer.
|
protected |
sized format for color texture, GL_RGBA8 by default
|
protected |
color texture objects
|
protected |
sized format for depth-stencil texture, GL_DEPTH24_STENCIL8 by default
|
protected |
depth-stencil texture object
|
protected |
color Render Buffer object (alternative to myColorTexture)
|
protected |
depth-stencil Render Buffer object (alternative to myDepthStencilTexture)
|
protected |
FBO object ID.
|
protected |
viewport width specified during initialization (kept even on failure)
|
protected |
viewport height specified during initialization (kept even on failure)
|
protected |
flag indicating that FBO should be deallocated by this class
|
protected |
flag indicating that color textures should be deallocated by this class
|
protected |
flag indicating that depth texture should be deallocated by this class
|
protected |
number of MSAA samples
|
protected |
viewport width (should be <= texture width)
|
protected |
viewport height (should be <= texture height)
|
static |
Helpful constants.
|
static |