rename light to manif

This commit is contained in:
Mylloon 2023-05-08 09:07:48 +02:00
parent 7b04ae7797
commit 5c25c2d070
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
6 changed files with 44 additions and 79 deletions

View file

@ -9,8 +9,8 @@
// Dimensions de la fenêtre
extern GLuint _dims[];
// Lumière
void lights(int);
// Scène de manifestation
void manif(int);
// Crédits de fin
void credits(int);

2
main.c
View file

@ -28,7 +28,7 @@ int main(int argc, char *argv[]) {
initMusic(_ambiance, "audio/ambiance.mid");
// Animations
GL4DHanime animations[] = {{7000, lights, NULL, NULL},
GL4DHanime animations[] = {{10000, manif, NULL, NULL},
{9000, credits, NULL, NULL},
{0, NULL, NULL, NULL}};

View file

@ -1,76 +0,0 @@
#include "../includes/animations.h"
static GLuint _pId = 0;
static GLuint _quadId = 0;
static void init(void);
static void draw(void);
void lights(int state) {
switch (state) {
case GL4DH_INIT:
init();
break;
case GL4DH_DRAW:
draw();
break;
default:
break;
}
}
static void init(void) {
_quadId = gl4dgGenQuadf();
_pId = gl4duCreateProgram("<vs>shaders/lights.vs", "<fs>shaders/lights.fs",
NULL);
gl4duGenMatrix(GL_FLOAT, "proj");
gl4duGenMatrix(GL_FLOAT, "mod");
gl4duGenMatrix(GL_FLOAT, "view");
glEnable(GL_DEPTH_TEST);
}
static void draw(void) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
static GLdouble lumloc = 0.;
// clang-format off
GLfloat rouge[] = {1.f, 0.f, 0.f, 1.f},
blanc[] = {1.f, 1.f, 1.f, 1.f},
lumpos0[] = {4.f * (float)sin(lumloc), 0.f, 1.1f, 1.f},
lumpos[4],
*mat,
ratio = (GLfloat)_dims[0] / (GLfloat)_dims[1];
// clang-format on
// Setup
gl4duBindMatrix("proj");
gl4duLoadIdentityf();
gl4duFrustumf(-ratio, ratio, -1, 1, 2, 100);
// Scene
gl4duBindMatrix("view");
gl4duLoadIdentityf();
gl4duLookAtf(0, 0, 4.0f, 0, 0, 0, 0.0f, 1.0f, 0);
mat = (GLfloat *)gl4duGetMatrixData();
MMAT4XVEC4(lumpos, mat, lumpos0);
gl4duBindMatrix("mod");
gl4duLoadIdentityf();
glUseProgram(_pId);
gl4duSendMatrices();
glUniform4fv(glGetUniformLocation(_pId, "scolor"), 1, rouge);
glUniform4fv(glGetUniformLocation(_pId, "lcolor"), 1, blanc);
glUniform4fv(glGetUniformLocation(_pId, "lumpos"), 1, lumpos);
gl4dgDraw(_quadId);
glUseProgram(0);
}

41
src/manif.c Normal file
View file

@ -0,0 +1,41 @@
#include "../includes/animations.h"
static GLuint _pId = 0;
static void init(void);
static void draw(void);
void manif(int state) {
switch (state) {
case GL4DH_INIT:
init();
break;
case GL4DH_DRAW:
draw();
break;
default:
break;
}
}
static void init(void) {
_pId = gl4duCreateProgram("<vs>shaders/lights.vs", "<fs>shaders/lights.fs",
NULL);
gl4duGenMatrix(GL_FLOAT, "proj");
gl4duGenMatrix(GL_FLOAT, "mod");
gl4duGenMatrix(GL_FLOAT, "view");
glEnable(GL_DEPTH_TEST);
}
static void draw(void) {
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* */
glUseProgram(0);
}