mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 20:14:37 +00:00
gl_engine: append stencil attachment in GLRenderTarget
Plans to use stencil to test support for path clipping and complex path rendering When the tessellation algorithm cannot handle it.
This commit is contained in:
parent
c9ee5d274d
commit
fc7ba88585
3 changed files with 18 additions and 7 deletions
|
@ -32,8 +32,8 @@ GlRenderTarget::~GlRenderTarget()
|
|||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, 0));
|
||||
GL_CHECK(glDeleteFramebuffers(1, &mFbo));
|
||||
|
||||
if (mColorTex == 0) return;
|
||||
GL_CHECK(glDeleteTextures(1, &mColorTex));
|
||||
if (mColorTex != 0) GL_CHECK(glDeleteTextures(1, &mColorTex));
|
||||
if (mStencilBuffer != 0) GL_CHECK(glDeleteRenderbuffers(1, &mStencilBuffer));
|
||||
}
|
||||
|
||||
void GlRenderTarget::init(GLint resolveId)
|
||||
|
@ -56,7 +56,16 @@ void GlRenderTarget::init(GLint resolveId)
|
|||
|
||||
GL_CHECK(glBindTexture(GL_TEXTURE_2D, 0));
|
||||
|
||||
GL_CHECK(glGenRenderbuffers(1, &mStencilBuffer));
|
||||
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, mStencilBuffer));
|
||||
|
||||
GL_CHECK(glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, mWidth, mHeight));
|
||||
|
||||
GL_CHECK(glBindRenderbuffer(GL_RENDERBUFFER, 0));
|
||||
|
||||
GL_CHECK(glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, mColorTex, 0));
|
||||
GL_CHECK(glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, mStencilBuffer));
|
||||
|
||||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, resolveId));
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ private:
|
|||
uint32_t mHeight = 0;
|
||||
GLuint mFbo = 0;
|
||||
GLuint mColorTex = 0;
|
||||
GLuint mStencilBuffer = 0;
|
||||
};
|
||||
|
||||
class GlRenderPass
|
||||
|
|
|
@ -111,15 +111,16 @@ void GlComposeTask::run()
|
|||
GL_CHECK(glBindFramebuffer(GL_FRAMEBUFFER, getSelfFbo()));
|
||||
|
||||
// clear this fbo
|
||||
GLenum color_buffer = GL_COLOR_ATTACHMENT0;
|
||||
const float transparent[] = {0.f, 0.f, 0.f, 0.f};
|
||||
|
||||
GL_CHECK(glDrawBuffers(1, &color_buffer));
|
||||
GL_CHECK(glClearBufferfv(GL_COLOR, 0, transparent));
|
||||
GL_CHECK(glClearColor(0, 0, 0, 0));
|
||||
GL_CHECK(glClearStencil(0));
|
||||
GL_CHECK(glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT));
|
||||
|
||||
for(uint32_t i = 0; i < mTasks.count; i++) {
|
||||
mTasks[i]->run();
|
||||
}
|
||||
|
||||
GLenum stencil_attachment = GL_STENCIL_ATTACHMENT;
|
||||
GL_CHECK(glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &stencil_attachment));
|
||||
}
|
||||
|
||||
GlBlitTask::GlBlitTask(GlProgram* program, GLuint target, GLuint compose, Array<GlRenderTask*>&& tasks)
|
||||
|
|
Loading…
Add table
Reference in a new issue