Ejemplo n.º 1
0
int main ()
{
   bcm_host_init();
   printf("Note: ensure you have sufficient gpu_mem configured\n");

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);

   // Setup the model world
   init_model_proj(state);

   // initialise the OGLES texture(s)
   init_textures(state);

   while (!terminate)
   {
      update_model(state);
      redraw_scene(state);
   }
   exit_func();
   return 0;
}
Ejemplo n.º 2
0
static void
render_scene (APP_STATE_T * state)
{
    update_model (state);
    redraw_scene (state);
    TRACE_VC_MEMORY_ONCE_FOR_ID ("after render_scene", gid2);
}
Ejemplo n.º 3
0
int main () {
   OGL_Init();

   while (!terminate) {
      redraw_scene();
   }

   OGL_Quit();
   return 0;
}
Ejemplo n.º 4
0
int _main ()
{
   bcm_host_init();

   // Clear application state
   memset( state, 0, sizeof( *state ) );
      
   // Start OGLES
   init_ogl(state);

   // Setup the model world
   init_model_proj(state);

   // initialise the OGLES texture(s)
   init_textures(state);

   while (!terminate)
   {
      update_model(state);
      redraw_scene(state);
   }
   exit_func();
   return 0;
}
Ejemplo n.º 5
0
int main(int argc, char *argv[])
{	 
	// Set the translation part to be the identity.
	locked_matrix[3][0] = locked_matrix[3][1] = locked_matrix[3][2] = 0;
	locked_matrix[0][3] = locked_matrix[1][3] = locked_matrix[2][3] = 0;
	locked_matrix[3][3] = 1;

	locked_matrix[0][0] = locked_matrix[1][1] = locked_matrix[2][2] = 1;
	locked_matrix[0][1] = locked_matrix[1][0] = locked_matrix[2][0] = locked_matrix[0][2]= locked_matrix[2][1] = locked_matrix[1][2]=0;
	
	memcpy(&final_matrix,locked_matrix[0],sizeof last_matrix);

	try
	{
		
		bcm_host_init();
		opengl_init();
		projection_init();
		textures_init();
		model_board_init();
		printf("AHRS Textures loaded\n");
		fflush(stdout);
		
		uint32_t time_start = 0;
		int missed = 0;
		uint32_t time_fps = 0;
		int fps = 0;
		uint32_t time_delay = 0;
			
		//non blocking sdtin read
		fcntl(STDIN_FILENO, F_SETFL, fcntl(STDIN_FILENO, F_GETFL, 0) | O_NONBLOCK);
	
		while(1)
		{			
	
			time_start += 20;
			uint32_t predicted_delay = time_start - millis(); //calc predicted delay
			if (predicted_delay > 20) predicted_delay = 0; //check for overflow
			if (predicted_delay != 0){
				delay(predicted_delay); 
				time_delay += predicted_delay;
			}else{
				time_start = millis(); //reset timer to now
				printf("AHRS Skipping Idle...\n");
				missed++;
			}

			int count = 1;
			char buffer[100];
			//stdin is line buffered so we can cheat a little bit
			while (count > 0){ // dump entire buffer
				count = read(STDIN_FILENO, buffer, sizeof(buffer));
				if (count > 1){ //ignore blank lines
					buffer[count-1] = '\0'; //replace last char with string ending
					//printf("!%s!\n",buffer);
					//check the line
					int temp[4];
					
					int result = sscanf(buffer,"%d %d %d", &temp[0], &temp[1],  &temp[2]);
					if (result != 3){
						fprintf(stderr, "AHRS Unrecognized input with %d items.\n", result);
					}else{
						acceleration[0] = temp[1];
						acceleration[1] = temp[2];
						acceleration[2] = 0;
						frame = temp[0];
					}
					
				}
			}
			if (state != frame){
				printf("AHRS Entering Mode %d\n",frame);
				state = frame;
				changes++;
			}	
			redraw_scene();

			fps++;
			if (time_fps < millis()){
				printf("AHRS FPS:%d  mis:%d idle:%d%% changes:%d\n",fps,missed,time_delay/10, changes);
				fps = 0;
				time_delay = 0;
				time_fps += 1000;
				if (time_fps < millis()) time_fps = millis()+1000;	
			}		
			
		}
		
		opengl_deinit();
		bcm_host_deinit();
		return 0;
	}
	catch(const std::exception & error)
	{
		std::cerr << "Error: " << error.what() << std::endl;
		exit(9);
	}
}