예제 #1
0
        public void Vector4_EqualsTestsCorrectly()
        {
            var vector1 = new Vector4(123.4f, 567.8f, 901.2f, 345.6f);
            var vector2 = new Vector4(123.4f, 567.8f, 901.2f, 345.6f);
            var vector3 = new Vector4(345.6f, 901.2f, 567.8f, 123.4f);

            TheResultingValue(vector1.Equals(vector2)).ShouldBe(true);
            TheResultingValue(vector1.Equals(vector3)).ShouldBe(false);
        }
예제 #2
0
		public void NaNEquality()
		{
			Vector4 nanVec = new Vector4(float.NaN, float.NaN, float.NaN, float.NaN);
			Assert.IsFalse(nanVec == nanVec);
			Assert.IsTrue(nanVec != nanVec);
			Assert.IsTrue(nanVec.Equals(nanVec));
		}
예제 #3
0
        // Test Operator: Equality //-----------------------------------------//

        /// <summary>
        /// Helper method for testing equality.
        /// </summary>
        void TestEquality (Vector4 a, Vector4 b, Boolean expected )
        {
            // This test asserts the following:
            //   (a == b) == expected
            //   (b == a) == expected
            //   (a != b) == !expected
            //   (b != a) == !expected

            Boolean result_1a = (a == b);
            Boolean result_1b = (a.Equals(b));
            Boolean result_1c = (a.Equals((Object)b));

            Boolean result_2a = (b == a);
            Boolean result_2b = (b.Equals(a));
            Boolean result_2c = (b.Equals((Object)a));

            Boolean result_3a = (a != b);
            Boolean result_4a = (b != a);

            Assert.That(result_1a, Is.EqualTo(expected));
            Assert.That(result_1b, Is.EqualTo(expected));
            Assert.That(result_1c, Is.EqualTo(expected));
            Assert.That(result_2a, Is.EqualTo(expected));
            Assert.That(result_2b, Is.EqualTo(expected));
            Assert.That(result_2c, Is.EqualTo(expected));
            Assert.That(result_3a, Is.EqualTo(!expected));
            Assert.That(result_4a, Is.EqualTo(!expected));
        }
예제 #4
0
		public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
		{
			// glClear depends on the scissor rectangle!
			if (scissorTestEnable)
			{
				glDisable(GLenum.GL_SCISSOR_TEST);
			}

			bool clearTarget = (options & ClearOptions.Target) == ClearOptions.Target;
			bool clearDepth = (options & ClearOptions.DepthBuffer) == ClearOptions.DepthBuffer;
			bool clearStencil = (options & ClearOptions.Stencil) == ClearOptions.Stencil;

			// Get the clear mask, set the clear properties if needed
			GLenum clearMask = GLenum.GL_ZERO;
			if (clearTarget)
			{
				clearMask |= GLenum.GL_COLOR_BUFFER_BIT;
				if (!color.Equals(currentClearColor))
				{
					glClearColor(
						color.X,
						color.Y,
						color.Z,
						color.W
					);
					currentClearColor = color;
				}
				// glClear depends on the color write mask!
				if (colorWriteEnable != ColorWriteChannels.All)
				{
					// FIXME: ColorWriteChannels1/2/3? -flibit
					glColorMask(true, true, true, true);
				}
			}
			if (clearDepth)
			{
				clearMask |= GLenum.GL_DEPTH_BUFFER_BIT;
				if (depth != currentClearDepth)
				{
					glClearDepth((double) depth);
					currentClearDepth = depth;
				}
				// glClear depends on the depth write mask!
				if (!zWriteEnable)
				{
					glDepthMask(true);
				}
			}
			if (clearStencil)
			{
				clearMask |= GLenum.GL_STENCIL_BUFFER_BIT;
				if (stencil != currentClearStencil)
				{
					glClearStencil(stencil);
					currentClearStencil = stencil;
				}
				// glClear depends on the stencil write mask!
				if (stencilWriteMask != -1)
				{
					// AKA 0xFFFFFFFF, ugh -flibit
					glStencilMask(-1);
				}
			}

			// CLEAR!
			glClear(clearMask);

			// Clean up after ourselves.
			if (scissorTestEnable)
			{
				glEnable(GLenum.GL_SCISSOR_TEST);
			}
			if (clearTarget && colorWriteEnable != ColorWriteChannels.All)
			{
				// FIXME: ColorWriteChannels1/2/3? -flibit
				glColorMask(
					(colorWriteEnable & ColorWriteChannels.Red) != 0,
					(colorWriteEnable & ColorWriteChannels.Blue) != 0,
					(colorWriteEnable & ColorWriteChannels.Green) != 0,
					(colorWriteEnable & ColorWriteChannels.Alpha) != 0
				);
			}
			if (clearDepth && !zWriteEnable)
			{
				glDepthMask(false);
			}
			if (clearStencil && stencilWriteMask != -1) // AKA 0xFFFFFFFF, ugh -flibit
			{
				glStencilMask(stencilWriteMask);
			}
		}
예제 #5
0
        public void Vector4NormaliseTest()
        {
            var a = new Vector4(3.0f, 4.0f, 1.0f, 2.0f);
            var expectedResult = new Vector4(0.5477226f, 0.730296731f, 0.182574183f, 0.365148365f);

            a.Normalise();

            Assert.True(a.Equals(expectedResult, 1e-3f));                
        }