Ignore:
Timestamp:
Apr 21, 2012, 6:58:33 PM (9 years ago)
Author:
sam
Message:

gpu: add methods to send mat2 and mat3 matrices to the shader.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gpu/shader.cpp

    r1241 r1259  
    393393    if (uni.vert)
    394394        cgGLSetParameter4f((CGparameter)uni.vert, v.x, v.y, v.z, v.w);
     395#endif
     396}
     397
     398void Shader::SetUniform(ShaderUniform const &uni, mat2 const &m)
     399{
     400#if defined USE_D3D9 || defined _XBOX
     401    if (uni.flags & 1)
     402        g_d3ddevice->SetPixelShaderConstantF((UINT)uni.frag, &m[0][0], 1);
     403    if (uni.flags & 2)
     404        g_d3ddevice->SetVertexShaderConstantF((UINT)uni.vert, &m[0][0], 1);
     405#elif !defined __CELLOS_LV2__
     406    glUniformMatrix2fv(uni.frag, 1, GL_FALSE, &m[0][0]);
     407#else
     408    /* Not implemented */
     409    Abort();
     410#endif
     411}
     412
     413void Shader::SetUniform(ShaderUniform const &uni, mat3 const &m)
     414{
     415#if defined USE_D3D9 || defined _XBOX
     416    /* FIXME: does this work at all? */
     417    if (uni.flags & 1)
     418        g_d3ddevice->SetPixelShaderConstantF((UINT)uni.frag, &m[0][0], 3);
     419    if (uni.flags & 2)
     420        g_d3ddevice->SetVertexShaderConstantF((UINT)uni.vert, &m[0][0], 3);
     421#elif !defined __CELLOS_LV2__
     422    glUniformMatrix3fv(uni.frag, 1, GL_FALSE, &m[0][0]);
     423#else
     424    /* FIXME: not implemented */
     425    Abort();
    395426#endif
    396427}
Note: See TracChangeset for help on using the changeset viewer.