forked from yahiaetman/OpenGL-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex04_varyings.cpp
More file actions
42 lines (31 loc) · 1.07 KB
/
ex04_varyings.cpp
File metadata and controls
42 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <application.hpp>
#include <shader.hpp>
class VaryingsApplication : public our::Application {
our::ShaderProgram program;
GLuint vertex_array = 0;
our::WindowConfiguration getWindowConfiguration() override {
return { "Varyings", {1280, 720}, false };
}
void onInitialize() override {
program.create();
program.attach("assets/shaders/ex04_varyings/colored_triangle.vert", GL_VERTEX_SHADER);
program.attach("assets/shaders/ex04_varyings/varying_color.frag", GL_FRAGMENT_SHADER);
program.link();
glGenVertexArrays(1, &vertex_array);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
void onDraw(double deltaTime) override {
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(program);
glBindVertexArray(vertex_array);
glDrawArrays(GL_TRIANGLES, 0, 3);
glBindVertexArray(0);
}
void onDestroy() override {
program.destroy();
glDeleteVertexArrays(1, &vertex_array);
}
};
int main(int argc, char** argv) {
return VaryingsApplication().run();
}