formating + switch off overview withh 1-9 keybindings

This commit is contained in:
Volodymyr Patuta 2021-01-01 15:13:09 +01:00
parent 57726d85d1
commit cf7b27ef0c
1 changed files with 48 additions and 31 deletions

View File

@ -87,7 +87,7 @@ int main(int argc, char ** argv) {
exit(3);
}
/* tentative de création d'une fenêtre pour GL4Dummies */
if(!gl4duwCreateWindow(argc, argv, /* args du programme */
if (!gl4duwCreateWindow(argc, argv, /* args du programme */
"Solar System", /* titre */
10, 10, _wW, _wH, /* x, y, largeur, heuteur */
GL4DW_SHOWN) /* état visible */) {
@ -140,7 +140,7 @@ void init(void) {
// create all spheres.
_sun = mkSphere(12, 12); /*ça fait 12x12x2 triangles !*/
for(i = 0; i < 18; ++i) {
for (i = 0; i < 18; ++i) {
_moon[i] = mkSphere(12, 12);
if (i < 9)
_planet[i] = mkSphere(12, 12);
@ -180,24 +180,24 @@ void init(void) {
// set texture to an object id and set all options.
setTexId(_sun, sun_id);
if(_use_tex)
if (_use_tex)
enableSurfaceOption(_sun, SO_USE_TEXTURE);
if(_use_lighting)
if (_use_lighting)
enableSurfaceOption(_sun, SO_USE_LIGHTING);
disableSurfaceOption(_sun, SO_USE_COLOR);
for(i = 0; i < 18; ++i) {
for (i = 0; i < 18; ++i) {
setTexId(_moon[i], moon_id[i]);
disableSurfaceOption(_moon[i], SO_USE_COLOR);
if(_use_tex)
if (_use_tex)
enableSurfaceOption(_moon[i], SO_USE_TEXTURE);
if(_use_lighting)
if (_use_lighting)
enableSurfaceOption(_moon[i], SO_USE_LIGHTING);
if (i < 9) {
setTexId(_planet[i], id[i]);
disableSurfaceOption(_planet[i], SO_USE_COLOR);
if(_use_tex)
if (_use_tex)
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
if(_use_lighting)
if (_use_lighting)
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
}
}
@ -445,11 +445,11 @@ void key(int keycode) {
switch(keycode) {
case GL4DK_UP:
if (_movement)
_cam.y += 5;
_cam.y += step;
break;
case GL4DK_DOWN:
if (_movement)
_cam.y -= 5;
_cam.y -= step;
break;
case GL4DK_RIGHT:
if (!_pause)
@ -519,6 +519,7 @@ void key(int keycode) {
_p = -1;
_pause = 0;
_movement = 1;
_overview = 0;
break;
case GL4DK_q:
exit(0);
@ -527,6 +528,7 @@ void key(int keycode) {
_p = 0;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -535,6 +537,7 @@ void key(int keycode) {
_p = 1;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -543,6 +546,7 @@ void key(int keycode) {
_p = 2;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -551,6 +555,7 @@ void key(int keycode) {
_p = 3;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -559,6 +564,7 @@ void key(int keycode) {
_p = 4;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -567,6 +573,7 @@ void key(int keycode) {
_p = 5;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -575,6 +582,7 @@ void key(int keycode) {
_p = 6;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -583,6 +591,7 @@ void key(int keycode) {
_p = 7;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -591,6 +600,7 @@ void key(int keycode) {
_p = 8;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -599,6 +609,7 @@ void key(int keycode) {
_p = 9;
/*_pause = 1;*/
_movement = 0;
_overview = 0;
_cam.x = (int)_cam.x;
_cam.y = (int)_cam.y;
_cam.z = (int)_cam.z;
@ -607,48 +618,54 @@ void key(int keycode) {
_use_tex = !_use_tex;
if(_use_tex) {
enableSurfaceOption(_sun, SO_USE_TEXTURE);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
enableSurfaceOption(_moon[i], SO_USE_TEXTURE);
for(i = 0; i < 9; ++i)
if (i < 9)
enableSurfaceOption(_planet[i], SO_USE_TEXTURE);
}
} else {
disableSurfaceOption(_sun, SO_USE_TEXTURE);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
disableSurfaceOption(_moon[i], SO_USE_TEXTURE);
for(i = 0; i < 9; ++i)
disableSurfaceOption(_planet[i], SO_USE_TEXTURE);
if (i < 9)
disableSurfaceOption(_planet[i], SO_USE_TEXTURE);
}
}
break;
case GL4DK_c: /* 'c' utiliser la couleur */
_use_color = !_use_color;
if(_use_color) {
enableSurfaceOption(_sun, SO_USE_COLOR);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
enableSurfaceOption(_moon[i], SO_USE_COLOR);
for(i = 0; i < 9; ++i)
enableSurfaceOption(_planet[i], SO_USE_COLOR);
if (i < 9)
enableSurfaceOption(_planet[i], SO_USE_COLOR);
}
} else {
disableSurfaceOption(_sun, SO_USE_COLOR);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
disableSurfaceOption(_moon[i], SO_USE_COLOR);
for(i = 0; i < 9; ++i)
if (i < 9)
disableSurfaceOption(_planet[i], SO_USE_COLOR);
}
}
break;
case GL4DK_l: /* 'l' utiliser l'ombrage par la méthode Gouraud */
_use_lighting = !_use_lighting;
if(_use_lighting) {
enableSurfaceOption(_sun, SO_USE_LIGHTING);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
enableSurfaceOption(_moon[i], SO_USE_LIGHTING);
for(i = 0; i < 9; ++i)
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
if (i < 9)
enableSurfaceOption(_planet[i], SO_USE_LIGHTING);
}
} else {
disableSurfaceOption(_sun, SO_USE_LIGHTING);
for(i = 0; i < 18; ++i)
for (i = 0; i < 18; ++i) {
disableSurfaceOption(_moon[i], SO_USE_LIGHTING);
for(i = 0; i < 9; ++i)
disableSurfaceOption(_planet[i], SO_USE_LIGHTING);
if (i < 9)
disableSurfaceOption(_planet[i], SO_USE_LIGHTING);
}
}
break;
default: break;
@ -682,17 +699,17 @@ void sortie(void) {
int i;
Mix_CloseAudio();
Mix_Quit();
if(_sun) {
if (_sun) {
freeSurface(_sun);
_sun = NULL;
}
for(i = 0; i < 18; ++i) {
for (i = 0; i < 18; ++i) {
if(_moon[i]){
freeSurface(_moon[i]);
_moon[i] = NULL;
}
if(i < 9) {
if(_planet[i]){
if (i < 9) {
if (_planet[i]){
freeSurface(_planet[i]);
_planet[i] = NULL;
}