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; | static int _use_tex = 1, _use_color = 0, _use_lighting = 1; | ||||||
| 
 | 
 | ||||||
| typedef struct cam_t cam_t; | typedef struct cam_t cam_t; | ||||||
| 
 |  | ||||||
| // camera structure, borrowed from sample3d_01-1.6 of GL4Dummies samples.
 | // camera structure, borrowed from sample3d_01-1.6 of GL4Dummies samples.
 | ||||||
| struct cam_t { | struct cam_t { | ||||||
| 	float x, y, z; | 	float x, y, z; | ||||||
| @ -72,13 +71,13 @@ static int _wW = 1200, _wH = 900; | |||||||
| static int _xm = 600, _ym = 450; | static int _xm = 600, _ym = 450; | ||||||
| 
 | 
 | ||||||
| static int _pause = 0; // boolean value for the pause.
 | 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 _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 _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. */ | /*!\brief paramètre l'application et lance la boucle infinie. */ | ||||||
| int main(int argc, char ** argv) { | int main(int argc, char ** argv) { | ||||||
| @ -119,8 +118,11 @@ int main(int argc, char ** argv) { | |||||||
|  * utilisées dans ce code */ |  * utilisées dans ce code */ | ||||||
| void init(void) { | void init(void) { | ||||||
| 	uint id[9], sun_id, i, moon_id[18]; | 	uint id[9], sun_id, i, moon_id[18]; | ||||||
| 	int flags = MIX_INIT_MP3; | 	int flags, initted; | ||||||
| 	int initted = Mix_Init(flags); | 
 | ||||||
|  | 	flags 	= MIX_INIT_MP3; | ||||||
|  | 	initted = Mix_Init(flags); | ||||||
|  | 
 | ||||||
| 	if ((initted & flags) != flags) { | 	if ((initted & flags) != flags) { | ||||||
| 		fprintf(stderr, "Mix_Init: Failed to init required mp3 support!\n"); | 		fprintf(stderr, "Mix_Init: Failed to init required mp3 support!\n"); | ||||||
| 		fprintf(stderr, "Mix_Init: %s\n,", Mix_GetError()); | 		fprintf(stderr, "Mix_Init: %s\n,", Mix_GetError()); | ||||||
| @ -135,7 +137,6 @@ void init(void) { | |||||||
| 	if (Mix_PlayChannel(-1, bsound, 0) < 0) | 	if (Mix_PlayChannel(-1, bsound, 0) < 0) | ||||||
| 		fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError()); | 		fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError()); | ||||||
| 	 | 	 | ||||||
| 	 |  | ||||||
| 	// create all spheres.
 | 	// create all spheres.
 | ||||||
| 	_sun = mkSphere(12, 12);  /*ça fait 12x12x2 triangles !*/ | 	_sun = mkSphere(12, 12);  /*ça fait 12x12x2 triangles !*/ | ||||||
| 	for(i = 0; i < 18; ++i) { | 	for(i = 0; i < 18; ++i) { | ||||||
| @ -145,7 +146,6 @@ void init(void) { | |||||||
| 		_planet[i] = mkSphere(12, 12); | 		_planet[i] = mkSphere(12, 12); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	// get all textures.
 | 	// get all textures.
 | ||||||
| 	sun_id 	= getTexFromBMP("images/2k-sun.bmp"); | 	sun_id 	= getTexFromBMP("images/2k-sun.bmp"); | ||||||
| 	id[0] 	= getTexFromBMP("images/2k-mercury.bmp"); | 	id[0] 	= getTexFromBMP("images/2k-mercury.bmp"); | ||||||
| @ -527,6 +527,7 @@ void draw(void) { | |||||||
| 	gl4dpScreenHasChanged(); | 	gl4dpScreenHasChanged(); | ||||||
| 	/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/ | 	/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/ | ||||||
| 	gl4dpUpdateScreen(NULL); | 	gl4dpUpdateScreen(NULL); | ||||||
|  | 
 | ||||||
| 	if (!_pause){ | 	if (!_pause){ | ||||||
| 		_a += ((360.0 * dt) / 60) * _s; // 360 in 1 minute so 1 day = 1 min
 | 		_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
 | 		r += ((360.0 * dt) / 60) * _s; // 360 in 1 minute so 1 day = 1 min
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Volodymyr Patuta
						Volodymyr Patuta