diff options
Diffstat (limited to 'indra/llrender/llrendertarget.h')
-rw-r--r-- | indra/llrender/llrendertarget.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h index 5f3214add3..71727bf09d 100644 --- a/indra/llrender/llrendertarget.h +++ b/indra/llrender/llrendertarget.h @@ -33,6 +33,8 @@ #include "llrender.h" /* + Wrapper around OpenGL framebuffer objects for use in render-to-texture + SAMPLE USAGE: LLRenderTarget target; @@ -73,7 +75,12 @@ public: //allocate resources for rendering //must be called before use //multiple calls will release previously allocated resources - bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth, bool sample_depth, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE, bool use_fbo = false, S32 samples = 0); + // resX - width + // resY - height + // color_fmt - GL color format (e.g. GL_RGB) + // depth - if true, allocate a depth buffer + // usage - deprecated, should always be TT_TEXTURE + bool allocate(U32 resx, U32 resy, U32 color_fmt, bool depth = false, LLTexUnit::eTextureType usage = LLTexUnit::TT_TEXTURE); //resize existing attachments to use new resolution and color format // CAUTION: if the GL runs out of memory attempting to resize, this render target will be undefined @@ -93,7 +100,7 @@ public: // attachment -- LLImageGL to render into // use_name -- optional texture name to target instead of attachment->getTexName() // NOTE: setColorAttachment and releaseColorAttachment cannot be used in conjuction with - // addColorAttachment, allocateDepth, resize, etc. + // addColorAttachment, allocateDepth, resize, etc. void setColorAttachment(LLImageGL* attachment, LLGLuint use_name = 0); // detach from current color attachment @@ -111,14 +118,19 @@ public: //free any allocated resources //safe to call redundantly + // asserts that this target is not currently bound or present in the RT stack void release(); //bind target for rendering //applies appropriate viewport + // If an LLRenderTarget is currently bound, stores a reference to that LLRenderTarget + // and restores previous binding on flush() (maintains a stack of Render Targets) + // Asserts that this target is not currently bound in the stack void bindTarget(); //clear render targer, clears depth buffer if present, //uses scissor rect if in copy-to-texture mode + // asserts that this target is currently bound void clear(U32 mask = 0xFFFFFFFF); //get applied viewport @@ -136,7 +148,6 @@ public: U32 getNumTextures() const; U32 getDepth(void) const { return mDepth; } - bool canSampleDepth() const { return mSampleDepth; } void bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilterOptions filter_options = LLTexUnit::TFO_BILINEAR); @@ -144,15 +155,18 @@ public: //must be called when rendering is complete //should be used 1:1 with bindTarget // call bindTarget once, do all your rendering, call flush once - // if fetch_depth is TRUE, every effort will be made to copy the depth buffer into - // the current depth texture. A depth texture will be allocated if needed. - void flush(bool fetch_depth = FALSE); + // If an LLRenderTarget was bound when bindTarget was called, binds that RenderTarget for rendering (maintains RT stack) + // asserts that this target is currently bound + void flush(); //Returns TRUE if target is ready to be rendered into. //That is, if the target has been allocated with at least //one renderable attachment (i.e. color buffer, depth buffer). bool isComplete() const; + // Returns true if this RenderTarget is bound somewhere in the stack + bool isBoundInStack() const; + static LLRenderTarget* getCurrentBoundTarget() { return sBoundTarget; } protected: @@ -161,13 +175,10 @@ protected: std::vector<U32> mTex; std::vector<U32> mInternalFormat; U32 mFBO; - U32 mPreviousFBO; - U32 mPreviousResX; - U32 mPreviousResY; + LLRenderTarget* mPreviousRT = nullptr; - U32 mDepth; + U32 mDepth; bool mUseDepth; - bool mSampleDepth; LLTexUnit::eTextureType mUsage; |