public void Matrix24() { string fs = @"#version 330 uniform mat2x4 exampleMat24; out vec3 FragColor; void main() { FragColor = vec3(exampleMat24[0].y, exampleMat24[0].w, 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)) { Matrix24<float> m24 = new Matrix24<float>( 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); Uniform<Matrix24<float>> exampleMat24 = (Uniform<Matrix24<float>>)sp.Uniforms["exampleMat24"]; Assert.AreEqual("exampleMat24", exampleMat24.Name); Assert.AreEqual(UniformType.FloatMatrix24, exampleMat24.Datatype); Assert.AreEqual(new Matrix24<float>(), exampleMat24.Value); exampleMat24.Value = m24; Assert.AreEqual(m24, exampleMat24.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 Construct2() { Matrix24<double> m = new Matrix24<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.Column0Row1); Assert.AreEqual(4.0, m.Column1Row1); Assert.AreEqual(5.0, m.Column0Row2); Assert.AreEqual(6.0, m.Column1Row2); Assert.AreEqual(7.0, m.Column0Row3); Assert.AreEqual(8.0, m.Column1Row3); Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0]); Assert.AreEqual(3.0, m.ReadOnlyColumnMajorValues[1]); Assert.AreEqual(5.0, m.ReadOnlyColumnMajorValues[2]); Assert.AreEqual(7.0, m.ReadOnlyColumnMajorValues[3]); Assert.AreEqual(2.0, m.ReadOnlyColumnMajorValues[4]); Assert.AreEqual(4.0, m.ReadOnlyColumnMajorValues[5]); Assert.AreEqual(6.0, m.ReadOnlyColumnMajorValues[6]); Assert.AreEqual(8.0, m.ReadOnlyColumnMajorValues[7]); }
public void Matrix24() { string fs = @"#version 330 uniform mat2x4 exampleMat24; out vec3 FragColor; void main() { FragColor = vec3(exampleMat24[0].y, exampleMat24[0].w, 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)) { Matrix24 <float> m24 = new Matrix24 <float>( 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); Uniform <Matrix24 <float> > exampleMat24 = (Uniform <Matrix24 <float> >)sp.Uniforms["exampleMat24"]; Assert.AreEqual("exampleMat24", exampleMat24.Name); Assert.AreEqual(UniformType.FloatMatrix24, exampleMat24.Datatype); Assert.AreEqual(new Matrix24 <float>(), exampleMat24.Value); exampleMat24.Value = m24; Assert.AreEqual(m24, exampleMat24.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); } }
internal UniformFloatMatrix24GL3x(string name, int location, ICleanableObserver observer) : base(name, UniformType.FloatMatrix24) { _location = location; _value = new Matrix24 <float>(); _dirty = true; _observer = observer; _observer.NotifyDirty(this); }
public void Construct1() { Matrix24<double> m = new Matrix24<double>(1.0); for (int i = 0; i < m.NumberOfComponents; ++i) { Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0], 1e-14); } }
public void DoubleToFloat() { Matrix24<double> m = new Matrix24<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix24<float> mf = Matrix24<double>.DoubleToFloat(m); Assert.AreEqual(1.0f, mf.Column0Row0, 1e-7); Assert.AreEqual(2.0f, mf.Column1Row0, 1e-7); Assert.AreEqual(3.0f, mf.Column0Row1, 1e-7); Assert.AreEqual(4.0f, mf.Column1Row1, 1e-7); Assert.AreEqual(5.0f, mf.Column0Row2, 1e-7); Assert.AreEqual(6.0f, mf.Column1Row2, 1e-7); Assert.AreEqual(7.0f, mf.Column0Row3, 1e-7); Assert.AreEqual(8.0f, mf.Column1Row3, 1e-7); }
public override string ToString() { if (HasSignal) { string ret = string.Format("{0} Handle:{1} Frame:{7} x:{3} y:{4} z:{5} Error:{6} Status:{8} {9}", TimeStamp.ToLongTimeString(), SensorIdx, HasSignal, Matrix14.ToString("F1").PadLeft(6, ' '), Matrix24.ToString("F1").PadLeft(6, ' '), Matrix34.ToString("F1").PadLeft(6, ' '), Error.ToString("F1").PadLeft(4, ' '), FrameNumber, PortStatus, Is6D ? "6D" : "5D"); if (PartiallyOutOfVolume) { ret += " PartiallyOutOfVolume"; } return(ret); } else { string ret = string.Format("{0} Handle:{1} Status:{2}", TimeStamp.ToLongTimeString(), SensorIdx, PortStatus); if (SensorCoilIsBroken) { ret += " Sensor is broken!"; } if (OutOfVolume) { ret += " OutOfVolume!"; } return(ret); } }
public void Equals() { Matrix24<double> a = new Matrix24<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix24<double> b = new Matrix24<double>(0.0); Matrix24<double> c = new Matrix24<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() { Matrix24<double> a = new Matrix24<double>( 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0); Matrix24<double> b = new Matrix24<double>(0.0); Matrix24<double> c = new Matrix24<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()); }