From 97f1b1c735775d1e22412bbcf98ef403f9ee2275 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Oct 2021 07:04:34 +0200 Subject: Add rectangle and sprite, use pixel coordinates, remote opengl dependency from test --- tests/main.c | 37 +++++++++++++------------------------ tests/project.conf | 3 --- 2 files changed, 13 insertions(+), 27 deletions(-) delete mode 100644 tests/project.conf (limited to 'tests') diff --git a/tests/main.c b/tests/main.c index 7a40d80..0b4c559 100644 --- a/tests/main.c +++ b/tests/main.c @@ -2,40 +2,29 @@ #include #include #include - -#include -#include +#include +#include typedef struct { mgl_texture *texture; } Userdata; static void draw(mgl_window *window, void *userdata) { + mgl_context *context = mgl_get_context(); Userdata *u = userdata; - glBegin(GL_QUADS); - glColor3f(1., 0., 0.); glVertex3f(-.75, -.75, 0.); - glColor3f(0., 1., 0.); glVertex3f( .75, -.75, 0.); - glColor3f(0., 0., 1.); glVertex3f( .75, .75, 0.); - glColor3f(1., 1., 0.); glVertex3f(-.75, .75, 0.); - glEnd(); + mgl_rectangle rect = { + .color = { 1.0f, 0.0f, 0.0f, 1.0f }, + .position = { 0.0f, 0.0f }, + .size = { 100.0f, 500.0f } + }; - glBegin(GL_QUADS); - glColor4f(1., 0., 0., 0.5); glVertex3f(0.1 + -.75, 0.1 + -.75, 0.); - glColor4f(1., 0., 0., 0.5); glVertex3f(0.1 + .75, 0.1 + -.75, 0.); - glColor4f(1., 0., 0., 0.5); glVertex3f(0.1 + .75, 0.1 + .75, 0.); - glColor4f(1., 0., 0., 0.5); glVertex3f(0.1 + -.75, 0.1 + .75, 0.); - glEnd(); + mgl_rectangle_draw(context, &rect); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBindTexture(GL_TEXTURE_2D, u->texture->id); - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f); - glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f + 0.1f, -1.0f, 0.0f); - glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f + 0.1f, -1.0f + 0.1f, 0.0f); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, -1.0f + 0.1f, 0.0f); - glEnd(); - glBindTexture(GL_TEXTURE_2D, 0); + mgl_sprite sprite; + mgl_sprite_init(&sprite, u->texture, 10.0f, 0.0f); + mgl_sprite_set_color(&sprite, 1.0f, 1.0f, 1.0f, 0.5f); + mgl_sprite_draw(context, &sprite); } int main(int argc, char **argv) { diff --git a/tests/project.conf b/tests/project.conf deleted file mode 100644 index 3c15235..0000000 --- a/tests/project.conf +++ /dev/null @@ -1,3 +0,0 @@ -[dependencies] -gl = ">=1" -glu = ">=9" -- cgit v1.2.3