private void SetNormalAttribute(GraphicsContext ctx) { if (ArrayBuffer != null) { ArrayBufferObjectBase.IArraySection arraySection = ArrayBuffer.GetArraySection(ArraySectionIndex); int arrayLength = (int)ArrayBufferItem.GetArrayLength(arraySection.ItemType); if (arrayLength != 3) { throw new NotSupportedException(String.Format("normal pointer of length {0} not supported", arrayLength)); } // Bind the array buffer ArrayBuffer.Bind(ctx); // Set vertex pointer Gl.NormalPointer( ArrayBufferItem.GetNormalPointerType(arraySection.ItemType), arraySection.Stride.ToInt32(), arraySection.Pointer ); // Enable vertex attribute Gl.EnableClientState(EnableCap.NormalArray); } else { Gl.DisableClientState(EnableCap.NormalArray); } }
private void SetTexCoordAttribute(GraphicsContext ctx) { if (ArrayBuffer != null) { ArrayBufferObjectBase.IArraySection arraySection = ArrayBuffer.GetArraySection(ArraySectionIndex); int arrayLength = (int)ArrayBufferItem.GetArrayLength(arraySection.ItemType); int arrayStride = arraySection.Stride.ToInt32(); // Bind the array buffer ArrayBuffer.Bind(ctx); // Set vertex pointer Gl.TexCoordPointer( arrayLength, ArrayBufferItem.GetTexCoordPointerType(arraySection.ItemType), arraySection.Stride.ToInt32(), arraySection.Pointer ); // Enable vertex attribute Gl.EnableClientState(EnableCap.TextureCoordArray); } else { Gl.DisableClientState(EnableCap.TextureCoordArray); } }
public static void EnablePrimitiveRestart(GraphicsContext ctx, uint index) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (ctx.IsCurrent) { throw new ArgumentException("not current", "ctx"); } if (ctx.Caps.GlExtensions.PrimitiveRestart) { // Enable primitive restart (server state) Gl.Enable(EnableCap.PrimitiveRestart); // Specify restart index Gl.PrimitiveRestartIndex(index); } else if (ctx.Caps.GlExtensions.PrimitiveRestart_NV) { // Enable primitive restart (client state) Gl.EnableClientState(EnableCap.PrimitiveRestartNv); // Specify restart index Gl.PrimitiveRestartIndexNV(index); } else { throw new InvalidOperationException("primitive restart not supported"); } }
private void DrawLines2f_GL_1_1(Vertex2f[] vertices) { if ((vertices.Length % 2) != 0) { throw new ArgumentException("length not a multiple of 2", "vertices"); } using (MemoryLock memoryLock = new MemoryLock(vertices)) { // Setup arrays Gl.VertexPointer(2, VertexPointerType.Float, 0, memoryLock.Address); Gl.EnableClientState(EnableCap.VertexArray); // Draw arrays Gl.DrawArrays(PrimitiveType.Lines, 0, vertices.Length); } }