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 }
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 ); }
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 ); }
public IGLBuffer GenIndexBuffer( bool dynamic, int indexCount, IndexElementSize indexElementSize ) { IGLBuffer result = null; ForceToMainThread(() => { result = GLDevice.GenIndexBuffer( dynamic, indexCount, indexElementSize ); }); // End ForceToMainThread return(result); }
public IGLBuffer GenVertexBuffer( bool dynamic, int vertexCount, int vertexStride ) { IGLBuffer result = null; ForceToMainThread(() => { result = GLDevice.GenVertexBuffer( dynamic, vertexCount, vertexStride ); }); // End ForceToMainThread return(result); }
public void SetVertexBufferData( IGLBuffer buffer, int offsetInBytes, IntPtr data, int dataLength, SetDataOptions options ) { ForceToMainThread(() => { GLDevice.SetVertexBufferData( buffer, offsetInBytes, data, dataLength, options ); }); // End ForceToMainThread }
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 }
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); }
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); }
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 }
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 }
private void BindIndexBuffer(IGLBuffer buffer) { uint handle = (buffer as OpenGLBuffer).Handle; if (handle != currentIndexBuffer) { glBindBuffer(GLenum.GL_ELEMENT_ARRAY_BUFFER, handle); currentIndexBuffer = handle; } }
public void AddDisposeIndexBuffer(IGLBuffer buffer) { if (IsOnMainThread()) { DeleteIndexBuffer(buffer); } else { GCIndexBuffers.Enqueue(buffer); } }
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 }
public void AddDisposeVertexBuffer(IGLBuffer buffer) { GCVertexBuffers.Enqueue(buffer); }
public void AddDisposeIndexBuffer(IGLBuffer buffer) { GCIndexBuffers.Enqueue(buffer); }
public RenderProcessor(IGLBuffer buf) { buffer = buf; }
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 }