HDK
|
#include <RE_OGLFramebuffer.h>
Public Types | |
enum | RE_BufferBindMode { RE_BIND_NONE = 0, RE_BIND_READ = 1, RE_BIND_DRAW = 2 } |
Public Member Functions | |
RE_OGLFramebuffer (const char *name=nullptr) | |
~RE_OGLFramebuffer () override | |
bool | init (RE_Render *r) override |
const char * | getName () |
bool | matches (int width, int height, int samples=1) const |
Returns true if the framebuffer is w x h, with samples = samples. More... | |
bool | attachTexture (RE_Render *r, RE_Texture *t, int level=-1, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
bool | setupTexture (RE_Render *r, RE_Texture *t, RE_GPUType data_type, int vectorsize, int miplevel=-1, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER) |
Setup a provided 2D texture to match framebuffer parameters. More... | |
RE_Texture * | createTexture (RE_Render *r, RE_GPUType data_type, int vectorsize, int miplevel=-1, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0, bool rect=false, int samples=0) |
RE_OGLRenderbuffer * | createRenderbuffer (RE_Render *r, RE_GPUType data_type, int vectorsize, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0, int samples=0) |
bool | attachRenderbuffer (RE_Render *r, RE_OGLRenderbuffer *rbuf, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
bool | hasAttachment (RE_Render *r, RE_BufferAttachment buffer_type, int colorbufnum=0) |
RE_OGLRenderbuffer * | getBufferAttachment (RE_Render *r, RE_BufferAttachment buffer_type, int colorbufnum=0) |
RE_Texture * | getTextureAttachment (RE_Render *r, RE_BufferAttachment buffer_type, int colorbufnum=0) |
void | pushAttachment (RE_Render *r, RE_BufferAttachment buffer_type, int colorbufnum=0) |
void | popAttachment (RE_Render *r) |
bool | verifyBufferAttachment (RE_Render *r, RE_BufferAttachment buffer_type, int colorbufnum=0, RE_FBOStatus *status=nullptr) |
Returns true if an attachment if framebuffer-complete. More... | |
void | setResolution (int width, int height) |
int | getWidth () const |
int | getHeight () const |
void | setSamples (int samples) |
int | getSamples () const |
void | setOrigin (fpreal x, fpreal y) |
Sets the origin for the lower-left corner. Normally 0,0. More... | |
void | getOrigin (fpreal &x, fpreal &y) const |
bool | isValid (RE_Render *r, RE_FBOStatus *status=nullptr) |
bool | isAttached (RE_Render *r, RE_Texture *tex) |
Returns true if the texture is attached to this framebuffer. More... | |
bool | bind (RE_Render *r, bool for_draw=true) |
Binds the framebuffer as the active draw or read FBO. More... | |
void | unbind (RE_Render *r, bool switch_only=false, bool restore_ms=true) |
bool | begin (RE_Render *r, RE_BufferAttachment buf, int colorbufnum=0, bool initview=true) |
bool | begin (RE_Render *r) |
void | end (RE_Render *r) |
bool | beginRead (RE_Render *r, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
bool | isActiveDraw () |
Returns true if the framebuffer is being drawn to. More... | |
void | interruptDraw (RE_Render *r) |
void | resumeDraw (RE_Render *r) |
void | drawToBuffer (RE_Render *r, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
void | readFromBuffer (RE_Render *r, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
void | drawToBuffers (RE_Render *r, int num, const int *bufferlist) |
void | drawToAllBuffers (RE_Render *r) |
void | initDraw (RE_Render *r, bool project_mat, bool scissor, bool clear) const |
bool | readAsyncFromBuffers (RE_Render *r, int num, int *bufferlist) |
bool | readFromRenderBuffer (RE_Render *r, void *image, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
bool | blitFromFramebuffer (RE_Render *r, RE_OGLFramebuffer *from_fbo, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0, int destbufnum=-1, const UT_DimRect *from_area=nullptr) |
bool | detach (RE_Render *r, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0, bool freeme=false) |
bool | detachAndFree (RE_Render *r, RE_BufferAttachment buffer_type=RE_COLOR_BUFFER, int colorbufnum=0) |
bool | writeToFile (RE_Render *r, const char *filename, RE_BufferAttachment buf, int colorbufnum=0) |
Mostly for debug, this writes out the given attachment to an image file. More... | |
void | dumpConfig (RE_Render *r, FILE *) |
GLuint | getID () const |
Raw GL ID of the FBO. More... | |
Public Member Functions inherited from RE_ContextSpecificObject | |
RE_ContextSpecificObject () | |
virtual | ~RE_ContextSpecificObject () |
void | initContext (RE_Render *r) |
bool | matchesContext (RE_Render *r) const |
void | clearContext () |
Static Public Member Functions | |
static const char * | getFBOErrorMessage (RE_FBOStatus status) |
Returns the error string for the given status. More... | |
static bool | verifyBinding (RE_Render *r, RE_OGLFramebuffer *fbo, RE_BufferBindMode bindmode=RE_BIND_DRAW) |
Additional Inherited Members | |
Protected Member Functions inherited from RE_ContextSpecificObject | |
RE_Render * | getMyRender () |
bool | initOrCheckRender (RE_Render *r) |
Definition at line 73 of file RE_OGLFramebuffer.h.
Enumerator | |
---|---|
RE_BIND_NONE | |
RE_BIND_READ | |
RE_BIND_DRAW |
Definition at line 266 of file RE_OGLFramebuffer.h.
RE_OGLFramebuffer::RE_OGLFramebuffer | ( | const char * | name = nullptr | ) |
|
override |
bool RE_OGLFramebuffer::attachRenderbuffer | ( | RE_Render * | r, |
RE_OGLRenderbuffer * | rbuf, | ||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
bool RE_OGLFramebuffer::attachTexture | ( | RE_Render * | r, |
RE_Texture * | t, | ||
int | level = -1 , |
||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
Attach a texture to the framebuffer. You are still responsible for deleting it. 'Level' is the mip level for 2D textures, the cube face (RE_TextureCubeFace) for cube maps, and the Z-coord for 3D textures.
bool RE_OGLFramebuffer::begin | ( | RE_Render * | r, |
RE_BufferAttachment | buf, | ||
int | colorbufnum = 0 , |
||
bool | initview = true |
||
) |
do all rendering between the begin/end statements. Renders to the given attachment. Specify initview = true set the modelview matrix to an orthographic projection the size of the framebuffer, the viewport to the size of the framebuffer, and to push the current GL state (via RE_OGLRender::pushState(1)).
bool RE_OGLFramebuffer::begin | ( | RE_Render * | r | ) |
bool RE_OGLFramebuffer::beginRead | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
bool RE_OGLFramebuffer::bind | ( | RE_Render * | r, |
bool | for_draw = true |
||
) |
Binds the framebuffer as the active draw or read FBO.
bool RE_OGLFramebuffer::blitFromFramebuffer | ( | RE_Render * | r, |
RE_OGLFramebuffer * | from_fbo, | ||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 , |
||
int | destbufnum = -1 , |
||
const UT_DimRect * | from_area = nullptr |
||
) |
Copies the framebuffer 'from_fbo' to this framebuffer. This is often used for resolving multisample framebuffers into an image. if destbufnum == -1, colorbufnum is used as the dest buffer as well.
RE_OGLRenderbuffer* RE_OGLFramebuffer::createRenderbuffer | ( | RE_Render * | r, |
RE_GPUType | data_type, | ||
int | vectorsize, | ||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 , |
||
int | samples = 0 |
||
) |
Create a renderbuffer and attach it to the framebuffer. This will be cleaned up when you delete the render buffer, or call clearAttachment() on it. If 'samples' > 1, this is a multisample (AA) Framebuffer, which must be blit'ed to a single-sample FBO before being read.
RE_Texture* RE_OGLFramebuffer::createTexture | ( | RE_Render * | r, |
RE_GPUType | data_type, | ||
int | vectorsize, | ||
int | miplevel = -1 , |
||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 , |
||
bool | rect = false , |
||
int | samples = 0 |
||
) |
Create a 2D texture and attach it to the framebuffer. You are still responsible for deleting it. Specify rect = true to create a texture rectangle (check to see that this extension is supported before calling this method). Samples > 0 requires the texture-multisample extension, and these can only be accessed via shaders.
bool RE_OGLFramebuffer::detach | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 , |
||
bool | freeme = false |
||
) |
Removes the attachment, and frees the renderbuffer or texture if freeme is true.
|
inline |
Definition at line 261 of file RE_OGLFramebuffer.h.
Draws to all color buffers up to getMaxDrawBuffers(). The Z/Stencil buffers are written as well if depth or stencil writing is enabled.
void RE_OGLFramebuffer::drawToBuffer | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
allows you to draw to multiple buffers at once. The type RE_COLOR_BUFFER is assumed. There is a limit on the number you can write to simultaneously, getMaxDrawBuffers().
RE_OGLRenderbuffer* RE_OGLFramebuffer::getBufferAttachment | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type, | ||
int | colorbufnum = 0 |
||
) |
|
static |
Returns the error string for the given status.
|
inline |
Definition at line 159 of file RE_OGLFramebuffer.h.
|
inline |
Raw GL ID of the FBO.
Definition at line 283 of file RE_OGLFramebuffer.h.
|
inline |
Definition at line 81 of file RE_OGLFramebuffer.h.
|
inline |
Definition at line 162 of file RE_OGLFramebuffer.h.
RE_Texture* RE_OGLFramebuffer::getTextureAttachment | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type, | ||
int | colorbufnum = 0 |
||
) |
|
inline |
Definition at line 158 of file RE_OGLFramebuffer.h.
bool RE_OGLFramebuffer::hasAttachment | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type, | ||
int | colorbufnum = 0 |
||
) |
|
overridevirtual |
Implements RE_ContextSpecificObject.
void RE_OGLFramebuffer::initDraw | ( | RE_Render * | r, |
bool | project_mat, | ||
bool | scissor, | ||
bool | clear | ||
) | const |
Initialize the GL state with the various settings in this FBO: project_mat - set the projection matrix scissor - set the scissor to the resolution of the view clear - clear the contents This always sets the viewport to the size of the FBO.
Definition at line 204 of file RE_OGLFramebuffer.h.
|
inline |
Returns true if the framebuffer is being drawn to.
Definition at line 202 of file RE_OGLFramebuffer.h.
bool RE_OGLFramebuffer::isAttached | ( | RE_Render * | r, |
RE_Texture * | tex | ||
) |
Returns true if the texture is attached to this framebuffer.
bool RE_OGLFramebuffer::isValid | ( | RE_Render * | r, |
RE_FBOStatus * | status = nullptr |
||
) |
Returns true if the framebuffer is ready to render. Optionally returns a more detailed failure description if 'status' is provided.
Returns true if the framebuffer is w x h, with samples = samples.
void RE_OGLFramebuffer::pushAttachment | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type, | ||
int | colorbufnum = 0 |
||
) |
Pushes an attachment, setting the specified buffer to nullptr. Calls to pop attachments will always pop to the original location, replacing anything that has been put there in the mean time.
void RE_OGLFramebuffer::readFromBuffer | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
bool RE_OGLFramebuffer::readFromRenderBuffer | ( | RE_Render * | r, |
void * | image, | ||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER , |
||
int | colorbufnum = 0 |
||
) |
reads the data from the render buffer specified into 'buffer'. 'buffer' must be large enough to contain the full renderbuffer size.
Definition at line 205 of file RE_OGLFramebuffer.h.
Sets the origin for the lower-left corner. Normally 0,0.
You must call this if attaching textures (if you are creating textures, the resulotion of the textures you pass is used).
bool RE_OGLFramebuffer::setupTexture | ( | RE_Render * | r, |
RE_Texture * | t, | ||
RE_GPUType | data_type, | ||
int | vectorsize, | ||
int | miplevel = -1 , |
||
RE_BufferAttachment | buffer_type = RE_COLOR_BUFFER |
||
) |
Setup a provided 2D texture to match framebuffer parameters.
Unbind the current framebuffer. 'switch_only' indicates that you are immediately changing to another FBO.
|
static |
bool RE_OGLFramebuffer::verifyBufferAttachment | ( | RE_Render * | r, |
RE_BufferAttachment | buffer_type, | ||
int | colorbufnum = 0 , |
||
RE_FBOStatus * | status = nullptr |
||
) |
Returns true if an attachment if framebuffer-complete.
bool RE_OGLFramebuffer::writeToFile | ( | RE_Render * | r, |
const char * | filename, | ||
RE_BufferAttachment | buf, | ||
int | colorbufnum = 0 |
||
) |
Mostly for debug, this writes out the given attachment to an image file.