summaryrefslogtreecommitdiff
path: root/indra/llrender
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2008-03-25 22:50:26 +0000
committerSteven Bennetts <steve@lindenlab.com>2008-03-25 22:50:26 +0000
commit6fcf38217e8772b2f90c7a8e7ce6b60071f6d20c (patch)
treea8e35fe195cc86c616daf9d8a21571e04bc2bc35 /indra/llrender
parent11a3589665aae1a2423e258e40eba45c117627d5 (diff)
merge release@82858 maint-render-2-merge@83010 -> release
QAR-389
Diffstat (limited to 'indra/llrender')
-rw-r--r--indra/llrender/llfontgl.cpp6
-rw-r--r--indra/llrender/llfontgl.h5
-rw-r--r--indra/llrender/llrendertarget.cpp64
-rw-r--r--indra/llrender/llrendertarget.h27
4 files changed, 81 insertions, 21 deletions
diff --git a/indra/llrender/llfontgl.cpp b/indra/llrender/llfontgl.cpp
index 2e767ebb9c..df9dca3af5 100644
--- a/indra/llrender/llfontgl.cpp
+++ b/indra/llrender/llfontgl.cpp
@@ -47,6 +47,7 @@ F32 LLFontGL::sVertDPI = 96.f;
F32 LLFontGL::sHorizDPI = 96.f;
F32 LLFontGL::sScaleX = 1.f;
F32 LLFontGL::sScaleY = 1.f;
+BOOL LLFontGL::sDisplayFont = TRUE ;
LLString LLFontGL::sAppDir;
LLFontGL* LLFontGL::sMonospace = NULL;
@@ -557,6 +558,11 @@ S32 LLFontGL::render(const LLWString &wstr,
BOOL use_embedded,
BOOL use_ellipses) const
{
+ if(!sDisplayFont) //do not display texts
+ {
+ return wstr.length() ;
+ }
+
LLGLEnable tex(GL_TEXTURE_2D);
if (wstr.empty())
diff --git a/indra/llrender/llfontgl.h b/indra/llrender/llfontgl.h
index 393d26c685..b5f018e8f7 100644
--- a/indra/llrender/llfontgl.h
+++ b/indra/llrender/llfontgl.h
@@ -202,6 +202,8 @@ public:
static LLString nameFromVAlign(LLFontGL::VAlign align);
static LLFontGL::VAlign vAlignFromName(const LLString& name);
+ static void setFontDisplay(BOOL flag) { sDisplayFont = flag ; }
+
protected:
struct embedded_data_t
{
@@ -220,6 +222,7 @@ public:
static F32 sHorizDPI;
static F32 sScaleX;
static F32 sScaleY;
+ static BOOL sDisplayFont ;
static LLString sAppDir; // For loading fonts
static LLFontGL* sMonospace; // medium
@@ -244,7 +247,7 @@ public:
protected:
/*virtual*/ BOOL addChar(const llwchar wch);
static LLString getFontPathLocal();
- static LLString getFontPathSystem();
+ static LLString getFontPathSystem();
protected:
LLPointer<LLImageRaw> mRawImageGLp;
diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp
index c082b93164..593a5a18e5 100644
--- a/indra/llrender/llrendertarget.cpp
+++ b/indra/llrender/llrendertarget.cpp
@@ -49,8 +49,9 @@ LLRenderTarget::~LLRenderTarget()
release();
}
-void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL force_fbo)
+void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage, BOOL use_fbo)
{
+ stop_glerror();
mResX = resx;
mResY = resy;
@@ -79,32 +80,44 @@ void LLRenderTarget::allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32
stop_glerror();
- if (sUseFBO || force_fbo)
+ if (depth)
{
- if (depth)
- {
- glGenRenderbuffersEXT(1, (GLuint *) &mDepth);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, mDepth);
- glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DEPTH_COMPONENT,mResX,mResY);
- glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
- }
+ stop_glerror();
+ allocateDepth();
+ stop_glerror();
+ }
+ if ((sUseFBO && use_fbo) && gGLManager.mHasFramebufferObject)
+ {
glGenFramebuffersEXT(1, (GLuint *) &mFBO);
+
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, mFBO);
if (mDepth)
{
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
- GL_RENDERBUFFER_EXT, mDepth);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, mUsage, mDepth, 0);
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, mUsage, mDepth, 0);
+ stop_glerror();
}
+
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
mUsage, mTex, 0);
-
+ stop_glerror();
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ stop_glerror();
}
}
+void LLRenderTarget::allocateDepth()
+{
+ glGenTextures(1, (GLuint *) &mDepth);
+ glBindTexture(mUsage, mDepth);
+ glTexParameteri(mUsage, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(mUsage, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, mResX, mResY, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, NULL);
+}
+
void LLRenderTarget::release()
{
if (mFBO)
@@ -121,7 +134,7 @@ void LLRenderTarget::release()
if (mDepth)
{
- glDeleteRenderbuffersEXT(1, (GLuint *) &mDepth);
+ glDeleteTextures(1, (GLuint *) &mDepth);
mDepth = 0;
}
}
@@ -141,7 +154,7 @@ void LLRenderTarget::clear()
U32 mask = GL_COLOR_BUFFER_BIT;
if (mUseDepth)
{
- mask |= GL_DEPTH_BUFFER_BIT;
+ mask |= GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
}
if (mFBO)
{
@@ -160,13 +173,34 @@ void LLRenderTarget::bindTexture()
glBindTexture(mUsage, mTex);
}
-void LLRenderTarget::flush()
+void LLRenderTarget::bindDepth()
+{
+ glBindTexture(mUsage, mDepth);
+}
+
+
+void LLRenderTarget::flush(BOOL fetch_depth)
{
gGL.flush();
if (!mFBO)
{
bindTexture();
glCopyTexSubImage2D(mUsage, 0, 0, 0, 0, 0, mResX, mResY);
+
+ if (fetch_depth)
+ {
+ if (!mDepth)
+ {
+ allocateDepth();
+ }
+
+ bindDepth();
+ glCopyTexImage2D(mUsage, 0, GL_DEPTH24_STENCIL8_EXT, 0, 0, mResX, mResY, 0);
+ }
+ }
+ else
+ {
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
}
diff --git a/indra/llrender/llrendertarget.h b/indra/llrender/llrendertarget.h
index 0c0eab2b10..7f9c611c69 100644
--- a/indra/llrender/llrendertarget.h
+++ b/indra/llrender/llrendertarget.h
@@ -37,7 +37,7 @@
/*
SAMPLE USAGE:
- LLFBOTarget target;
+ LLRenderTarget target;
...
@@ -46,7 +46,7 @@
//render to contents of offscreen buffer
target.bindTarget();
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ target.clear();
... <issue drawing commands> ...
target.flush();
@@ -71,7 +71,10 @@ public:
//allocate resources for rendering
//must be called before use
//multiple calls will release previously allocated resources
- void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL force_fbo = FALSE);
+ void allocate(U32 resx, U32 resy, U32 color_fmt, BOOL depth, U32 usage = GL_TEXTURE_2D, BOOL use_fbo = TRUE);
+
+ //allocate a depth texture
+ void allocateDepth();
//free any allocated resources
//safe to call redundantly
@@ -80,7 +83,7 @@ public:
//bind target for rendering
//applies appropriate viewport
void bindTarget();
-
+
//clear render targer, clears depth buffer if present,
//uses scissor rect if in copy-to-texture mode
void clear();
@@ -88,14 +91,25 @@ public:
//get applied viewport
void getViewport(S32* viewport);
+ //get X resolution
+ U32 getWidth() const { return mResX; }
+
+ //get Y resolution
+ U32 getHeight() const { return mResY; }
+
//bind results of render for sampling
void bindTexture();
+ //bind results of render for sampling depth buffer
+ void bindDepth();
+
//flush rendering operations
//must be called when rendering is complete
//should be used 1:1 with bindTarget
// call bindTarget once, do all your rendering, call flush once
- void flush();
+ // 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);
//Returns TRUE if target is ready to be rendered into.
//That is, if the target has been allocated with at least
@@ -108,8 +122,11 @@ private:
U32 mTex;
U32 mFBO;
U32 mDepth;
+ U32 mStencil;
BOOL mUseDepth;
+ BOOL mRenderDepth;
U32 mUsage;
+
};
#endif