summaryrefslogtreecommitdiff
path: root/src/engine/rendertarget.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/rendertarget.h')
-rw-r--r--src/engine/rendertarget.h93
1 files changed, 10 insertions, 83 deletions
diff --git a/src/engine/rendertarget.h b/src/engine/rendertarget.h
index 3c93f18..f1e13e6 100644
--- a/src/engine/rendertarget.h
+++ b/src/engine/rendertarget.h
@@ -121,7 +121,7 @@ struct rendertarget
while(!depthfmt && depthfmts[++find]);
if(!depthfmt) depthfmt = depthfmts[find];
}
-
+
glBindFramebuffer_(GL_FRAMEBUFFER, 0);
texw = w;
@@ -152,8 +152,8 @@ struct rendertarget
bool checkblurtiles(float x1, float y1, float x2, float y2, float blurmargin = 0)
{
float blurerror = 2.0f*float(2*blursize + blurmargin);
- if(x2+blurerror/vieww < scissorx1 || y2+blurerror/viewh < scissory1 ||
- x1-blurerror/vieww > scissorx2 || y1-blurerror/viewh > scissory2)
+ if(x2+blurerror/vieww < scissorx1 || y2+blurerror/viewh < scissory1 ||
+ x1-blurerror/vieww > scissorx2 || y1-blurerror/viewh > scissory2)
return false;
if(!blurtile) return true;
@@ -247,7 +247,7 @@ struct rendertarget
}
if(scissor) glDisable(GL_SCISSOR_TEST);
-
+
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
}
@@ -259,7 +259,7 @@ struct rendertarget
virtual bool shouldrender() { return true; }
virtual void doblur(int blursize, float blursigma, int blurysize)
- {
+ {
int sx, sy, sw, sh;
bool scissoring = rtscissor && scissorblur(sx, sy, sw, sh) && sw > 0 && sh > 0;
if(!scissoring) { sx = sy = 0; sw = vieww; sh = viewh; }
@@ -268,7 +268,7 @@ struct rendertarget
virtual bool scissorrender(int &x, int &y, int &w, int &h)
{
- if(scissorx1 >= scissorx2 || scissory1 >= scissory2)
+ if(scissorx1 >= scissorx2 || scissory1 >= scissory2)
{
if(vieww < texw || viewh < texh)
{
@@ -323,19 +323,19 @@ struct rendertarget
vieww = w;
viewh = h;
if(w!=texw || h!=texh || (swaptexs() && !rtsharefb ? !blurfb : blurfb)) cleanup();
-
+
if(!filter())
{
if(blurtex) cleanupblur();
blursize = blurysize = 0;
}
-
+
if(!rendertex) setup(w, h);
-
+
scissorx2 = scissory2 = -1;
scissorx1 = scissory1 = 1;
memset(blurtiles, 0, sizeof(blurtiles));
-
+
if(!shouldrender()) return;
if(blursize && !blurtex) setupblur();
@@ -387,78 +387,5 @@ struct rendertarget
glBindFramebuffer_(GL_FRAMEBUFFER, 0);
glViewport(0, 0, screenw, screenh);
}
-
- virtual void dodebug(int w, int h) {}
- virtual bool flipdebug() const { return true; }
-
- void debugscissor(int w, int h, bool lines = false)
- {
- if(!rtscissor || scissorx1 >= scissorx2 || scissory1 >= scissory2) return;
- int sx = int(0.5f*(scissorx1 + 1)*w),
- sy = int(0.5f*(scissory1 + 1)*h),
- sw = int(0.5f*(scissorx2 - scissorx1)*w),
- sh = int(0.5f*(scissory2 - scissory1)*h);
- if(flipdebug()) { sy = h - sy; sh = -sh; }
- gle::defvertex(2);
- gle::begin(lines ? GL_LINE_LOOP : GL_TRIANGLE_STRIP);
- gle::attribf(sx, sy);
- gle::attribf(sx + sw, sy);
- if(lines) gle::attribf(sx + sw, sy + sh);
- gle::attribf(sx, sy + sh);
- if(!lines) gle::attribf(sx + sw, sy + sh);
- gle::end();
- }
-
- void debugblurtiles(int w, int h, bool lines = false)
- {
- if(!blurtile) return;
- float vxsz = float(w)/BLURTILES, vysz = float(h)/BLURTILES;
- gle::defvertex(2);
- loop(y, BLURTILES+1)
- {
- uint mask = blurtiles[y];
- int x = 0;
- while(mask)
- {
- while(!(mask&0xFF)) { mask >>= 8; x += 8; }
- while(!(mask&1)) { mask >>= 1; x++; }
- int xstart = x;
- do { mask >>= 1; x++; } while(mask&1);
- uint strip = (BLURTILEMASK>>(BLURTILES - x)) & (BLURTILEMASK<<xstart);
- int yend = y;
- do { blurtiles[yend] &= ~strip; yend++; } while((blurtiles[yend] & strip) == strip);
- float vx = xstart*vxsz,
- vy = y*vysz,
- vw = (x-xstart)*vxsz,
- vh = (yend-y)*vysz;
- if(flipdebug()) { vy = h - vy; vh = -vh; }
- loopi(lines ? 1 : 2)
- {
- if(!lines) gle::colorf(1, 1, i ? 1.0f : 0.5f);
- gle::begin(lines || i ? GL_LINE_LOOP : GL_TRIANGLE_STRIP);
- gle::attribf(vx, vy);
- gle::attribf(vx+vw, vy);
- if(lines || i) gle::attribf(vx+vw, vy+vh);
- gle::attribf(vx, vy+vh);
- if(!lines && !i) gle::attribf(vx+vw, vy+vh);
- gle::end();
- }
- }
- }
- }
-
- void debug()
- {
- if(!rendertex) return;
- int w = min(screenw, screenh)/2, h = (w*screenh)/screenw;
- hudshader->set();
- gle::colorf(1, 1, 1);
- glBindTexture(GL_TEXTURE_2D, rendertex);
- float tx1 = 0, tx2 = 1, ty1 = 0, ty2 = 1;
- if(flipdebug()) swap(ty1, ty2);
- hudquad(0, 0, w, h, tx1, ty1, tx2-tx1, ty2-ty1);
- hudnotextureshader->set();
- dodebug(w, h);
- }
};