aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-10-16 07:04:34 +0200
committerdec05eba <dec05eba@protonmail.com>2021-10-16 07:04:34 +0200
commit97f1b1c735775d1e22412bbcf98ef403f9ee2275 (patch)
tree80c2d729a20996d673e7081c4213b09be1076a74 /tests
parent08dcbfa7772149bcdcc0ab660a897853a30103a0 (diff)
Add rectangle and sprite, use pixel coordinates, remote opengl dependency from test
Diffstat (limited to 'tests')
-rw-r--r--tests/main.c37
-rw-r--r--tests/project.conf3
2 files changed, 13 insertions, 27 deletions
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 <mgl/mgl.h>
#include <mgl/window.h>
#include <mgl/graphics/texture.h>
-
-#include <GL/gl.h>
-#include <GL/glu.h>
+#include <mgl/graphics/rectangle.h>
+#include <mgl/graphics/sprite.h>
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"