public void render(RawModel model) { Gl.BindVertexArray(model.vaoID); Gl.EnableVertexAttribArray(0); Gl.DrawArrays(PrimitiveType.Triangles, 0, model.vertexCount); Gl.DisableVertexAttribArray(0); Gl.BindVertexArray(0); }
static void Main(string[] args) { // Initialize OpenGL Gl.Initialize(); // If the library isn't in the environment path we need to set it Glfw.ConfigureNativesDirectory("..\\..\\libs"); // Initialize the GLFW if (!Glfw.Init()) { Environment.Exit(-1); } // Create a windowed mode window and its OpenGL context var window = Glfw.CreateWindow(width, height, "OpenGL/Glfw"); if (!window) { Glfw.Terminate(); Environment.Exit(-1); } // Make the window's context current Glfw.MakeContextCurrent(window); Renderer renderer = new Renderer(); Loader loader = new Loader(); float[] vertices = { -0.5f, 0.5f, 0f, -0.5f, -0.5f, 0f, 0.5f, -0.5f, 0f, 0.5f, -0.5f, 0f, 0.5f, 0.5f, 0f, -0.5f, 0.5f, 0f }; RawModel model = loader.LoadToVao(vertices); // Loop until the user closes the window while (!Glfw.WindowShouldClose(window)) { // Render here renderer.prepare(); renderer.render(model); //Swap front and back buffers Glfw.SwapBuffers(window); // Poll for and process events Glfw.PollEvents(); } // clean memory loader.CleanUp(); // terminate program Glfw.Terminate(); }