use functions
This commit is contained in:
parent
eadb04f159
commit
a736dca50e
2 changed files with 68 additions and 54 deletions
|
@ -1,17 +1,22 @@
|
|||
#include "../includes/animations.h"
|
||||
|
||||
static void init();
|
||||
static void draw();
|
||||
|
||||
void credits(int state) {
|
||||
switch (state) {
|
||||
case GL4DH_INIT:
|
||||
init();
|
||||
break;
|
||||
|
||||
case GL4DH_DRAW:
|
||||
break;
|
||||
|
||||
case GL4DH_FREE:
|
||||
draw();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void init() {}
|
||||
static void draw() {}
|
||||
|
|
47
src/light.c
47
src/light.c
|
@ -1,15 +1,29 @@
|
|||
#include "../includes/animations.h"
|
||||
|
||||
void cube(int, int);
|
||||
static GLuint _pId = 0;
|
||||
static GLuint _quadId = 0;
|
||||
|
||||
static void init();
|
||||
static void draw();
|
||||
|
||||
void lights(int state) {
|
||||
static GLuint quadId = 0;
|
||||
static GLuint pId = 0;
|
||||
|
||||
switch (state) {
|
||||
case GL4DH_INIT:
|
||||
quadId = gl4dgGenQuadf();
|
||||
pId = gl4duCreateProgram("<vs>shaders/lights.vs", "<fs>shaders/lights.fs",
|
||||
init();
|
||||
break;
|
||||
|
||||
case GL4DH_DRAW:
|
||||
draw();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void init() {
|
||||
_quadId = gl4dgGenQuadf();
|
||||
_pId = gl4duCreateProgram("<vs>shaders/lights.vs", "<fs>shaders/lights.fs",
|
||||
NULL);
|
||||
|
||||
gl4duGenMatrix(GL_FLOAT, "proj");
|
||||
|
@ -17,9 +31,9 @@ void lights(int state) {
|
|||
gl4duGenMatrix(GL_FLOAT, "view");
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
break;
|
||||
}
|
||||
|
||||
case GL4DH_DRAW:
|
||||
static void draw() {
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -35,7 +49,7 @@ void lights(int state) {
|
|||
|
||||
// Setup
|
||||
gl4duBindMatrix("proj");
|
||||
gl4duLoadIdentityf(); // TODO: ça bug??
|
||||
gl4duLoadIdentityf();
|
||||
gl4duFrustumf(-ratio, ratio, -1, 1, 2, 100);
|
||||
|
||||
// Scene
|
||||
|
@ -49,18 +63,13 @@ void lights(int state) {
|
|||
gl4duBindMatrix("mod");
|
||||
gl4duLoadIdentityf();
|
||||
|
||||
glUseProgram(pId);
|
||||
glUseProgram(_pId);
|
||||
gl4duSendMatrices();
|
||||
|
||||
glUniform4fv(glGetUniformLocation(pId, "scolor"), 1, rouge);
|
||||
glUniform4fv(glGetUniformLocation(pId, "lcolor"), 1, blanc);
|
||||
glUniform4fv(glGetUniformLocation(pId, "lumpos"), 1, lumpos);
|
||||
gl4dgDraw(quadId);
|
||||
glUniform4fv(glGetUniformLocation(_pId, "scolor"), 1, rouge);
|
||||
glUniform4fv(glGetUniformLocation(_pId, "lcolor"), 1, blanc);
|
||||
glUniform4fv(glGetUniformLocation(_pId, "lumpos"), 1, lumpos);
|
||||
gl4dgDraw(_quadId);
|
||||
|
||||
glUseProgram(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue