Ejemplo n.º 1
0
////////////////////////////////////////////////////////////////////////////////
// run function
////////////////////////////////////////////////////////////////////////////////
void run(Config *config, Thread *receiver, Queue<AVPacket> *rgb_packet_queue,
		Queue<AVPacket> *depth_packet_queue, int argc, char **argv)
{
	/* Declarations */
	int rgb_width, rgb_height, depth_width, depth_height;
	Decoder *rgb_decoder, *depth_decoder;
	Scaler<uint16_t> *scaler;
	Queue<Image> *rgb_image_queue, *depth_scaler_queue, *depth_image_queue;
	pthread_t receiver_thread, rgb_decoder_thread, depth_decoder_thread,
			scaler_thread;

	/* Initialize the queues */
	rgb_image_queue = new Queue<Image>(1000);
	depth_image_queue = new Queue<Image>(1000);
	depth_scaler_queue = new Queue<Image>(10);

	if (!rgb_image_queue || !depth_image_queue || !depth_scaler_queue)
	{
		printf("[run] Could not allocate queues.\n");
		exit(-1);
	}

	/* Initialize window constants */
//	rgb_width = 2 * config->rgb_width;
//	rgb_height = 2 * config->rgb_height;
//	depth_width = 2 * config->depth_width;
//	depth_height = 2 * config->depth_height;
	rgb_width = config->rgb_width;
	rgb_height = config->rgb_height;
	depth_width = config->depth_width;
	depth_height = config->depth_height;

	/* Initialize the decoders */
	rgb_decoder = new Decoder(rgb_packet_queue, config->rgb_width,
			config->rgb_height, config->rgb_codec_pix_fmt, config->rgb_codec_ID,
			rgb_image_queue, rgb_width, rgb_height, AV_PIX_FMT_RGB24);
	depth_decoder = new Decoder(depth_packet_queue, config->depth_width,
			config->depth_height, config->depth_codec_pix_fmt,
			config->depth_codec_ID, depth_scaler_queue, depth_width,
			depth_height, AV_PIX_FMT_GRAY16LE);

	/* Initialize the scaler */
	scaler = new Scaler<uint16_t>(depth_scaler_queue, 0, config->depth_res,
			depth_image_queue, 0, (int) pow(2, 16) - 1);

	/* Init glut / viewer */
	init_glut(rgb_image_queue, rgb_width, rgb_height, depth_image_queue,
			depth_width, depth_height, argc, argv);

	/* Run everything */
	printf("run everything...\n");

	pthread_create(&rgb_decoder_thread, NULL, &thread_func,
			(void*) rgb_decoder);
	pthread_create(&depth_decoder_thread, NULL, &thread_func,
			(void*) depth_decoder);
	pthread_create(&scaler_thread, NULL, &thread_func, (void*) scaler);
	pthread_create(&receiver_thread, NULL, &thread_func, (void*) receiver);
	glutMainLoop();
}
Ejemplo n.º 2
0
// Assume that argv[1] has filename to make life nicer.
int
main (int argc, char* argv[])
{
  init_glut (argc, argv);

  glutMainLoop ();

  return 0;
}
Ejemplo n.º 3
0
 void segment(int argc, char**argv)
 {
   // start the segmentation
   std::thread(segment_iteration_circles).detach();
   std::thread(segment_iteration_paths).detach();
   std::thread(segment_iteration_detect).detach();
   
   // start the glut
   init_glut(argc, argv, segment_iteration_caputre);
   glutMainLoop();    
 }  
