From 192861f2a97f4ce3556f35ab445b4ab9d21ed604 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 8 May 2023 14:35:36 +0200 Subject: [PATCH] macro bind and load --- includes/animations.h | 2 -- includes/utils.h | 5 ++++- src/credits.c | 6 ++---- src/utils.c | 5 +++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/includes/animations.h b/includes/animations.h index 68659e3..5963fa7 100644 --- a/includes/animations.h +++ b/includes/animations.h @@ -1,8 +1,6 @@ #ifndef DEMO_ANIMATION_H #define DEMO_ANIMATION_H 1 -#include - #include "audio.h" #include "font.h" #include "utils.h" diff --git a/includes/utils.h b/includes/utils.h index 286d8d5..ca33eb7 100644 --- a/includes/utils.h +++ b/includes/utils.h @@ -1,9 +1,12 @@ #ifndef DEMO_UTILS_H #define DEMO_UTILS_H 1 -#include +#include // Récupère un delta-temps double get_dt(double *, GLboolean); +// Bind and load a matrix +void bindAndLoadf(const char *name); + #endif diff --git a/src/credits.c b/src/credits.c index 949ab31..0e2e23a 100644 --- a/src/credits.c +++ b/src/credits.c @@ -67,12 +67,10 @@ static void draw(void) { GLfloat dt = .25f * (GLfloat)get_dt(&t0, GL_FALSE) - 1.1f; GLfloat ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1]; - gl4duBindMatrix(matrix_proj); - gl4duLoadIdentityf(); + bindAndLoadf(matrix_proj); gl4duFrustumf(-ratio, ratio, -1, 1, 2, 100); - gl4duBindMatrix(matrix_modview); - gl4duLoadIdentityf(); + bindAndLoadf(matrix_modview); gl4duTranslatef(0.f, dt, -2.f); glActiveTexture(GL_TEXTURE0); diff --git a/src/utils.c b/src/utils.c index e9cae7b..f07416d 100644 --- a/src/utils.c +++ b/src/utils.c @@ -8,3 +8,8 @@ double get_dt(double *t0, GLboolean override_t0) { return dt; } + +void bindAndLoadf(const char *name) { + gl4duBindMatrix(name); + gl4duLoadIdentityf(); +}