private static uint ToOpenTKBufferType(GraphicsBufferType value) { switch (value) { case GraphicsBufferType.Vertex: return(WebGLRenderingContextBase.ARRAY_BUFFER); case GraphicsBufferType.Index: return(WebGLRenderingContextBase.ELEMENT_ARRAY_BUFFER); } return(WebGLRenderingContextBase.ARRAY_BUFFER); }
private static BufferTarget ToOpenTKBufferType(GraphicsBufferType value) { switch (value) { case GraphicsBufferType.Vertex: return(BufferTarget.ArrayBuffer); case GraphicsBufferType.Index: return(BufferTarget.ElementArrayBuffer); } return(BufferTarget.ArrayBuffer); }
public static void Bind(GraphicsBufferType type, NativeGraphicsBuffer buffer) { if (GetBound(type) == buffer) { return; } SetBound(type, buffer); BufferTarget target = ToOpenTKBufferType(type); GL.BindBuffer(target, buffer != null ? buffer.Handle : 0); }
private static NativeGraphicsBuffer GetBound(GraphicsBufferType type) { if (type == GraphicsBufferType.Vertex) { return(boundVertex); } else if (type == GraphicsBufferType.Index) { return(boundIndex); } else { return(null); } }
private static void SetBound(GraphicsBufferType type, NativeGraphicsBuffer buffer) { if (type == GraphicsBufferType.Vertex) { boundVertex = buffer; } else if (type == GraphicsBufferType.Index) { boundIndex = buffer; } else { return; } }
private static ClearBufferMask GetClearFlags(GraphicsBufferType bufferMask) { ClearBufferMask clearFlags = 0; if ((bufferMask & GraphicsBufferType.Color) != 0) { clearFlags |= ClearBufferMask.ColorBufferBit; } if ((bufferMask & GraphicsBufferType.Depth) != 0) { clearFlags |= ClearBufferMask.DepthBufferBit; } if ((bufferMask & GraphicsBufferType.Stencil) != 0) { clearFlags |= ClearBufferMask.StencilBufferBit; } return(clearFlags); }
/// <summary> /// Clear surface buffers. /// </summary> /// <param name="ctx"> /// A <see cref="GraphicsContext"/> used for clearing buffers. /// </param> /// <param name="bufferMask"> /// A <see cref="GraphicsBuffersFormat.GraphicsBufferType"/> indicating which buffers to clear. /// </param> public void Clear(GraphicsContext ctx, GraphicsBufferType bufferMask) { // Update clear values (only what is necessary) if ((bufferMask & GraphicsBufferType.Color) != 0) { Gl.ClearColor(mClearColor.Red, mClearColor.Green, mClearColor.Blue, mClearColor.Alpha); } if ((bufferMask & GraphicsBufferType.Depth) != 0) { Gl.ClearDepth(mClearDepth); } if ((bufferMask & GraphicsBufferType.Stencil) != 0) { Gl.ClearStencil(mClearStencil); } // Clear Gl.Clear(GetClearFlags(bufferMask)); }
public NativeGraphicsBuffer(GraphicsBufferType type) { this.handle = GL.GenBuffer(); this.type = type; }
INativeGraphicsBuffer IGraphicsBackend.CreateBuffer(GraphicsBufferType type) { return(new NativeGraphicsBuffer(type)); }
public NativeGraphicsBuffer(GraphicsBufferType type) { this.handle = GraphicsBackend.GL.CreateBuffer(); this.type = type; }
public DummyNativeGraphicsBuffer(GraphicsBufferType type) { this.type = type; }
public GraphicsBuffer(GraphicsBufferType bufferType = GraphicsBufferType.Default) { this.bufferType = bufferType; }
public NativeGraphicsBuffer(GraphicsBufferType type) { GL.GenBuffers(1, out this.handle); this.type = type; }
/// <summary> /// Confirm pixel format assigned to this surface. XXX /// </summary> /// <param name="pixelFormat"> /// A <see cref="DevicePixelFormat"/> defining the available surface buffers /// and their definitions. /// </param> /// <remarks> /// This routine shall be called after a successfull call to SetPixelFormat. /// </remarks> public void SetBufferConfiguration(DevicePixelFormat pixelFormat) { _SurfaceBuffers = 0; if (pixelFormat.ColorBits > 0) { if (pixelFormat.SRGBCapable == false) { _SurfaceBuffers |= GraphicsBufferType.Color; } else { _SurfaceBuffers |= GraphicsBufferType.ColorSRGB; } } if (pixelFormat.DoubleBuffer) { _SurfaceBuffers |= GraphicsBufferType.Double; } if (pixelFormat.DepthBits > 0) { _SurfaceBuffers |= GraphicsBufferType.Depth; } if (pixelFormat.StencilBits > 0) { _SurfaceBuffers |= GraphicsBufferType.Stencil; } if (pixelFormat.MultisampleBits > 0) { _SurfaceBuffers |= GraphicsBufferType.Multisample; } switch (pixelFormat.ColorBits) { case 8: _ColorType = PixelLayout.RGB8; break; case 16: _ColorType = PixelLayout.RGB16; break; case 24: _ColorType = PixelLayout.RGB24; break; case 32: _ColorType = PixelLayout.RGBA32; break; default: throw new InvalidOperationException("invalid pixel format composed by " + pixelFormat.ColorBits + " bits"); } _DepthBits = (uint)pixelFormat.DepthBits; _StencilBits = (uint)pixelFormat.StencilBits; _MultisampleBits = (uint)pixelFormat.MultisampleBits; }