Ejemplo n.º 4
0
Archivo: main.c Proyecto: cheque/s3d
int main(int argc, char **argv)
{
  Scene *s;

  init_lang();
  scn = scene_read();

  init_glut("GPU", scn);
  glutMainLoop();
  close_gl(scn);
  
  exit(0);
}
Ejemplo n.º 5
0
// Assume that argv[1] has filename to make life nicer.
int
main (int argc, char* argv[])
{
  m = new mesh::mesh (argv[1]);

  init_glut (argc, argv);

  glutMainLoop ();

  // Free our memory!
  delete m;

  return 0;
}
struct piglit_gl_framework*
piglit_glut_framework_create(const struct piglit_gl_test_config *test_config)
{
	bool ok = true;

#if !defined(GLUT_CORE_PROFILE) && \
    (!defined(GLUT_MACOSX_IMPLEMENTATION) || GLUT_MACOSX_IMPLEMENTATION < 4)
	if (!test_config->supports_gl_compat_version) {
		printf("GLUT can create only GL compatibility contexts, "
			"which the test does not support running under.\n");
		piglit_report_result(PIGLIT_SKIP);
	}
#endif

	if (test_config->window_samples > 1) {
		printf("GLUT doesn't support MSAA visuals.\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	ok = piglit_gl_framework_init(&glut_fw.gl_fw, test_config);
	if (!ok)
		return NULL;

	init_glut();

        /* Check if we actually have a core profile */
	{
		int actual_version = piglit_get_gl_version();
		if (actual_version >= 31 &&
		    !piglit_is_extension_supported("GL_ARB_compatibility"))
			piglit_is_core_profile = true;
	}

	if (!check_gl_version(test_config))
		piglit_report_result(PIGLIT_SKIP);

	glut_fw.gl_fw.swap_buffers = swap_buffers;
	glut_fw.gl_fw.run_test = run_test;
	glut_fw.gl_fw.post_redisplay = post_redisplay;
	glut_fw.gl_fw.set_keyboard_func = set_keyboard_func;
	glut_fw.gl_fw.set_reshape_func = set_reshape_func;
	glut_fw.gl_fw.destroy = destroy;

	return &glut_fw.gl_fw;
}
Ejemplo n.º 7
0
/* view thread function */
static void* view_thread_func(void* param)
{
  ThreadInfo* thread_info = (ThreadInfo*)param;

  //initize GLUT
  init_glut();

  //run message loop
  while(1)
  {
    //handle glut messages
    glutMainLoopEvent();

    //check whether to quit
    if (thread_info->should_quit)
      break;

    //handle CTC
    view_sync.enter();
    if (ctc_function != NULL)
    {
      ctc_result = ctc_function(ctc_param);
      ctc_function = NULL;
      view_sync.signal_cross_thread_call();
    }
    view_sync.leave();

    //wait for 10 ms
#ifdef WIN32
    Sleep(10);
#else
    usleep(10*1000);
#endif
  }

  //cleanup
  shutdown_glut();

  //cleanup
  delete thread_info;
  return NULL;
}
Ejemplo n.º 8
0
int main( int argc, char * * argv ){
	
	glutInit( &argc, argv );
	glutInitWindowSize( window_width, window_height );
	glutInitWindowPosition( 0, 0 );
	glutInitDisplayMode( GLUT_DOUBLE );
	glutCreateWindow( "shortest path" );

	srand( 2  );

	init_glut( );	
	glutDisplayFunc( display_callback );
	glutReshapeFunc( resize_callback );	
	glutPassiveMotionFunc( mouse_motion_callback );
	glutMouseFunc( mouse_callback );

	glutMainLoop();

	return 0;
}
Ejemplo n.º 9
0
int main(int argc, char* argv[])
{
  if (argc < 3)
  {
    printf("Please input as this format: zoom-to-fit <function> <domain> \n");
    return -1;
  }

  // Define dimensions of the various tested views.
  init_glut();
  int screen_width = glutGet(GLUT_SCREEN_WIDTH);
  int screen_height = glutGet(GLUT_SCREEN_HEIGHT);
  int rect_size = std::min(screen_height, screen_width);

  int test_dims[][2] = {
    {rect_size / 6, rect_size / 6},
    {rect_size, rect_size},
    {screen_width / 6, screen_height},
    {screen_width / 2, screen_height},
    {screen_width, screen_height / 6},
    {screen_width, screen_height / 2},
  };

  // Window titles for the selected function.
  const std::string titles[5] = {
    "z = c",
    "z = tan(50)*y",
    "Cuboid-like function",
    "Function with a large range",
    "z = x^2 + y^2"
  };
  std::string title;

  // True to determine the vertical limits from function values.
  bool auto_range = true;      
  // Custom vertical limits.
  double range_min, range_max; 

  // Function for inspection.
  Solution fn;

  // Load the mesh file.
  Mesh mesh;
  H2DReader mloader;
  mloader.load(argv[2], &mesh);

  int fn_id = atoi(argv[1]);
  switch(fn_id) 
  {
    case 0:
      fn.set_exact(&mesh, fn_const);
      title = titles[0];
      break;
    case 1:
      fn.set_exact(&mesh, fn_plane);
      title = titles[1];
      break;
    case 2:
      fn.set_exact(&mesh, fn_cuboid);
      title = titles[2];
      break;
    case 3:
      fn.set_exact(&mesh, fn_bigrange);
      range_min = -2;
      range_max = 4;
      auto_range = false;
      title = titles[3];
      break;
    case 4:
      fn.set_exact(&mesh, fn_paraboloid);
      auto_range = false;
      title = titles[4];
      break;
    default:
      printf("Please set the first argument to a number from 0 to 4: \n");
      for (int i = 0; i < 4; i++)
        printf("%d: %s\n", i, title.c_str());
      return -1;
  }

  // Test manual setting bounds for the displayed range.
  if (fn_id == 4) 
  { 
    ScalarView view(const_cast<char *>(title.c_str()), new WinGeom(screen_width/4, screen_height/4, screen_width/2, screen_width/2));
    view.set_3d_mode(true);

    // Test the behaviour when user enters bigger lower bound.
    view.set_min_max_range(1, 0.5);
    // Show the function.
    view.show(&fn);
    // Wait for the view to be closed.
    View::wait();

    // Test the behaviour when user enters both bounds the same.
    view.set_min_max_range(0.5, 0.5);
    // Show the function.
    view.show(&fn);
    // Wait for the view to be closed.
    View::wait();

  } 
  else 
  // Test model positioning.
  { 
    for (int i = 0; i < 6; i++) {
      ScalarView view(const_cast<char *>(title.c_str()), new WinGeom(0, 0, test_dims[i][0], test_dims[i][1]));
      view.set_3d_mode(true);

      // Show the function.
      view.show(&fn);
      // Wait for the view to be closed.
      View::wait();

      if (!auto_range) 
      {
        char buf[256];
        sprintf(buf, "%s - restricted to (%f,%f)", title.c_str(), range_min, range_max);
        ScalarView view(buf, new WinGeom(0, 0, test_dims[i][0], test_dims[i][1]));
        view.set_min_max_range(range_min, range_max);
        view.set_3d_mode();
        view.show_bounding_box();

        // Show the function.
        view.show(&fn);
        // Wait for the view to be closed.
        View::wait();
      }
    }
  }

  return 0;
}
Ejemplo n.º 10
0
void resize_callback( int x, int y ){
	window_width = x;
	window_height = y;
	init_glut();
}
Ejemplo n.º 11
0
int main(int argc, char **argv) {
  init_glut(&argc, argv);
  init_gl();
  glutMainLoop();
  return 0;
}