diff --git a/includes/animations.h b/includes/animations.h index 7532ec7..ffa96b0 100644 --- a/includes/animations.h +++ b/includes/animations.h @@ -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); diff --git a/main.c b/main.c index 1e02b64..2888168 100644 --- a/main.c +++ b/main.c @@ -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}}; diff --git a/shaders/lights.fs b/shaders/manif.fs similarity index 100% rename from shaders/lights.fs rename to shaders/manif.fs diff --git a/shaders/lights.vs b/shaders/manif.vs similarity index 100% rename from shaders/lights.vs rename to shaders/manif.vs diff --git a/src/light.c b/src/light.c deleted file mode 100644 index 571576b..0000000 --- a/src/light.c +++ /dev/null @@ -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("shaders/lights.vs", "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); -} diff --git a/src/manif.c b/src/manif.c new file mode 100644 index 0000000..a3331c6 --- /dev/null +++ b/src/manif.c @@ -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("shaders/lights.vs", "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); +}