void Canvas::clip(const glm::mat4& transform, VertexArrayPtr pVA, GLenum stencilOp) { // Disable drawing to color buffer glColorMask(0, 0, 0, 0); // Enable drawing to stencil buffer glStencilMask(~0); // Draw clip rectangle into stencil buffer glStencilFunc(GL_ALWAYS, 0, 0); glStencilOp(stencilOp, stencilOp, stencilOp); StandardShaderPtr pShader = GLContext::getCurrent()->getStandardShader(); pShader->setUntextured(); pShader->activate(); glLoadMatrixf(glm::value_ptr(transform)); pVA->draw(); // Set stencil test to only let glStencilFunc(GL_LEQUAL, m_ClipLevel, ~0); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // Disable drawing to stencil buffer glStencilMask(0); // Enable drawing to color buffer glColorMask(~0, ~0, ~0, ~0); }
void Canvas::clip(const glm::mat4& transform, SubVertexArray& va, GLenum stencilOp) { // Disable drawing to color buffer glColorMask(0, 0, 0, 0); // Enable drawing to stencil buffer glStencilMask(~0); // Draw clip rectangle into stencil buffer glStencilFunc(GL_ALWAYS, 0, 0); glStencilOp(stencilOp, stencilOp, stencilOp); StandardShaderPtr pShader = GLContext::getMain()->getStandardShader(); pShader->setUntextured(); pShader->setTransform(transform); pShader->activate(); va.draw(); // Set stencil test to only let glStencilFunc(GL_LEQUAL, m_ClipLevel, ~0); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // Disable drawing to stencil buffer glStencilMask(0); // Enable drawing to color buffer glColorMask(~0, ~0, ~0, ~0); }
void Shape::draw(const glm::mat4& transform, float opacity) { bool bIsTextured = isTextured(); GLContext* pContext = GLContext::getCurrent(); StandardShaderPtr pShader = pContext->getStandardShader(); pShader->setTransform(transform); pShader->setAlpha(opacity); if (bIsTextured) { m_pSurface->activate(); } else { pShader->setUntextured(); pShader->activate(); } m_SubVA.draw(); }
void Canvas::renderOutlines(const glm::mat4& transform) { GLContext* pContext = GLContext::getMain(); VertexArrayPtr pVA(new VertexArray); pContext->setBlendMode(GLContext::BLEND_BLEND, false); m_pRootNode->renderOutlines(pVA, Pixel32(0,0,0,0)); StandardShaderPtr pShader = pContext->getStandardShader(); pShader->setTransform(transform); pShader->setUntextured(); pShader->setAlpha(0.5f); pShader->activate(); if (pVA->getNumVerts() != 0) { pVA->update(); pVA->draw(); } }
void Canvas::renderOutlines() { GLContext* pContext = GLContext::getCurrent(); VertexArrayPtr pVA(new VertexArray); pContext->setBlendMode(GLContext::BLEND_BLEND, false); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(glm::value_ptr(glm::mat4(1.0))); m_pRootNode->renderOutlines(pVA, Pixel32(0,0,0,0)); StandardShaderPtr pShader = GLContext::getCurrent()->getStandardShader(); pShader->setUntextured(); pShader->activate(); if (pVA->getCurVert() != 0) { pVA->update(); pContext->enableGLColorArray(true); pVA->draw(); } }