Esempio 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();
}
Esempio n. 2
0
void AreaNode::setViewport(float x, float y, float width, float height)
{
    glm::vec2 oldSize = getRelViewport().size();
    if (x == -32767) {
        x = getRelViewport().tl.x;
    }
    if (y == -32767) {
        y = getRelViewport().tl.y;
    }
    glm::vec2 mediaSize = glm::vec2(getMediaSize());
    if (width == -32767) {
        if (m_UserSize.x == 0.0) {
            width = mediaSize.x;
        } else {
            width = m_UserSize.x;
        } 
    }
    if (height == -32767) {
        if (m_UserSize.y == 0.0) {
            height = mediaSize.y;
        } else {
            height = m_UserSize.y;
        } 
    }
    if (width < 0 || height < 0) {
        throw Exception(AVG_ERR_OUT_OF_RANGE, "Negative size for a node.");
    }
    m_RelViewport = FRect(x, y, x+width, y+height);
    if (oldSize != m_RelViewport.size()) {
        notifySubscribers("SIZE_CHANGED", m_RelViewport.size());
    }
    m_bTransformChanged = true;
}
Esempio n. 3
0
void RasterNode::renderFX()
{
    if (m_bFXDirty || m_pSurface->isDirty() || m_pFXNode->isDirty()) {
        ScopeTimer Timer(FXProfilingZone);
        GLContext* pContext = GLContext::getCurrent();
        StandardShader::get()->setAlpha(1.0f);
        m_pSurface->activate(getMediaSize());

        m_pFBO->activate();
        clearGLBuffers(GL_COLOR_BUFFER_BIT, false);

        bool bPremultipliedAlpha = m_pSurface->isPremultipliedAlpha();
        if (bPremultipliedAlpha) {
            glproc::BlendColor(1.0f, 1.0f, 1.0f, 1.0f);
        }
        pContext->setBlendMode(GLContext::BLEND_BLEND, bPremultipliedAlpha);
        m_pImagingProjection->setColor(m_Color);
        m_pImagingProjection->draw(StandardShader::get()->getShader());
/*
        static int i=0;
        stringstream ss;
        ss << "node" << i << ".png";
        BitmapPtr pBmp = m_pFBO->getImage(0);
        pBmp->save(ss.str());
*/  
        m_pFXNode->apply(m_pFBO->getTex()->getCurTex());
        
/*        
        stringstream ss1;
        ss1 << "nodefx" << i << ".png";
        i++;
        m_pFXNode->getImage()->save(ss1.str());
*/
    }
}
Esempio n. 4
0
void AreaNode::setViewport(float x, float y, float width, float height)
{
    if (x == -32767) {
        x = getRelViewport().tl.x;
    }
    if (y == -32767) {
        y = getRelViewport().tl.y;
    }
    glm::vec2 mediaSize = glm::vec2(getMediaSize());
    if (width == -32767) {
        if (m_UserSize.x == 0.0) {
            width = mediaSize.x;
        } else {
            width = m_UserSize.x;
        } 
    }
    if (height == -32767) {
        if (m_UserSize.y == 0.0) {
            height = mediaSize.y;
        } else {
            height = m_UserSize.y;
        } 
    }
    if (width < 0 || height < 0) {
        throw Exception(AVG_ERR_OUT_OF_RANGE, "Negative size for a node.");
    }
    m_RelViewport = FRect(x, y, x+width, y+height);
}
Esempio n. 5
0
void LLViewerMediaImpl::scaleMouse(S32 *mouse_x, S32 *mouse_y)
{
#if 0
	S32 media_width, media_height;
	S32 texture_width, texture_height;
	getMediaSize( &media_width, &media_height );
	getTextureSize( &texture_width, &texture_height );
	S32 y_delta = texture_height - media_height;

	*mouse_y -= y_delta;
#endif
}
Esempio n. 6
0
void RasterNode::calcMaskCoords()
{
    glm::vec2 maskSize;
    glm::vec2 mediaSize = glm::vec2(getMediaSize());
    if (m_MaskSize == glm::vec2(0,0)) {
        maskSize = glm::vec2(1,1);
    } else {
        maskSize = glm::vec2(m_MaskSize.x/mediaSize.x, m_MaskSize.y/mediaSize.y);
    }
    glm::vec2 maskPos = glm::vec2(m_MaskPos.x/mediaSize.x, m_MaskPos.y/mediaSize.y);
    m_pSurface->setMaskCoords(maskPos, maskSize);
}
Esempio n. 7
0
void AreaNode::connectDisplay()
{
    IntPoint MediaSize = getMediaSize();
    if (m_UserSize.x == 0.0) {
        m_RelViewport.setWidth(float(MediaSize.x));
    } else {
        m_RelViewport.setWidth(float(m_UserSize.x));
    }
    if (m_UserSize.y == 0.0) {
        m_RelViewport.setHeight(float(MediaSize.y));
    } else {
        m_RelViewport.setHeight(float(m_UserSize.y));
    }
    Node::connectDisplay();
}
Esempio n. 8
0
void AreaNode::connectDisplay()
{
    IntPoint MediaSize = getMediaSize();
    if (m_UserSize.x == 0.0) {
        m_RelViewport.setWidth(float(MediaSize.x));
    } else {
        m_RelViewport.setWidth(float(m_UserSize.x));
    }
    if (m_UserSize.y == 0.0) {
        m_RelViewport.setHeight(float(MediaSize.y));
    } else {
        m_RelViewport.setHeight(float(m_UserSize.y));
    }
    if (m_UserSize.x == 0.0 || m_UserSize.y == 0) {
        notifySubscribers("SIZE_CHANGED", m_RelViewport.size());
    }
    m_bTransformChanged = true;
    Node::connectDisplay();
}
Esempio n. 9
0
void CameraNode::open()
{
    m_pCamera->startCapture();
    setViewport(-32767, -32767, -32767, -32767);
    PixelFormat pf = getPixelFormat();
    IntPoint size = getMediaSize();
    bool bMipmap = getMaterial().getUseMipmaps();
    m_pTex = GLTexturePtr(new GLTexture(size, pf, bMipmap));
    m_pTex->enableStreaming();
    getSurface()->create(pf, m_pTex);

    BitmapPtr pBmp = m_pTex->lockStreamingBmp();
    if (pf == B8G8R8X8 || pf == B8G8R8A8) {
        FilterFill<Pixel32> Filter(Pixel32(0,0,0,255));
        Filter.applyInPlace(pBmp);
    } else if (pf == I8) {
        FilterFill<Pixel8> Filter(0);
        Filter.applyInPlace(pBmp);
    } 
    m_pTex->unlockStreamingBmp(true);
    setupFX(true);
}