//----------------------------------------------------------------------------------------- protected override void OnUnload(EventArgs e) { GL.DeleteProgram(_shaderProgramName[0]); GL.DeleteProgram(_shaderProgramName[1]); GL.DeleteBuffers(Buffers.GetCount(), Buffers.Names); GL.DeleteVertexArrays(1, ref _vertexArrayName); }
//----------------------------------------------------------------------------------------- private bool _InitBuffers() { float[] vertexData = new float[] { // back -0.25f, 0.25f, -0.25f, -0.25f, -0.25f, -0.25f, 0.25f, -0.25f, -0.25f, 0.25f, -0.25f, -0.25f, 0.25f, 0.25f, -0.25f, -0.25f, 0.25f, -0.25f, // right 0.25f, -0.25f, -0.25f, 0.25f, -0.25f, 0.25f, 0.25f, 0.25f, -0.25f, 0.25f, -0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, -0.25f, // front 0.25f, -0.25f, 0.25f, -0.25f, -0.25f, 0.25f, 0.25f, 0.25f, 0.25f, -0.25f, -0.25f, 0.25f, -0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, // left -0.25f, -0.25f, 0.25f, -0.25f, -0.25f, -0.25f, -0.25f, 0.25f, 0.25f, -0.25f, -0.25f, -0.25f, -0.25f, 0.25f, -0.25f, -0.25f, 0.25f, 0.25f, // bottom -0.25f, -0.25f, 0.25f, 0.25f, -0.25f, 0.25f, 0.25f, -0.25f, -0.25f, 0.25f, -0.25f, -0.25f, -0.25f, -0.25f, -0.25f, -0.25f, -0.25f, 0.25f, // top -0.25f, 0.25f, -0.25f, 0.25f, 0.25f, -0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, -0.25f, 0.25f, 0.25f, -0.25f, 0.25f, -0.25f }; GL.GenBuffers(Buffers.GetCount(), Buffers.Names); GL.BindBuffer(BufferTarget.ArrayBuffer, Buffers.GetName(Buffers.Type.VERTEX)); GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(sizeof(float) * 4 * vertexData.Length), vertexData, BufferUsageHint.StaticDraw); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindBuffer(BufferTarget.AtomicCounterBuffer, Buffers.GetName(Buffers.Type.ATOMIC_COUNTER)); GL.BufferData(BufferTarget.AtomicCounterBuffer, (IntPtr)sizeof(uint), IntPtr.Zero, BufferUsageHint.DynamicCopy); GL.BindBuffer(BufferTarget.AtomicCounterBuffer, 0); return(true); }