예제 #1
0
        /// <summary>
        /// Create a <see cref="ArrayBufferObjectBase"/> for testing.
        /// </summary>
        /// <returns>
        /// It returns the <see cref="ArrayBufferObjectBase"/> instance to test.
        /// </returns>
        private void CreateGpuInstance(BufferObject buffer)
        {
            if (buffer.GetType() == typeof(ArrayBufferObject))
            {
                ArrayBufferObject arrayBufferObject = (ArrayBufferObject)buffer;

                arrayBufferObject.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ElementBufferObject))
            {
                ElementBufferObject elementBufferObject = (ElementBufferObject)buffer;

                elementBufferObject.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ArrayBufferObjectInterleaved))
            {
                ArrayBufferObjectInterleaved arrayBufferObjectInterleaved = (ArrayBufferObjectInterleaved)buffer;

                arrayBufferObjectInterleaved.Create(_Context, CreateTestArray());
            }
            else if (buffer.GetType() == typeof(ArrayBufferObjectPacked))
            {
                ArrayBufferObjectPacked arrayBufferObjectPacked = (ArrayBufferObjectPacked)buffer;

                arrayBufferObjectPacked.Create(_Context, CreateTestArray());
            }
        }
예제 #2
0
            /// <summary>
            /// Allocate an instance of the type.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating the instance.
            /// </param>
            /// <returns>
            /// It returns an instance of a specific type.
            /// </returns>
            public override object Allocate(GraphicsContext ctx)
            {
                ArrayBufferObjectPacked arrayBufferObject = new ArrayBufferObjectPacked(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);

                arrayBufferObject.Create(16);

                return(arrayBufferObject);
            }
예제 #3
0
            /// <summary>
            /// Allocate an instance of the type mocked for spying.
            /// </summary>
            /// <param name="ctx">
            /// A <see cref="GraphicsContext"/> used for allocating the instance.
            /// </param>
            /// <returns>
            /// It returns an instance of a specific type.
            /// </returns>
            public override T AllocateSpy <T>(GraphicsContext ctx)
            {
                T arrayBufferObjectSpy = (T)CreateTypeSpy(_InstanceType, typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);
                ArrayBufferObjectPacked arrayBufferObject = arrayBufferObjectSpy as ArrayBufferObjectPacked;

                if (arrayBufferObject != null)
                {
                    arrayBufferObject.Create(16);
                }

                return(arrayBufferObjectSpy);
            }
예제 #4
0
        public void SetArraySectionByBlock()
        {
            ArrayBufferObjectBase arrayBuffer1 = null, arrayBuffer2 = null, arrayBuffer3 = null;

            try {
                arrayBuffer1 = new ArrayBufferObject(VertexBaseType.Float, 3, BufferObjectHint.StaticCpuDraw);
                arrayBuffer1.Create(16);

                arrayBuffer2 = new ArrayBufferObjectInterleaved(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);
                arrayBuffer2.Create(16);

                arrayBuffer3 = new ArrayBufferObjectPacked(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);
                arrayBuffer3.Create(16);

                using (VertexArrayObject vertexArray = new VertexArrayObject()) {
                    // Set array buffers to different attributes
                    Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer1, 0, "attribute1", null); });
                    VertexArrayBufferValues(vertexArray, "attribute1", null, arrayBuffer1, 0);

                    Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer2, 0, "attribute2", null); });
                    VertexArrayBufferValues(vertexArray, "attribute2", null, arrayBuffer2, 0);

                    Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer2, 1, "attribute3", null); });
                    VertexArrayBufferValues(vertexArray, "attribute3", null, arrayBuffer2, 1);

                    Assert.DoesNotThrow(delegate() { vertexArray.SetArray(arrayBuffer3, 2, "attribute4", null); });
                    VertexArrayBufferValues(vertexArray, "attribute4", null, arrayBuffer3, 2);
                }

                Assert.IsTrue(arrayBuffer1.IsDisposed);
                Assert.IsTrue(arrayBuffer2.IsDisposed);
                Assert.IsTrue(arrayBuffer3.IsDisposed);
            } finally {
                if (arrayBuffer1 != null && !arrayBuffer1.IsDisposed)
                {
                    arrayBuffer1.Dispose();
                }
                if (arrayBuffer2 != null && !arrayBuffer2.IsDisposed)
                {
                    arrayBuffer2.Dispose();
                }
                if (arrayBuffer3 != null && !arrayBuffer3.IsDisposed)
                {
                    arrayBuffer3.Dispose();
                }
            }
        }
예제 #5
0
		public void SetArraySectionByBlock()
		{
			ArrayBufferObjectBase arrayBuffer1 = null, arrayBuffer2 = null, arrayBuffer3 = null;

			try {
				arrayBuffer1 = new ArrayBufferObject(VertexBaseType.Float, 3, BufferObjectHint.StaticCpuDraw);
				arrayBuffer1.Create(16);

				arrayBuffer2 = new ArrayBufferObjectInterleaved(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);
				arrayBuffer2.Create(16);

				arrayBuffer3 = new ArrayBufferObjectPacked(typeof(ComplexVertexElement), BufferObjectHint.StaticCpuDraw);
				arrayBuffer3.Create(16);

				using (VertexArrayObject vertexArray = new VertexArrayObject()) {
					// Set array buffers to different attributes
					Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer1, 0, "attribute1", null); });
					VertexArrayBufferValues(vertexArray, "attribute1", null, arrayBuffer1, 0);

					Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer2, 0, "attribute2", null); });
					VertexArrayBufferValues(vertexArray, "attribute2", null, arrayBuffer2, 0);

					Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer2, 1, "attribute3", null); });
					VertexArrayBufferValues(vertexArray, "attribute3", null, arrayBuffer2, 1);

					Assert.DoesNotThrow(delegate () { vertexArray.SetArray(arrayBuffer3, 2, "attribute4", null); });
					VertexArrayBufferValues(vertexArray, "attribute4", null, arrayBuffer3, 2);
				}

				Assert.IsTrue(arrayBuffer1.IsDisposed);
				Assert.IsTrue(arrayBuffer2.IsDisposed);
				Assert.IsTrue(arrayBuffer3.IsDisposed);
			} finally {
				if (arrayBuffer1 != null && !arrayBuffer1.IsDisposed)
					arrayBuffer1.Dispose();
				if (arrayBuffer2 != null && !arrayBuffer2.IsDisposed)
					arrayBuffer2.Dispose();
				if (arrayBuffer3 != null && !arrayBuffer3.IsDisposed)
					arrayBuffer3.Dispose();
			}
		}