improve clipping performance

This commit is contained in:
Eduardo Bart 2012-04-04 12:19:17 -03:00
parent 8b184d3ce8
commit 034fce9147
3 changed files with 13 additions and 6 deletions

View File

@ -135,7 +135,7 @@ void Graphics::resize(const Size& size)
void Graphics::beginRender()
{
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
}
void Graphics::endRender()
@ -154,10 +154,17 @@ void Graphics::endRender()
void Graphics::beginClipping(const Rect& clipRect)
{
static uint8 depth = 0;
depth++;
if(depth == 0) {
glClear(GL_STENCIL_BUFFER_BIT);
depth = 1;
}
// setup stencil buffer for writing
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1);
glStencilFunc(GL_ALWAYS, depth, 1);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
// draw the clipping area into the stencil buffer
@ -166,7 +173,7 @@ void Graphics::beginClipping(const Rect& clipRect)
// set stencil buffer for clipping
glColorMask(1, 1, 1, 1);
glStencilFunc(GL_EQUAL, 1, 1);
glStencilFunc(GL_EQUAL, depth, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
}

View File

@ -310,7 +310,7 @@ void WIN32Window::internalChooseGLVisual()
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
1, // 1Bit Stencil Buffer
8, // 8Bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved

View File

@ -369,7 +369,7 @@ void X11Window::internalChooseGLVisual()
GLX_USE_GL,
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_STENCIL_SIZE, 1,
GLX_STENCIL_SIZE, 8,
/*
GLX_ACCUM_RED_SIZE, 8,
GLX_ACCUM_GREEN_SIZE, 8,