Change cube size with music
This commit is contained in:
parent
4ea7bfdfd7
commit
2f407d7cdd
1 changed files with 20 additions and 0 deletions
20
src/cube.c
20
src/cube.c
|
@ -6,6 +6,8 @@ void cube(int etat) {
|
||||||
static GLuint cube = 0, proc_id = 0;
|
static GLuint cube = 0, proc_id = 0;
|
||||||
static GLclampf rgb[3] = { 0 };
|
static GLclampf rgb[3] = { 0 };
|
||||||
|
|
||||||
|
static GLfloat musique[3] = {0};
|
||||||
|
|
||||||
switch(etat) {
|
switch(etat) {
|
||||||
case GL4DH_INIT:
|
case GL4DH_INIT:
|
||||||
for(int i = 0; i < 3; ++i) {
|
for(int i = 0; i < 3; ++i) {
|
||||||
|
@ -39,7 +41,25 @@ void cube(int etat) {
|
||||||
gl4duBindMatrix("modview");
|
gl4duBindMatrix("modview");
|
||||||
gl4duLoadIdentityf();
|
gl4duLoadIdentityf();
|
||||||
|
|
||||||
|
GLfloat s = moyenneMusique() * 5000.f;
|
||||||
|
if(musique[0] != 0 || musique[1] != 0) {
|
||||||
|
s = (s - musique[0]) / (musique[1] - musique[0]) + .5f;
|
||||||
|
if(s > musique[2]) {
|
||||||
|
s -= s / 10.f;
|
||||||
|
}
|
||||||
|
if(s < musique[2]) {
|
||||||
|
s += s / 10.f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
musique[1] = musique[1] < s ? s : musique[1];
|
||||||
|
musique[0] = musique[0] > s ? s : musique[0];
|
||||||
|
musique[2] = s;
|
||||||
|
|
||||||
gl4duPushMatrix();
|
gl4duPushMatrix();
|
||||||
|
if(musique[1] != musique[0]) {
|
||||||
|
gl4duScalef(s, s, s);
|
||||||
|
}
|
||||||
|
printf("Son : %f\n", s);
|
||||||
gl4duRotatef(cube_rotation, 0, 1, 0);
|
gl4duRotatef(cube_rotation, 0, 1, 0);
|
||||||
gl4duSendMatrices();
|
gl4duSendMatrices();
|
||||||
gl4dgDraw(cube);
|
gl4dgDraw(cube);
|
||||||
|
|
Reference in a new issue