コード例 #1
0
ファイル: TexShader.cpp プロジェクト: 13W/phantomjs
void TexShader::use(const AffineTransform& transform, const AffineTransform& texTransform, int sampler, float alpha)
{
    m_context->useProgram(m_program);
    float matrix[9];
    affineTo3x3(transform, matrix);
    m_context->uniformMatrix3fv(m_matrixLocation, false /*transpose*/, matrix, 1 /*count*/);

    float texMatrix[9];
    affineTo3x3(texTransform, texMatrix);
    m_context->uniformMatrix3fv(m_texMatrixLocation, false /*transpose*/, texMatrix, 1 /*count*/);

    m_context->uniform1i(m_samplerLocation, sampler);
    m_context->uniform1f(m_alphaLocation, alpha);

    m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0);

    m_context->enableVertexAttribArray(m_positionLocation);

}
コード例 #2
0
void ConvolutionShader::use(const AffineTransform& transform, const AffineTransform& texTransform, const float* kernel, int kernelWidth, float imageIncrement[2])
{
    m_context->useProgram(m_program);
    float matrix[9];
    affineTo3x3(transform, matrix);
    m_context->uniformMatrix3fv(m_matrixLocation, false /*transpose*/, matrix, 1 /*count*/);

    float texMatrix[9];
    affineTo3x3(texTransform, texMatrix);
    m_context->uniformMatrix3fv(m_texMatrixLocation, false /*transpose*/, texMatrix, 1 /*count*/);

    m_context->uniform2f(m_imageIncrementLocation, imageIncrement[0], imageIncrement[1]);

    // For now, we always use texture unit 0. If that ever changes, we should
    // expose this parameter to the caller.
    m_context->uniform1i(m_imageLocation, 0);
    if (kernelWidth > m_kernelWidth)
        kernelWidth = m_kernelWidth;
    m_context->uniform1fv(m_kernelLocation, const_cast<float*>(kernel), kernelWidth);

    m_context->vertexAttribPointer(m_positionLocation, 2, GraphicsContext3D::FLOAT, false, 0, 0);

    m_context->enableVertexAttribArray(m_positionLocation);
}