public void Matrix42() { string fs = @"#version 330 uniform mat4x2 exampleMat42; out vec3 FragColor; void main() { FragColor = vec3(exampleMat42[0].x, exampleMat42[2].y, 0.0); }"; using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context)) using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), fs)) using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location)) { Matrix42<float> m42 = new Matrix42<float>( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); Uniform<Matrix42<float>> exampleMat42 = (Uniform<Matrix42<float>>)sp.Uniforms["exampleMat42"]; Assert.AreEqual("exampleMat42", exampleMat42.Name); Assert.AreEqual(UniformType.FloatMatrix42, exampleMat42.Datatype); Assert.AreEqual(new Matrix42<float>(), exampleMat42.Value); exampleMat42.Value = m42; Assert.AreEqual(m42, exampleMat42.Value); window.Context.Framebuffer = framebuffer; window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 255, 0); } }
public void Matrix42() { string fs = @"#version 330 uniform mat4x2 exampleMat42; out vec3 FragColor; void main() { FragColor = vec3(exampleMat42[0].x, exampleMat42[2].y, 0.0); }"; using (GraphicsWindow window = Device.CreateWindow(1, 1)) using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context)) using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), fs)) using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location)) { Matrix42 <float> m42 = new Matrix42 <float>( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); Uniform <Matrix42 <float> > exampleMat42 = (Uniform <Matrix42 <float> >)sp.Uniforms["exampleMat42"]; Assert.AreEqual("exampleMat42", exampleMat42.Name); Assert.AreEqual(UniformType.FloatMatrix42, exampleMat42.Datatype); Assert.AreEqual(new Matrix42 <float>(), exampleMat42.Value); exampleMat42.Value = m42; Assert.AreEqual(m42, exampleMat42.Value); window.Context.Framebuffer = framebuffer; window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 255, 0); } }
public void Construct1() { Matrix42<double> m = new Matrix42<double>(1.0); for (int i = 0; i < m.NumberOfComponents; ++i) { Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0], 1e-14); } }
internal UniformFloatMatrix42GL3x(string name, int location, ICleanableObserver observer) : base(name, UniformType.FloatMatrix42) { _location = location; _value = new Matrix42 <float>(); _dirty = true; _observer = observer; _observer.NotifyDirty(this); }
public void DoubleToFloat() { Matrix42<double> m = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix42<float> mf = Matrix42<double>.DoubleToFloat(m); Assert.AreEqual(1.0f, mf.Column0Row0, 1e-7); Assert.AreEqual(2.0f, mf.Column1Row0, 1e-7); Assert.AreEqual(3.0f, mf.Column2Row0, 1e-7); Assert.AreEqual(4.0f, mf.Column3Row0, 1e-7); Assert.AreEqual(5.0f, mf.Column0Row1, 1e-7); Assert.AreEqual(6.0f, mf.Column1Row1, 1e-7); Assert.AreEqual(7.0f, mf.Column2Row1, 1e-7); Assert.AreEqual(8.0f, mf.Column3Row1, 1e-7); }
public void Construct2() { Matrix42<double> m = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Assert.AreEqual(1.0, m.Column0Row0); Assert.AreEqual(2.0, m.Column1Row0); Assert.AreEqual(3.0, m.Column2Row0); Assert.AreEqual(4.0, m.Column3Row0); Assert.AreEqual(5.0, m.Column0Row1); Assert.AreEqual(6.0, m.Column1Row1); Assert.AreEqual(7.0, m.Column2Row1); Assert.AreEqual(8.0, m.Column3Row1); Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0]); Assert.AreEqual(5.0, m.ReadOnlyColumnMajorValues[1]); Assert.AreEqual(2.0, m.ReadOnlyColumnMajorValues[2]); Assert.AreEqual(6.0, m.ReadOnlyColumnMajorValues[3]); Assert.AreEqual(3.0, m.ReadOnlyColumnMajorValues[4]); Assert.AreEqual(7.0, m.ReadOnlyColumnMajorValues[5]); Assert.AreEqual(4.0, m.ReadOnlyColumnMajorValues[6]); Assert.AreEqual(8.0, m.ReadOnlyColumnMajorValues[7]); }
public void Equals() { Matrix42<double> a = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix42<double> b = new Matrix42<double>(0.0); Matrix42<double> c = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Assert.IsTrue(a.Equals(c)); Assert.IsTrue(c.Equals(a)); Assert.IsTrue(a == c); Assert.IsTrue(c == a); Assert.IsFalse(c != a); Assert.IsFalse(c != a); Assert.IsFalse(a.Equals(b)); Assert.IsFalse(b.Equals(a)); Assert.IsFalse(a == b); Assert.IsFalse(b == a); Assert.IsTrue(a != b); Assert.IsTrue(b != a); object objA = a; object objB = b; object objC = c; Assert.IsTrue(a.Equals(objA)); Assert.IsTrue(a.Equals(objC)); Assert.IsFalse(a.Equals(objB)); Assert.IsTrue(objA.Equals(objC)); Assert.IsFalse(objA.Equals(objB)); Assert.IsFalse(a.Equals(null)); Assert.IsFalse(a.Equals(5)); }
public void TestGetHashCode() { Matrix42<double> a = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix42<double> b = new Matrix42<double>(0.0); Matrix42<double> c = new Matrix42<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Assert.AreEqual(a.GetHashCode(), c.GetHashCode()); Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode()); }
public override void Set(Context context, DrawState drawState, SceneState sceneState) { _uniform.Value = Matrix42 <float> .DoubleToFloat(sceneState.ModelZToClipCoordinates); }