Changeset 1289


Ignore:
Timestamp:
Apr 24, 2012, 8:17:43 PM (11 years ago)
Author:
sam
Message:

gpu: implement a few CG calls.

File:
1 edited

Legend:

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

    r1265 r1289  
    295295    glUniform1i(uni.frag, i);
    296296#else
    297     /* FIXME: does this exist at all? */
    298     //cgGLSetParameter1i((CGparameter)uni.frag, i);
     297    /* FIXME: does this exist at all? cgGLSetParameter1i doesn't. */
    299298#endif
    300299}
     
    355354    SetUniform(uni, vec4(v, 0, 0));
    356355#elif !defined __CELLOS_LV2__
    357     glUniform2f(uni.frag, v.x, v.y);
     356    glUniform2fv(uni.frag, 1, &v[0]);
    358357#else
    359358    if (uni.frag)
    360         cgGLSetParameter2f((CGparameter)uni.frag, v.x, v.y);
     359        cgGLSetParameter2fv((CGparameter)uni.frag, &v[0]);
    361360    if (uni.vert)
    362         cgGLSetParameter2f((CGparameter)uni.vert, v.x, v.y);
     361        cgGLSetParameter2fv((CGparameter)uni.vert, &v[0]);
    363362#endif
    364363}
     
    369368    SetUniform(uni, vec4(v, 0));
    370369#elif !defined __CELLOS_LV2__
    371     glUniform3f(uni.frag, v.x, v.y, v.z);
     370    glUniform3fv(uni.frag, 1, &v[0]);
    372371#else
    373372    if (uni.frag)
    374         cgGLSetParameter3f((CGparameter)uni.frag, v.x, v.y, v.z);
     373        cgGLSetParameter3fv((CGparameter)uni.frag, &v[0]);
    375374    if (uni.vert)
    376         cgGLSetParameter3f((CGparameter)uni.vert, v.x, v.y, v.z);
     375        cgGLSetParameter3fv((CGparameter)uni.vert, &v[0]);
    377376#endif
    378377}
     
    386385        g_d3ddevice->SetVertexShaderConstantF((UINT)uni.vert, &v[0], 1);
    387386#elif !defined __CELLOS_LV2__
    388     glUniform4f(uni.frag, v.x, v.y, v.z, v.w);
    389 #else
    390     /* FIXME: use the array versions of these functions */
     387    glUniform4fv(uni.frag, 1, &v[0]);
     388#else
    391389    if (uni.frag)
    392         cgGLSetParameter4f((CGparameter)uni.frag, v.x, v.y, v.z, v.w);
     390        cgGLSetParameter4fv((CGparameter)uni.frag, &v[0]);
    393391    if (uni.vert)
    394         cgGLSetParameter4f((CGparameter)uni.vert, v.x, v.y, v.z, v.w);
     392        cgGLSetParameter4fv((CGparameter)uni.vert, &v[0]);
    395393#endif
    396394}
     
    407405    glUniformMatrix2fv(uni.frag, 1, GL_FALSE, &m[0][0]);
    408406#else
    409     /* FIXME: not implemented */
    410     Abort();
     407    mat4 tmp(m, 1.0f, 1.0f);
     408    if (uni.frag)
     409        cgGLSetMatrixParameterfc((CGparameter)uni.frag, &m[0][0]);
     410    if (uni.vert)
     411        cgGLSetMatrixParameterfc((CGparameter)uni.vert, &m[0][0]);
    411412#endif
    412413}
     
    425426    glUniformMatrix3fv(uni.frag, 1, GL_FALSE, &m[0][0]);
    426427#else
    427     /* FIXME: not implemented */
    428     Abort();
     428    /* FIXME: check it's the proper way to do this */
     429    mat4 tmp(m, 1.0f);
     430    if (uni.frag)
     431        cgGLSetMatrixParameterfc((CGparameter)uni.frag, &m[0][0]);
     432    if (uni.vert)
     433        cgGLSetMatrixParameterfc((CGparameter)uni.vert, &m[0][0]);
    429434#endif
    430435}
Note: See TracChangeset for help on using the changeset viewer.