Annotation of /linden_release/linden/indra/llrender/llrendertarget.h
Parent Directory
|
Revision Log
Revision 57 - (view) (download)
| 1 : | mjm | 57 | /** |
| 2 : | * @file llrendertarget.h | ||
| 3 : | * @brief Off screen render target abstraction. Loose wrapper for GL_EXT_framebuffer_objects. | ||
| 4 : | * | ||
| 5 : | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
| 6 : | * | ||
| 7 : | * Copyright (c) 2001-2008, Linden Research, Inc. | ||
| 8 : | * | ||
| 9 : | * Second Life Viewer Source Code | ||
| 10 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 11 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 12 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 13 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 14 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 15 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 16 : | * | ||
| 17 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 18 : | * it is applied to this Source Code. View the full text of the exception | ||
| 19 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 20 : | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 21 : | * | ||
| 22 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 23 : | * that you have read and understood your obligations described above, | ||
| 24 : | * and agree to abide by those obligations. | ||
| 25 : | * | ||
| 26 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 27 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 28 : | * COMPLETENESS OR PERFORMANCE. | ||
| 29 : | * $/LicenseInfo$ | ||
| 30 : | */ | ||
| 31 : | |||
| 32 : | #ifndef LL_LLRENDERTARGET_H | ||
| 33 : | #define LL_LLRENDERTARGET_H | ||
| 34 : | |||
| 35 : | #include "llgl.h" | ||
| 36 : | |||
| 37 : | /* | ||
| 38 : | SAMPLE USAGE: | ||
| 39 : | |||
| 40 : | LLRenderTarget target; | ||
| 41 : | |||
| 42 : | ... | ||
| 43 : | |||
| 44 : | //allocate a 256x256 RGBA render target with depth buffer | ||
| 45 : | target.allocate(256,256,GL_RGBA,TRUE); | ||
| 46 : | |||
| 47 : | //render to contents of offscreen buffer | ||
| 48 : | target.bindTarget(); | ||
| 49 : | target.clear(); | ||
| 50 : | ... <issue drawing commands> ... | ||
| 51 : | target.flush(); | ||
| 52 : | |||
| 53 : | ... | ||
| 54 : | |||
| 55 : | //use target as a texture | ||
| 56 : | target.bindTexture(); | ||
| 57 : | ... <issue drawing commands> ... | ||
| 58 : | |||
| 59 : | */ | ||
| 60 : | |||
| 61 : | |||
| 62 : | class LLRenderTarget | ||
| 63 : | { | ||
| 64 : | public: | ||
| 65 : | //whether or not to use FBO implementation | ||
| 66 : | static BOOL sUseFBO; | ||
| 67 : | |||
| 68 : | LLRenderTarget(); | ||
| 69 : | ~LLRenderTarget(); | ||
| 70 : | |||
| 71 : | //allocate resources for rendering | ||
| 72 : | //must be called before use | ||
| 73 : | //multiple calls will release previously allocated resources | ||
| 74 : | void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = FALSE); | ||
| 75 : | |||
| 76 : | //allocate a depth texture | ||
| 77 : | void allocateDepth(); | ||
| 78 : | |||
| 79 : | //free any allocated resources | ||
| 80 : | //safe to call redundantly | ||
| 81 : | void release(); | ||
| 82 : | |||
| 83 : | //bind target for rendering | ||
| 84 : | //applies appropriate viewport | ||
| 85 : | void bindTarget(); | ||
| 86 : | |||
| 87 : | //unbind target for rendering | ||
| 88 : | static void unbindTarget(); | ||
| 89 : | |||
| 90 : | //clear render targer, clears depth buffer if present, | ||
| 91 : | //uses scissor rect if in copy-to-texture mode | ||
| 92 : | void clear(); | ||
| 93 : | |||
| 94 : | //get applied viewport | ||
| 95 : | void getViewport(S32* viewport); | ||
| 96 : | |||
| 97 : | //get X resolution | ||
| 98 : | U32 getWidth() const { return mResX; } | ||
| 99 : | |||
| 100 : | //get Y resolution | ||
| 101 : | U32 getHeight() const { return mResY; } | ||
| 102 : | |||
| 103 : | //bind results of render for sampling | ||
| 104 : | void bindTexture(); | ||
| 105 : | |||
| 106 : | //bind results of render for sampling depth buffer | ||
| 107 : | void bindDepth(); | ||
| 108 : | |||
| 109 : | //flush rendering operations | ||
| 110 : | //must be called when rendering is complete | ||
| 111 : | //should be used 1:1 with bindTarget | ||
| 112 : | // call bindTarget once, do all your rendering, call flush once | ||
| 113 : | // if fetch_depth is TRUE, every effort will be made to copy the depth buffer into | ||
| 114 : | // the current depth texture. A depth texture will be allocated if needed. | ||
| 115 : | void flush(BOOL fetch_depth = FALSE); | ||
| 116 : | |||
| 117 : | //Returns TRUE if target is ready to be rendered into. | ||
| 118 : | //That is, if the target has been allocated with at least | ||
| 119 : | //one renderable attachment (i.e. color buffer, depth buffer). | ||
| 120 : | BOOL isComplete() const; | ||
| 121 : | |||
| 122 : | private: | ||
| 123 : | U32 mResX; | ||
| 124 : | U32 mResY; | ||
| 125 : | U32 mTex; | ||
| 126 : | U32 mFBO; | ||
| 127 : | U32 mDepth; | ||
| 128 : | U32 mStencil; | ||
| 129 : | BOOL mUseDepth; | ||
| 130 : | BOOL mRenderDepth; | ||
| 131 : | U32 mUsage; | ||
| 132 : | |||
| 133 : | }; | ||
| 134 : | |||
| 135 : | #endif | ||
| 136 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

