Add renderer support for matrix uniforms.
This commit is contained in:
@@ -62,6 +62,7 @@ namespace OpenRA.FileFormats.Graphics
|
||||
{
|
||||
void SetVec(string name, float x, float y);
|
||||
void SetTexture(string param, ITexture texture);
|
||||
void SetMatrix(string param, float[] mtx);
|
||||
void Render(Action a);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,5 +81,15 @@ namespace OpenRA.Renderer.Cg
|
||||
if (param != IntPtr.Zero)
|
||||
Tao.Cg.CgGl.cgGLSetParameter2f(param, x, y);
|
||||
}
|
||||
|
||||
public void SetMatrix(string name, float[] mtx)
|
||||
{
|
||||
if (mtx.Length != 16)
|
||||
throw new InvalidDataException("Invalid 4x4 matrix");
|
||||
|
||||
var param = Tao.Cg.Cg.cgGetNamedEffectParameter(effect, name);
|
||||
if (param != IntPtr.Zero)
|
||||
Tao.Cg.CgGl.cgGLSetMatrixParameterfr(param, mtx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,5 +150,18 @@ namespace OpenRA.Renderer.Glsl
|
||||
Gl.glUniform2fARB(param,x,y);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
|
||||
public void SetMatrix(string name, float[] mtx)
|
||||
{
|
||||
if (mtx.Length != 16)
|
||||
throw new InvalidDataException("Invalid 4x4 matrix");
|
||||
|
||||
Gl.glUseProgramObjectARB(program);
|
||||
ErrorHandler.CheckGlError();
|
||||
int param = Gl.glGetUniformLocationARB(program, name);
|
||||
ErrorHandler.CheckGlError();
|
||||
Gl.glUniformMatrix4fv(param, 1, Gl.GL_FALSE, mtx);
|
||||
ErrorHandler.CheckGlError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace OpenRA.Renderer.Null
|
||||
{
|
||||
public void SetVec(string name, float x, float y) { }
|
||||
public void SetTexture(string param, ITexture texture) { }
|
||||
public void SetMatrix(string param, float[] mtx) { }
|
||||
public void Commit() { }
|
||||
public void Render(Action a) { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user