From 2317ee328eb254978e3630fe741a8ebc55d2c1d0 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 19 May 2023 12:30:47 +0200 Subject: [PATCH] initialisation global of quad --- includes/animations.h | 3 +++ main.c | 2 ++ src/animations.c | 9 ++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/includes/animations.h b/includes/animations.h index dd7f891..6a6071f 100644 --- a/includes/animations.h +++ b/includes/animations.h @@ -14,6 +14,9 @@ void manif(int); // Crédits de fin void credits(int); +// Initialisation des transitions +void transitions_init(void); + // Transition zoom void zoom_in(void (*)(int), void (*)(int), Uint32, Uint32, int); diff --git a/main.c b/main.c index 3ed2da8..2318fe4 100644 --- a/main.c +++ b/main.c @@ -42,6 +42,8 @@ static void init(void) { srand((Uint32)time(NULL)); + transitions_init(); + printf("Bienvenue dans la démo API8 !\n"); } diff --git a/src/animations.c b/src/animations.c index bc96d23..a1ac3bf 100644 --- a/src/animations.c +++ b/src/animations.c @@ -3,7 +3,7 @@ /* Mise-à-jour des animations en fonction du son */ static void update_with_audio(void (*)(int), void (*)(int), int); -static GLuint _zoomin_pId = 0, _zoomin_tId = 0, _zoomin_tex[2]; +static GLuint _zoomin_pId = 0, _zoomin_tId = 0, _zoomin_tex[2], _quadId = 0; static void zoomin_init(void); static void zoomin_draw(void (*)(int), void (*)(int), Uint32, Uint32, int); static void zoomin_deinit(void); @@ -18,6 +18,12 @@ static void update_with_audio(void (*a0)(int), void (*a1)(int), int state) { } } +void transitions_init(void) { + if (!_quadId) { + _quadId = gl4dgGenQuadf(); + } +} + void zoom_in(void (*a0)(int), void (*a1)(int), Uint32 t, Uint32 et, int state) { switch (state) { case GL4DH_INIT: @@ -82,6 +88,7 @@ static void zoomin_draw(void (*a0)(int), void (*a1)(int), Uint32 t, Uint32 et, glUniform1f(glGetUniformLocation(_zoomin_pId, "zoomAmount"), (GLfloat)et / (GLfloat)t); glUniform1i(glGetUniformLocation(_zoomin_pId, "tex"), 0); + gl4dgDraw(_quadId); } static void zoomin_deinit(void) {