diff options
author | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:42 -0500 |
commit | ce28e056c20bf2723f565bbf464b87781ec248a2 (patch) | |
tree | ef7b0501c4de4b631a916305cbc2a5fdc125e52d /linden/indra/llrender | |
parent | Second Life viewer sources 1.19.1.4b (diff) | |
download | meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.zip meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.gz meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.bz2 meta-impy-ce28e056c20bf2723f565bbf464b87781ec248a2.tar.xz |
Second Life viewer sources 1.20.2
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llrender/llfontgl.cpp | 6 | ||||
-rw-r--r-- | linden/indra/llrender/llfontgl.h | 5 | ||||
-rw-r--r-- | linden/indra/llrender/llrendertarget.cpp | 59 | ||||
-rw-r--r-- | linden/indra/llrender/llrendertarget.h | 27 |
4 files changed, 79 insertions, 18 deletions
diff --git a/linden/indra/llrender/llfontgl.cpp b/linden/indra/llrender/llfontgl.cpp index 9298e8c..53e8c2b 100644 --- a/linden/indra/llrender/llfontgl.cpp +++ b/linden/indra/llrender/llfontgl.cpp | |||
@@ -47,6 +47,7 @@ F32 LLFontGL::sVertDPI = 96.f; | |||
47 | F32 LLFontGL::sHorizDPI = 96.f; | 47 | F32 LLFontGL::sHorizDPI = 96.f; |
48 | F32 LLFontGL::sScaleX = 1.f; | 48 | F32 LLFontGL::sScaleX = 1.f; |
49 | F32 LLFontGL::sScaleY = 1.f; | 49 | F32 LLFontGL::sScaleY = 1.f; |
50 | BOOL LLFontGL::sDisplayFont = TRUE ; | ||
50 | LLString LLFontGL::sAppDir; | 51 | LLString LLFontGL::sAppDir; |
51 | 52 | ||
52 | LLFontGL* LLFontGL::sMonospace = NULL; | 53 | LLFontGL* LLFontGL::sMonospace = NULL; |
@@ -559,6 +560,11 @@ S32 LLFontGL::render(const LLWString &wstr, | |||
559 | BOOL use_embedded, | 560 | BOOL use_embedded, |
560 | BOOL use_ellipses) const | 561 | BOOL use_ellipses) const |
561 | { | 562 | { |
563 | if(!sDisplayFont) //do not display texts | ||
564 | { | ||
565 | return wstr.length() ; | ||
566 | } | ||
567 | |||
562 | LLGLEnable tex(GL_TEXTURE_2D); | 568 | LLGLEnable tex(GL_TEXTURE_2D); |
563 | 569 | ||
564 | if (wstr.empty()) | 570 | if (wstr.empty()) |
diff --git a/linden/indra/llrender/llfontgl.h b/linden/indra/llrender/llfontgl.h index ce55385..4df1063 100644 --- a/linden/indra/llrender/llfontgl.h +++ b/linden/indra/llrender/llfontgl.h | |||
@@ -204,6 +204,8 @@ public: | |||
204 | static LLString nameFromVAlign(LLFontGL::VAlign align); | 204 | static LLString nameFromVAlign(LLFontGL::VAlign align); |
205 | static LLFontGL::VAlign vAlignFromName(const LLString& name); | 205 | static LLFontGL::VAlign vAlignFromName(const LLString& name); |
206 | 206 | ||
207 | static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; } | ||
208 | |||
207 | protected: | 209 | protected: |
208 | struct embedded_data_t | 210 | struct embedded_data_t |
209 | { | 211 | { |
@@ -222,6 +224,7 @@ public: | |||
222 | static F32 sHorizDPI; | 224 | static F32 sHorizDPI; |
223 | static F32 sScaleX; | 225 | static F32 sScaleX; |
224 | static F32 sScaleY; | 226 | static F32 sScaleY; |
227 | static BOOL sDisplayFont ; | ||
225 | static LLString sAppDir; // For loading fonts | 228 | static LLString sAppDir; // For loading fonts |
226 | 229 | ||
227 | static LLFontGL* sMonospace; // medium | 230 | static LLFontGL* sMonospace; // medium |
@@ -246,7 +249,7 @@ public: | |||
246 | protected: | 249 | protected: |
247 | /*virtual*/ BOOL addChar(const llwchar wch); | 250 | /*virtual*/ BOOL addChar(const llwchar wch); |
248 | static LLString getFontPathLocal(); | 251 | static LLString getFontPathLocal(); |
249 | static LLString getFontPathSystem(); | 252 | static LLString getFontPathSystem(); |
250 | 253 | ||
251 | protected: | 254 | protected: |
252 | LLPointer<LLImageRaw> mRawImageGLp; | 255 | LLPointer<LLImageRaw> mRawImageGLp; |
diff --git a/linden/indra/llrender/llrendertarget.cpp b/linden/indra/llrender/llrendertarget.cpp index 974e0a2..d95c8aa 100644 --- a/linden/indra/llrender/llrendertarget.cpp +++ b/linden/indra/llrender/llrendertarget.cpp | |||
@@ -49,8 +49,9 @@ LLRenderTarget::~LLRenderTarget() | |||
49 | release(); | 49 | release(); |
50 | } | 50 | } |
51 | 51 | ||
52 | void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL force_fbo) | 52 | void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo) |
53 | { | 53 | { |
54 | stop_glerror(); | ||
54 | mResX = resx; | 55 | mResX = resx; |
55 | mResY = resy; | 56 | mResY = resy; |
56 | 57 | ||
@@ -79,32 +80,45 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 | |||
79 | 80 | ||
80 | stop_glerror(); | 81 | stop_glerror(); |
81 | 82 | ||
82 | if (sUseFBO || force_fbo) | 83 | if ((sUseFBO || use_fbo) && gGLManager.mHasFramebufferObject) |
83 | { | 84 | { |
85 | |||
84 | if (depth) | 86 | if (depth) |
85 | { | 87 | { |
86 | glGenRenderbuffersEXT(1, (GLuint *) &mDepth); | 88 | stop_glerror(); |
87 | glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth); | 89 | allocateDepth(); |
88 | glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,mResX,mResY); | 90 | stop_glerror(); |
89 | glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); | ||
90 | } | 91 | } |
91 | 92 | ||
92 | glGenFramebuffersEXT(1, (GLuint *) &mFBO); | 93 | glGenFramebuffersEXT(1, (GLuint *) &mFBO); |
94 | |||
93 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); | 95 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO); |
94 | 96 | ||
95 | if (mDepth) | 97 | if (mDepth) |
96 | { | 98 | { |
97 | glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, | 99 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0); |
98 | GL_RENDERBUFFER_EXT, mDepth); | 100 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0); |
101 | stop_glerror(); | ||
99 | } | 102 | } |
103 | |||
100 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, | 104 | glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, |
101 | mUsage, mTex, 0); | 105 | mUsage, mTex, 0); |
102 | 106 | stop_glerror(); | |
103 | 107 | ||
104 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | 108 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); |
109 | stop_glerror(); | ||
105 | } | 110 | } |
106 | } | 111 | } |
107 | 112 | ||
113 | void LLRenderTarget::allocateDepth() | ||
114 | { | ||
115 | glGenTextures(1, (GLuint *) &mDepth); | ||
116 | glBindTexture(mUsage, mDepth); | ||
117 | glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST); | ||
118 | glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST); | ||
119 | glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL); | ||
120 | } | ||
121 | |||
108 | void LLRenderTarget::release() | 122 | void LLRenderTarget::release() |
109 | { | 123 | { |
110 | if (mFBO) | 124 | if (mFBO) |
@@ -121,7 +135,7 @@ void LLRenderTarget::release() | |||
121 | 135 | ||
122 | if (mDepth) | 136 | if (mDepth) |
123 | { | 137 | { |
124 | glDeleteRenderbuffersEXT(1, (GLuint *) &mDepth); | 138 | glDeleteTextures(1, (GLuint *) &mDepth); |
125 | mDepth = 0; | 139 | mDepth = 0; |
126 | } | 140 | } |
127 | } | 141 | } |
@@ -141,7 +155,7 @@ void LLRenderTarget::clear() | |||
141 | U32 mask = GL_COLOR_BUFFER_BIT; | 155 | U32 mask = GL_COLOR_BUFFER_BIT; |
142 | if (mUseDepth) | 156 | if (mUseDepth) |
143 | { | 157 | { |
144 | mask |= GL_DEPTH_BUFFER_BIT; | 158 | mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; |
145 | } | 159 | } |
146 | if (mFBO) | 160 | if (mFBO) |
147 | { | 161 | { |
@@ -160,13 +174,34 @@ void LLRenderTarget::bindTexture() | |||
160 | glBindTexture(mUsage, mTex); | 174 | glBindTexture(mUsage, mTex); |
161 | } | 175 | } |
162 | 176 | ||
163 | void LLRenderTarget::flush() | 177 | void LLRenderTarget::bindDepth() |
178 | { | ||
179 | glBindTexture(mUsage, mDepth); | ||
180 | } | ||
181 | |||
182 | |||
183 | void LLRenderTarget::flush(BOOL fetch_depth) | ||
164 | { | 184 | { |
165 | gGL.flush(); | 185 | gGL.flush(); |
166 | if (!mFBO) | 186 | if (!mFBO) |
167 | { | 187 | { |
168 | bindTexture(); | 188 | bindTexture(); |
169 | glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); | 189 | glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY); |
190 | |||
191 | if (fetch_depth) | ||
192 | { | ||
193 | if (!mDepth) | ||
194 | { | ||
195 | allocateDepth(); | ||
196 | } | ||
197 | |||
198 | bindDepth(); | ||
199 | glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0); | ||
200 | } | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); | ||
170 | } | 205 | } |
171 | } | 206 | } |
172 | 207 | ||
diff --git a/linden/indra/llrender/llrendertarget.h b/linden/indra/llrender/llrendertarget.h index cc36146..918a604 100644 --- a/linden/indra/llrender/llrendertarget.h +++ b/linden/indra/llrender/llrendertarget.h | |||
@@ -37,7 +37,7 @@ | |||
37 | /* | 37 | /* |
38 | SAMPLE USAGE: | 38 | SAMPLE USAGE: |
39 | 39 | ||
40 | LLFBOTarget target; | 40 | LLRenderTarget target; |
41 | 41 | ||
42 | ... | 42 | ... |
43 | 43 | ||
@@ -46,7 +46,7 @@ | |||
46 | 46 | ||
47 | //render to contents of offscreen buffer | 47 | //render to contents of offscreen buffer |
48 | target.bindTarget(); | 48 | target.bindTarget(); |
49 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 49 | target.clear(); |
50 | ... <issue drawing commands> ... | 50 | ... <issue drawing commands> ... |
51 | target.flush(); | 51 | target.flush(); |
52 | 52 | ||
@@ -71,7 +71,10 @@ public: | |||
71 | //allocate resources for rendering | 71 | //allocate resources for rendering |
72 | //must be called before use | 72 | //must be called before use |
73 | //multiple calls will release previously allocated resources | 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 force_fbo = FALSE); | 74 | void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = TRUE); |
75 | |||
76 | //allocate a depth texture | ||
77 | void allocateDepth(); | ||
75 | 78 | ||
76 | //free any allocated resources | 79 | //free any allocated resources |
77 | //safe to call redundantly | 80 | //safe to call redundantly |
@@ -80,7 +83,7 @@ public: | |||
80 | //bind target for rendering | 83 | //bind target for rendering |
81 | //applies appropriate viewport | 84 | //applies appropriate viewport |
82 | void bindTarget(); | 85 | void bindTarget(); |
83 | 86 | ||
84 | //clear render targer, clears depth buffer if present, | 87 | //clear render targer, clears depth buffer if present, |
85 | //uses scissor rect if in copy-to-texture mode | 88 | //uses scissor rect if in copy-to-texture mode |
86 | void clear(); | 89 | void clear(); |
@@ -88,14 +91,25 @@ public: | |||
88 | //get applied viewport | 91 | //get applied viewport |
89 | void getViewport(S32* viewport); | 92 | void getViewport(S32* viewport); |
90 | 93 | ||
94 | //get X resolution | ||
95 | U32 getWidth() const { return mResX; } | ||
96 | |||
97 | //get Y resolution | ||
98 | U32 getHeight() const { return mResY; } | ||
99 | |||
91 | //bind results of render for sampling | 100 | //bind results of render for sampling |
92 | void bindTexture(); | 101 | void bindTexture(); |
93 | 102 | ||
103 | //bind results of render for sampling depth buffer | ||
104 | void bindDepth(); | ||
105 | |||
94 | //flush rendering operations | 106 | //flush rendering operations |
95 | //must be called when rendering is complete | 107 | //must be called when rendering is complete |
96 | //should be used 1:1 with bindTarget | 108 | //should be used 1:1 with bindTarget |
97 | // call bindTarget once, do all your rendering, call flush once | 109 | // call bindTarget once, do all your rendering, call flush once |
98 | void flush(); | 110 | // if fetch_depth is TRUE, every effort will be made to copy the depth buffer into |
111 | // the current depth texture. A depth texture will be allocated if needed. | ||
112 | void flush(BOOL fetch_depth = FALSE); | ||
99 | 113 | ||
100 | //Returns TRUE if target is ready to be rendered into. | 114 | //Returns TRUE if target is ready to be rendered into. |
101 | //That is, if the target has been allocated with at least | 115 | //That is, if the target has been allocated with at least |
@@ -108,8 +122,11 @@ private: | |||
108 | U32 mTex; | 122 | U32 mTex; |
109 | U32 mFBO; | 123 | U32 mFBO; |
110 | U32 mDepth; | 124 | U32 mDepth; |
125 | U32 mStencil; | ||
111 | BOOL mUseDepth; | 126 | BOOL mUseDepth; |
127 | BOOL mRenderDepth; | ||
112 | U32 mUsage; | 128 | U32 mUsage; |
129 | |||
113 | }; | 130 | }; |
114 | 131 | ||
115 | #endif | 132 | #endif |