refactoring
This commit is contained in:
parent
61ec04c349
commit
5c015f183d
19
window.c
19
window.c
@ -53,7 +53,6 @@ static surface_t * _moon[18] = {NULL, NULL, NULL, NULL,
|
||||
static int _use_tex = 1, _use_color = 0, _use_lighting = 1;
|
||||
|
||||
typedef struct cam_t cam_t;
|
||||
|
||||
// camera structure, borrowed from sample3d_01-1.6 of GL4Dummies samples.
|
||||
struct cam_t {
|
||||
float x, y, z;
|
||||
@ -72,13 +71,13 @@ static int _wW = 1200, _wH = 900;
|
||||
static int _xm = 600, _ym = 450;
|
||||
|
||||
static int _pause = 0; // boolean value for the pause.
|
||||
static float _s = 1.0f; // multiplier for angle (for speeding planets movement and rotation).
|
||||
static int _movement = 1; // boolean to allow movement.
|
||||
static int _p = -1; // the object (sun, planets, pluto) number to move.
|
||||
static float _a = 0.0f; // rotation angle.
|
||||
static int _overview = 0; // boolean to toggle overview (view from the top).
|
||||
static int _p = -1; // the object (sun, planets, pluto) number to move.
|
||||
static float _s = 1.0f; // multiplier for angle (for speeding planets movement and rotation).
|
||||
static float _a = 0.0f; // rotation angle.
|
||||
|
||||
static Mix_Chunk * bsound = NULL;
|
||||
static Mix_Chunk * bsound = NULL; // background sound.
|
||||
|
||||
/*!\brief paramètre l'application et lance la boucle infinie. */
|
||||
int main(int argc, char ** argv) {
|
||||
@ -119,8 +118,11 @@ int main(int argc, char ** argv) {
|
||||
* utilisées dans ce code */
|
||||
void init(void) {
|
||||
uint id[9], sun_id, i, moon_id[18];
|
||||
int flags = MIX_INIT_MP3;
|
||||
int initted = Mix_Init(flags);
|
||||
int flags, initted;
|
||||
|
||||
flags = MIX_INIT_MP3;
|
||||
initted = Mix_Init(flags);
|
||||
|
||||
if ((initted & flags) != flags) {
|
||||
fprintf(stderr, "Mix_Init: Failed to init required mp3 support!\n");
|
||||
fprintf(stderr, "Mix_Init: %s\n,", Mix_GetError());
|
||||
@ -134,7 +136,6 @@ void init(void) {
|
||||
bsound = Mix_LoadWAV("./space.wav");
|
||||
if (Mix_PlayChannel(-1, bsound, 0) < 0)
|
||||
fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError());
|
||||
|
||||
|
||||
// create all spheres.
|
||||
_sun = mkSphere(12, 12); /*ça fait 12x12x2 triangles !*/
|
||||
@ -145,7 +146,6 @@ void init(void) {
|
||||
_planet[i] = mkSphere(12, 12);
|
||||
}
|
||||
|
||||
|
||||
// get all textures.
|
||||
sun_id = getTexFromBMP("images/2k-sun.bmp");
|
||||
id[0] = getTexFromBMP("images/2k-mercury.bmp");
|
||||
@ -527,6 +527,7 @@ void draw(void) {
|
||||
gl4dpScreenHasChanged();
|
||||
/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/
|
||||
gl4dpUpdateScreen(NULL);
|
||||
|
||||
if (!_pause){
|
||||
_a += ((360.0 * dt) / 60) * _s; // 360 in 1 minute so 1 day = 1 min
|
||||
r += ((360.0 * dt) / 60) * _s; // 360 in 1 minute so 1 day = 1 min
|
||||
|
Loading…
Reference in New Issue
Block a user