示例#1
0
 public void DrawInstancedPrimitives(
     PrimitiveType primitiveType,
     int baseVertex,
     int minVertexIndex,
     int numVertices,
     int startIndex,
     int primitiveCount,
     int instanceCount,
     IGLBuffer indices,
     IndexElementSize indexElementSize
     )
 {
     ForceToMainThread(() =>
     {
         GLDevice.DrawInstancedPrimitives(
             primitiveType,
             baseVertex,
             minVertexIndex,
             numVertices,
             startIndex,
             primitiveCount,
             instanceCount,
             indices,
             indexElementSize
             );
     });             // End ForceToMainThread
 }
示例#2
0
        protected IndexBuffer(
            GraphicsDevice graphicsDevice,
            IndexElementSize indexElementSize,
            int indexCount,
            BufferUsage usage,
            bool dynamic
            )
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }

            GraphicsDevice   = graphicsDevice;
            IndexElementSize = indexElementSize;
            IndexCount       = indexCount;
            BufferUsage      = usage;

            buffer = GraphicsDevice.GLDevice.GenIndexBuffer(
                dynamic,
                usage,
                IndexCount,
                IndexElementSize
                );
        }
示例#3
0
        protected VertexBuffer(
            GraphicsDevice graphicsDevice,
            VertexDeclaration vertexDeclaration,
            int vertexCount,
            BufferUsage bufferUsage,
            bool dynamic
            )
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }

            GraphicsDevice    = graphicsDevice;
            VertexDeclaration = vertexDeclaration;
            VertexCount       = vertexCount;
            BufferUsage       = bufferUsage;

            // Make sure the graphics device is assigned in the vertex declaration.
            if (vertexDeclaration.GraphicsDevice != graphicsDevice)
            {
                vertexDeclaration.GraphicsDevice = graphicsDevice;
            }

            buffer = GraphicsDevice.GLDevice.GenVertexBuffer(
                dynamic,
                VertexCount,
                VertexDeclaration.VertexStride
                );
        }
示例#4
0
        public IGLBuffer GenIndexBuffer(
            bool dynamic,
            int indexCount,
            IndexElementSize indexElementSize
            )
        {
            IGLBuffer result = null;

            ForceToMainThread(() =>
            {
                result = GLDevice.GenIndexBuffer(
                    dynamic,
                    indexCount,
                    indexElementSize
                    );
            });             // End ForceToMainThread
            return(result);
        }
示例#5
0
        public IGLBuffer GenVertexBuffer(
            bool dynamic,
            int vertexCount,
            int vertexStride
            )
        {
            IGLBuffer result = null;

            ForceToMainThread(() =>
            {
                result = GLDevice.GenVertexBuffer(
                    dynamic,
                    vertexCount,
                    vertexStride
                    );
            });             // End ForceToMainThread
            return(result);
        }
示例#6
0
 public void SetVertexBufferData(
     IGLBuffer buffer,
     int offsetInBytes,
     IntPtr data,
     int dataLength,
     SetDataOptions options
     )
 {
     ForceToMainThread(() =>
     {
         GLDevice.SetVertexBufferData(
             buffer,
             offsetInBytes,
             data,
             dataLength,
             options
             );
     });             // End ForceToMainThread
 }
示例#7
0
 public void GetIndexBufferData(
     IGLBuffer buffer,
     int offsetInBytes,
     IntPtr data,
     int startIndex,
     int elementCount,
     int elementSizeInBytes
     )
 {
     ForceToMainThread(() =>
     {
         GLDevice.GetIndexBufferData(
             buffer,
             offsetInBytes,
             data,
             startIndex,
             elementCount,
             elementSizeInBytes
             );
     });             // End ForceToMainThread
 }
示例#8
0
		private void DeleteIndexBuffer(IGLBuffer buffer)
		{
			uint handle = (buffer as OpenGLBuffer).Handle;
			if (handle == currentIndexBuffer)
			{
				glBindBuffer(GLenum.GL_ELEMENT_ARRAY_BUFFER, 0);
				currentIndexBuffer = 0;
			}
			glDeleteBuffers(1, ref handle);
		}
示例#9
0
		private void DeleteVertexBuffer(IGLBuffer buffer)
		{
			uint handle = (buffer as OpenGLBuffer).Handle;
			if (handle == currentVertexBuffer)
			{
				glBindBuffer(GLenum.GL_ARRAY_BUFFER, 0);
				currentVertexBuffer = 0;
			}
			for (int i = 0; i < attributes.Length; i += 1)
			{
				if (handle == attributes[i].CurrentBuffer)
				{
					// Force the next vertex attrib update!
					attributes[i].CurrentBuffer = uint.MaxValue;
				}
			}
			glDeleteBuffers(1, ref handle);
		}
