macro bind and load

This commit is contained in:
Mylloon 2023-05-08 14:35:36 +02:00
parent 378398193c
commit 192861f2a9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 11 additions and 7 deletions

View file

@ -1,8 +1,6 @@
#ifndef DEMO_ANIMATION_H
#define DEMO_ANIMATION_H 1
#include <GL4D/gl4duw_SDL2.h>
#include "audio.h"
#include "font.h"
#include "utils.h"

View file

@ -1,9 +1,12 @@
#ifndef DEMO_UTILS_H
#define DEMO_UTILS_H 1
#include <GL4D/gl4dummies.h>
#include <GL4D/gl4duw_SDL2.h>
// Récupère un delta-temps
double get_dt(double *, GLboolean);
// Bind and load a matrix
void bindAndLoadf(const char *name);
#endif

View file

@ -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);

View file

@ -8,3 +8,8 @@ double get_dt(double *t0, GLboolean override_t0) {
return dt;
}
void bindAndLoadf(const char *name) {
gl4duBindMatrix(name);
gl4duLoadIdentityf();
}