-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathf.cpp
More file actions
66 lines (48 loc) · 1.5 KB
/
Copy pathf.cpp
File metadata and controls
66 lines (48 loc) · 1.5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "window.hpp"
#include "scene.hpp"
#include "util/color.hpp"
#include "entities/plane.hpp"
#include "entities/triangle.hpp"
#include "shaders.hpp"
#include "program.hpp"
#include <GLFW/glfw3.h>
static float screen_width, screen_height,
mouse_x, mouse_y;
int main()
{
GLFWwindow *w = initGLFW();
Scene s;
Entity triangle = create_plane(s.m_registry);
add_position(triangle, 200.f, 200.f);
add_scale(triangle, 25.f, 25.f);
glfwSetWindowUserPointer(w, &s);
glfwSetFramebufferSizeCallback(
w, [](GLFWwindow *window, int width, int height){
Scene *s = (Scene*)glfwGetWindowUserPointer(window);
glViewport(0, 0, width, height);
update_orthographic_camera(s->cam, width, height);
Program::setMat4_id(Shaders::get_shader("main"), "vp", s->cam.matrix);
screen_width = width;
screen_height = height;
});
glfwSetCursorPosCallback(
w, [](GLFWwindow *window, double x, double y) {
mouse_x = x, mouse_y = y;
});
glfwSwapInterval(0);
Color clearColor("#202020");
while (!glfwWindowShouldClose(w))
{
update_time();
// printf("dt: %f\n", dt);
// printf("fps: %f\n", 1.f/dt);
// printf("x50: %f y: %f\n", mouse_x, mouse_y);
glClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
glClear(GL_COLOR_BUFFER_BIT);
set_position(triangle, mouse_x, mouse_y);
s.render();
glfwSwapBuffers(w);
glfwPollEvents();
}
return 0;
}