aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-29 14:29:24 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-29 14:29:24 +0200
commit275e851e8a2b11c2efe7c39787bf331dd3b75272 (patch)
tree940b5144cadd293b5684057f1f5ab0548262d9be /tests
parent5476dd7d21875d68a4d957f441d34eee2a9e2b37 (diff)
Use gl*Pointer and glDrawArrays to render vertices (in mgl_vertices_draw) instead of loop with glBegin/glEnd
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/main.c b/tests/main.c
index 98c68ad..4f29a55 100644
--- a/tests/main.c
+++ b/tests/main.c
@@ -53,6 +53,31 @@ 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_vertex vertices[4] = {
+ (mgl_vertex){
+ .position = {window->cursor_position.x, 0.0f},
+ .texcoords = {0.0f, 0.0f},
+ .color = {0, 255, 0, 255}
+ },
+ (mgl_vertex){
+ .position = {window->cursor_position.x + 100.0f, 0.0f},
+ .texcoords = {0.0f, 0.0f},
+ .color = {0, 255, 0, 255},
+ },
+ (mgl_vertex){
+ .position = {window->cursor_position.x + 100.0f, 100.0f},
+ .texcoords = {0.0f, 0.0f},
+ .color = {0, 255, 0, 255},
+ },
+ (mgl_vertex){
+ .position = {window->cursor_position.x, 100.0f},
+ .texcoords = {0.0f, 0.0f},
+ .color = {0, 255, 0, 255}
+ }
+ };
+
+ mgl_vertices_draw(context, vertices, 4, MGL_PRIMITIVE_QUADS);
}
int main(int argc, char **argv) {