fixed triangle
This commit is contained in:
parent
c71f6537e2
commit
9bea2c1142
10
src/main.cpp
10
src/main.cpp
@ -18,13 +18,18 @@ int main(int argc, char *argv[]){
|
||||
}
|
||||
glfwMakeContextCurrent(window);
|
||||
gladLoadGL();
|
||||
glViewport(0, 0, 640, 480);
|
||||
while(!glfwWindowShouldClose(window)){
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
float vertices[] = {
|
||||
-0.5f, -0.5f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f
|
||||
};
|
||||
unsigned int VBO;
|
||||
unsigned int VAO;
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
glGenBuffers(1, &VBO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
|
||||
@ -86,11 +91,8 @@ int main(int argc, char *argv[]){
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
glEnableVertexAttribArray(0);
|
||||
|
||||
unsigned int VAO;
|
||||
glGenVertexArrays(1, &VAO);
|
||||
glBindVertexArray(VAO);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
|
||||
glfwPollEvents();
|
||||
glfwSwapBuffers(window);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user