示例#10
0
		public void GetIndexBufferData(
			IGLBuffer buffer,
			int offsetInBytes,
			IntPtr data,
			int startIndex,
			int elementCount,
			int elementSizeInBytes
		) {
#if !DISABLE_THREADING
			ForceToMainThread(() => {
#endif

			BindIndexBuffer(buffer);

			glGetBufferSubData(
				GLenum.GL_ELEMENT_ARRAY_BUFFER,
				(IntPtr) offsetInBytes,
				(IntPtr) (elementCount * elementSizeInBytes),
				data + (startIndex * elementSizeInBytes)
			);

#if !DISABLE_THREADING
			});
#endif
		}
示例#11
0
		public void SetIndexBufferData(
			IGLBuffer buffer,
			int offsetInBytes,
			IntPtr data,
			int startIndex,
			int elementCount,
			int elementSizeInBytes,
			SetDataOptions options
		) {
#if !DISABLE_THREADING
			ForceToMainThread(() => {
#endif

			BindIndexBuffer(buffer);

			if (options == SetDataOptions.Discard)
			{
				glBufferData(
					GLenum.GL_ELEMENT_ARRAY_BUFFER,
					buffer.BufferSize,
					IntPtr.Zero,
					(buffer as OpenGLBuffer).Dynamic
				);
			}

			glBufferSubData(
				GLenum.GL_ELEMENT_ARRAY_BUFFER,
				(IntPtr) offsetInBytes,
				(IntPtr) (elementSizeInBytes * elementCount),
				data + (startIndex * elementSizeInBytes)
			);

#if !DISABLE_THREADING
			});
#endif
		}
示例#12
0
		private void BindIndexBuffer(IGLBuffer buffer)
		{
			uint handle = (buffer as OpenGLBuffer).Handle;
			if (handle != currentIndexBuffer)
			{
				glBindBuffer(GLenum.GL_ELEMENT_ARRAY_BUFFER, handle);
				currentIndexBuffer = handle;
			}
		}
示例#13
0
		public void AddDisposeIndexBuffer(IGLBuffer buffer)
		{
			if (IsOnMainThread())
			{
				DeleteIndexBuffer(buffer);
			}
			else
			{
				GCIndexBuffers.Enqueue(buffer);
			}
		}
示例#14
0
        public void SetVertexBufferData(
			IGLBuffer buffer,
			int offsetInBytes,
			IntPtr data,
			int startIndex,
			int elementCount,
			int elementSizeInBytes,
			SetDataOptions options
		)
        {
            #if !DISABLE_THREADING
            ForceToMainThread(() => {
            #endif
            uint handle = (buffer as OpenGLBuffer).Handle;

            if (options == SetDataOptions.Discard)
            {
                glNamedBufferData(
                    handle,
                    buffer.BufferSize,
                    IntPtr.Zero,
                    (buffer as OpenGLBuffer).Dynamic
                );
            }

            glNamedBufferSubData(
                handle,
                (IntPtr) offsetInBytes,
                (IntPtr) (elementSizeInBytes * elementCount),
                data + (startIndex * elementSizeInBytes)
            );

            #if !DISABLE_THREADING
            });
            #endif
        }
示例#15
0
 public void AddDisposeVertexBuffer(IGLBuffer buffer)
 {
     GCVertexBuffers.Enqueue(buffer);
 }
示例#16
0
 public void AddDisposeIndexBuffer(IGLBuffer buffer)
 {
     GCIndexBuffers.Enqueue(buffer);
 }
示例#17
0
 public RenderProcessor(IGLBuffer buf)
 {
     buffer = buf;
 }
示例#18
0
        public void GetVertexBufferData(
			IGLBuffer buffer,
			int offsetInBytes,
			IntPtr data,
			int startIndex,
			int elementCount,
			int elementSizeInBytes,
			int vertexStride
		)
        {
            #if !DISABLE_THREADING
            ForceToMainThread(() => {
            #endif

            glGetNamedBufferSubData(
                (buffer as OpenGLBuffer).Handle,
                (IntPtr) offsetInBytes,
                (IntPtr) (elementCount * vertexStride),
                data + (startIndex * elementSizeInBytes)
            );

            #if !DISABLE_THREADING
            });
            #endif
        }