factorize code
This commit is contained in:
parent
26aeb4fd81
commit
1c885c4819
2 changed files with 10 additions and 14 deletions
12
src/cube.c
12
src/cube.c
|
@ -5,15 +5,13 @@
|
|||
void cube(int etat) {
|
||||
static GLuint cube = 0, proc_id = 0;
|
||||
|
||||
static GLclampf r = 0,
|
||||
g = 0,
|
||||
b = 0;
|
||||
static GLclampf rgb[3] = { 0 };
|
||||
|
||||
switch(etat) {
|
||||
case GL4DH_INIT:
|
||||
r = rand() / (float)RAND_MAX;
|
||||
g = rand() / (float)RAND_MAX;
|
||||
b = rand() / (float)RAND_MAX;
|
||||
for(int i = 0; i < 3; ++i) {
|
||||
rgb[i] = rand() / (float)RAND_MAX;
|
||||
}
|
||||
|
||||
cube = gl4dgGenCubef();
|
||||
proc_id = gl4duCreateProgram("<vs>shaders/cube.vs", "<fs>shaders/cube.fs", NULL);
|
||||
|
@ -44,7 +42,7 @@ void cube(int etat) {
|
|||
break;
|
||||
|
||||
case GL4DH_DRAW:
|
||||
glClearColor(r, g, b, 1.f);
|
||||
glClearColor(rgb[0], rgb[1], rgb[2], 1.f);
|
||||
static GLfloat cube_rotation = 0;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glUseProgram(proc_id);
|
||||
|
|
12
src/cube2.c
12
src/cube2.c
|
@ -5,15 +5,13 @@
|
|||
void cube2(int etat) {
|
||||
static GLuint cube = 0, proc_id = 0;
|
||||
|
||||
static GLclampf r = 0,
|
||||
g = 0,
|
||||
b = 0;
|
||||
static GLclampf rgb[3] = { 0 };
|
||||
|
||||
switch(etat) {
|
||||
case GL4DH_INIT:
|
||||
r = rand() / (float)RAND_MAX;
|
||||
g = rand() / (float)RAND_MAX;
|
||||
b = rand() / (float)RAND_MAX;
|
||||
for(int i = 0; i < 3; ++i) {
|
||||
rgb[i] = rand() / (float)RAND_MAX;
|
||||
}
|
||||
|
||||
cube = gl4dgGenCubef();
|
||||
proc_id = gl4duCreateProgram("<vs>shaders/cube.vs", "<fs>shaders/cube.fs", NULL);
|
||||
|
@ -44,7 +42,7 @@ void cube2(int etat) {
|
|||
break;
|
||||
|
||||
case GL4DH_DRAW:
|
||||
glClearColor(r, g, b, 1.f);
|
||||
glClearColor(rgb[0], rgb[1], rgb[2], 1.f);
|
||||
static GLfloat cube_rotation = 0;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glUseProgram(proc_id);
|
||||
|
|
Reference in a new issue