Add renderer support for additional vec* uniforms.

This commit is contained in:
Paul Chote
2013-03-02 10:36:58 +13:00
parent 064938378f
commit 9566385aac
4 changed files with 52 additions and 0 deletions

View File

@@ -75,6 +75,13 @@ namespace OpenRA.Renderer.Cg
Tao.Cg.CgGl.cgGLSetupSampler(param, texture.texture);
}
public void SetVec(string name, float x)
{
var param = Tao.Cg.Cg.cgGetNamedEffectParameter(effect, name);
if (param != IntPtr.Zero)
Tao.Cg.CgGl.cgGLSetParameter1f(param, x);
}
public void SetVec(string name, float x, float y)
{
var param = Tao.Cg.Cg.cgGetNamedEffectParameter(effect, name);
@@ -82,6 +89,22 @@ namespace OpenRA.Renderer.Cg
Tao.Cg.CgGl.cgGLSetParameter2f(param, x, y);
}
public void SetVec(string name, float[] vec, int length)
{
var param = Tao.Cg.Cg.cgGetNamedEffectParameter(effect, name);
if (param == IntPtr.Zero)
return;
switch(length)
{
case 1: Tao.Cg.CgGl.cgGLSetParameter1fv(param, vec); break;
case 2: Tao.Cg.CgGl.cgGLSetParameter2fv(param, vec); break;
case 3: Tao.Cg.CgGl.cgGLSetParameter3fv(param, vec); break;
case 4: Tao.Cg.CgGl.cgGLSetParameter4fv(param, vec); break;
default: throw new InvalidDataException("Invalid vector length");
}
}
public void SetMatrix(string name, float[] mtx)
{
if (mtx.Length != 16)