Ejemplo n.º 1
0
void RasterNode::blt(const glm::mat4& transform, const glm::vec2& destSize)
{
    GLContext* pContext = GLContext::getCurrent();
    FRect destRect;
    
    StandardShaderPtr pShader = pContext->getStandardShader();
    float opacity = getEffectiveOpacity();
    pContext->setBlendColor(glm::vec4(1.0f, 1.0f, 1.0f, opacity));
    pShader->setAlpha(opacity);
    if (m_pFXNode) {
        pContext->setBlendMode(m_BlendMode, true);
        m_pFXNode->getTex()->activate(GL_TEXTURE0);
        pShader->setColorModel(0);
        pShader->disableColorspaceMatrix();
        pShader->setGamma(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
        pShader->setPremultipliedAlpha(true);
        pShader->setMask(false);

        FRect relDestRect = m_pFXNode->getRelDestRect();
        destRect = FRect(relDestRect.tl.x*destSize.x, relDestRect.tl.y*destSize.y,
                relDestRect.br.x*destSize.x, relDestRect.br.y*destSize.y);
    } else {
        m_pSurface->activate(getMediaSize());
        pContext->setBlendMode(m_BlendMode, m_pSurface->isPremultipliedAlpha());
        destRect = FRect(glm::vec2(0,0), destSize);
    }
    glm::vec3 pos(destRect.tl.x, destRect.tl.y, 0);
    glm::vec3 scaleVec(destRect.size().x, destRect.size().y, 1);
    glm::mat4 localTransform = glm::translate(transform, pos);
    localTransform = glm::scale(localTransform, scaleVec);
    pShader->setTransform(localTransform);
    pShader->activate();
    m_pSubVA->draw();
}
Ejemplo n.º 2
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);
}
Ejemplo n.º 3
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();
}
Ejemplo n.º 4
0
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();
    }
}