aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-03 20:47:32 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-03 20:47:32 +0100
commit61279a1947328df0b8004edebcbe405ab7b1c09e (patch)
tree3b15cfb697f14e7fea40c9bdbeeb8c21ab8e7804 /tests
parentf26a606bf50f7dbe35c79bfa52f2026bd7af3eb8 (diff)
Add mgl_window_get_view instead of giving prev view in set_view
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/main.c b/tests/main.c
index 99a8398..878f8ff 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -55,17 +55,19 @@ static void draw(mgl_window *window, void *userdata) {
mgl_vertex_buffer_set_position(u->vertex_buffer2, (mgl_vec2f){ window->cursor_position.x, window->cursor_position.y + 500 });
mgl_vertex_buffer_draw(context, u->vertex_buffer2, &u->font->texture);
+ mgl_view prev_view;
+ mgl_window_get_view(window, &prev_view);
+
mgl_vec2i view_size = {
.x = 200,
.y = 200
};
-
- mgl_view prev_view;
mgl_view new_view = {
.position = { window->size.x/2 - view_size.x/2, window->size.y/2 - view_size.y/2 },
.size = view_size
};
- mgl_window_set_view(window, &new_view, &prev_view);
+ mgl_window_set_view(window, &new_view);
+
mgl_vertex vertices[4] = {
(mgl_vertex){
.position = {-new_view.position.x + window->cursor_position.x, -new_view.position.y + window->cursor_position.y},
@@ -88,8 +90,9 @@ static void draw(mgl_window *window, void *userdata) {
.color = {255, 255, 0, 255}
}
};
+
mgl_vertices_draw(context, vertices, 4, MGL_PRIMITIVE_QUADS);
- mgl_window_set_view(window, &prev_view, NULL);
+ mgl_window_set_view(window, &prev_view);
}
int main(int argc, char **argv) {