Add support for boolean uniforms.

This commit is contained in:
Paul Chote
2015-09-28 19:41:41 +01:00
parent 3665d8f19b
commit b08adbeb61
3 changed files with 13 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ namespace OpenRA
public interface IShader
{
void SetBool(string name, bool value);
void SetVec(string name, float x);
void SetVec(string name, float x, float y);
void SetVec(string name, float[] vec, int length);

View File

@@ -148,6 +148,17 @@ namespace OpenRA.Platforms.Default
textures[texUnit] = t;
}
public void SetBool(string name, bool value)
{
VerifyThreadAffinity();
GL.UseProgram(program);
ErrorHandler.CheckGlError();
var param = GL.GetUniformLocation(program, name);
ErrorHandler.CheckGlError();
GL.Uniform1(param, value ? 1 : 0);
ErrorHandler.CheckGlError();
}
public void SetVec(string name, float x)
{
VerifyThreadAffinity();

View File

@@ -63,6 +63,7 @@ namespace OpenRA.Platforms.Null
public class NullShader : IShader
{
public void SetBool(string name, bool value) { }
public void SetVec(string name, float x) { }
public void SetVec(string name, float x, float y) { }
public void SetVec(string name, float[] vec, int length) { }