public static void Init() { sceneShaped = false; GL1.GenVertexArray(1, out VAOId); GL1.BindVertexArray(VAOId); GL1.GenBuffer(1, ref VBOId); GL1.GenBuffer(1, ref VBOId2); GL1.BindBuffer(0x8892, VBOId); ShaderProgram = new ShaderProgram("shaders\\vertex.glsl", "shaders\\fragment.glsl"); ShaderProgram.Use(); matrixLocation = GL1.GetUniformLocation(ShaderProgram.ProgramID, "MVP"); GL1.ClearColor(0.5f, 0, 1, 0); GL1.Clear(0x00000100 | 0x00004000); }
private static void DrawArray(Vector3[] pos, Vector3[] color, PrimitiveType type) { if (pos != null) { GL1.EnableVertexAttribArray(0); GL1.BindBuffer(0x8892, VBOId); GL1.BufferData(0x8892, (IntPtr)(Vector3.SizeInBytes * pos.Length), pos, (uint)BufferUsageHint.DynamicDraw); GL1.VertexAttribPointer(0, 3, (uint)VertexAttribPointerType.Float, false, Vector3.SizeInBytes, (IntPtr)0); } if (color != null) { GL1.EnableVertexAttribArray(1); GL1.BindBuffer(0x8892, VBOId2); GL1.BufferData(0x8892, (IntPtr)(Vector3.SizeInBytes * color.Length), color, (uint)BufferUsageHint.StreamDraw); GL1.VertexAttribPointer(1, 3, (uint)VertexAttribPointerType.Float, false, Vector3.SizeInBytes, (IntPtr)0); } GL1.DrawArrays((uint)type, 0, color.Length); GL1.BindBuffer(0x8892, 0); }