diff --git a/OpenGL/Source/Application.cpp b/OpenGL/Source/Application.cpp index 87b80c5..88ba123 100644 --- a/OpenGL/Source/Application.cpp +++ b/OpenGL/Source/Application.cpp @@ -29,17 +29,27 @@ int main() std::cout << glGetString(GL_VERSION) << std::endl; + float positions[6] = { + -0.5f, -0.5f, + 0.0f, 0.5f, + 0.5f, -0.5f + }; + + unsigned int buffer; + glGenBuffers(1, &buffer); + glBindBuffer(GL_ARRAY_BUFFER, buffer); + glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float), positions, GL_STATIC_DRAW); + + glEnableVertexAttribArray(0); + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 2, 0); + /* Loop until the user closes the window */ while (!glfwWindowShouldClose(window)) { /* Render here */ glClear(GL_COLOR_BUFFER_BIT); - glBegin(GL_TRIANGLES); - glVertex2f(-0.5f, -0.5f); - glVertex2f(0.0f, 0.5f); - glVertex2f(0.5f, -0.5f); - glEnd(); + glDrawArrays(GL_TRIANGLES, 0, 3); /* Swap front and back buffers */ glfwSwapBuffers(window);