コード例 #1
0
ファイル: gstmirsink.c プロジェクト: rsalveti/gst-plugins-bad
static void
gst_mir_sink_finalize (GObject * object)
{
    GstMirSink *sink = GST_MIR_SINK (object);

    GST_DEBUG_OBJECT (sink, "Finalizing the sink..");

#if 0
    if (sink->window)
        destroy_window (sink->window);
    if (sink->display)
        destroy_display (sink->display);
    if (sink->session)
        destroy_session (sink->session);
#endif

    /* Make sure that the SurfaceTextureClientHybris instance gets cleaned
     * up when the pipeline is being torn down.
     */
    if (sink->surface_texture_client)
        surface_texture_client_unref (sink->surface_texture_client);

    g_mutex_clear (&sink->mir_lock);

    G_OBJECT_CLASS (parent_class)->finalize (object);
}
コード例 #2
0
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Here we retrieve the linux-dmabuf objects, or error */
	wl_display_roundtrip(display->display);

	if (!running)
		return 1;

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
コード例 #3
0
ファイル: simple-dmabuf.c プロジェクト: kwm81/weston
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int ret = 0;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	/* Initialise damage to full surface, so the padding gets painted */
	wl_surface_damage(window->surface, 0, 0,
			  window->width, window->height);

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-dmabuf exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
コード例 #4
0
static void
gst_wayland_sink_finalize (GObject * object)
{
  GstWaylandSink *sink = GST_WAYLAND_SINK (object);

  GST_DEBUG_OBJECT (sink, "Finalizing the sink..");

  if (sink->window)
    destroy_window (sink->window);
  if (sink->display)
    destroy_display (sink->display);

  if (sink->pool_lock) {
    g_mutex_free (sink->pool_lock);
    sink->pool_lock = NULL;
  }

  if (sink->buffer_pool) {
    gst_wayland_bufferpool_clear (sink);
  }

  g_mutex_free (sink->wayland_lock);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
コード例 #5
0
ファイル: simple-shm.c プロジェクト: Blei/weston
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;

	display = create_display();
	window = create_window(display, 250, 250);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	redraw(window, NULL, 0);

	while (running)
		wl_display_iterate(display->display, display->mask);

	fprintf(stderr, "simple-shm exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
コード例 #6
0
ファイル: fastereo.c プロジェクト: BackupTheBerlios/fastereo
/**
 * S'occupe du nettoyage...
 */
void terminate_program()
{
    Edbg(("terminate_program()"));

    destroy_cameras();
    destroy_display();
    
    Rdbg(("terminate_program"));

    exit(0);
}
コード例 #7
0
ファイル: gametest1.c プロジェクト: RoboNickBot/c-maze
int main ()
{
    struct mazegame game;
    struct game_display *display;

    /* char *map_file_name = "mazes/mazeFile1.txt"; */

    struct maze *maze;

    int game_running = 1;
    enum command command;

    srand ( time ( NULL ) );

    /* maze = read_map ( map_file_name ); */
    maze = generate_maze ( 20, 70, 50, 30 );

    printf ( "escaped the read_map\n" );
    
    game = new_mazegame ( maze );

    printf ( "initializing display" );
    display = init_display ( game.maze->size, MAINGAME );

    while ( game_running )
    {
        update_display ( display, &game );
        get_command ( &command );
        if ( command == QUIT || DR_equal_pos ( game.player.p, game.maze->goal_position ) || game.player.battery < -5 ) {
          game_running = 0;

        } else if ( RUN == command ) {
          update_game( &game, command );
          update_display( display, &game );
          update_game( &game, command );
          update_display( display, &game );
          update_game( &game, command );

        } else {
          update_game ( &game, command );
        }
    }

    destroy_display ( display );
    destroy_mazegame ( &game );

    return 0;

}
コード例 #8
0
ファイル: simple.c プロジェクト: HornetBlack/wl_stupid
int main(void)
{
        struct sigaction   sigint;
        struct my_display *display;
        struct my_window  *window;

        /* Connect to the display */
        printf("Connecting to display\n");
        display = create_display();
        printf("Connected!\n");

        /* Create a window */
        printf("Creating a window\n");
        window = create_window(display, MIN_WIDTH, MIN_HEIGHT);
        if (!window)
                return 1;
        printf("Window created\n");

        /* Set up singal handler. So SIGINT allows us to cleanly die. */
        sigint.sa_handler = signal_int;
        sigemptyset(&sigint.sa_mask);
        sigint.sa_flags = SA_RESETHAND;
        sigaction(SIGINT, &sigint, NULL);

        printf("Initialising buffers\n");
        /* Initialize */
        wl_surface_damage(window->surface, 0, 0, window->width, window->height);
        /* Draw first screen which allocates buffer(s). */
        draw(window, NULL, 0);
       
        printf("Starting loop\n");
        /* Main loop */
        while (running) {
                if (wl_display_dispatch(display->display) == -1) {
                        running = 0;
                }
        }
        printf("Loop exited\n");
        
        /* Destroy the display */
        printf("Destroying window\n");
        destroy_window(window); window = NULL;
        printf("Disconnecting display\n");
        destroy_display(display); display = NULL;
        printf("Done\n");

        return 0;
}
コード例 #9
0
static void
gst_wayland_sink_finalize (GObject * object)
{
  GstWaylandSink *sink = GST_WAYLAND_SINK (object);

  GST_DEBUG_OBJECT (sink, "Finalizing the sink..");

  if (sink->window)
    destroy_window (sink->window);
  if (sink->display)
    destroy_display (sink->display);
  if (sink->shm_pool)
    shm_pool_destroy (sink->shm_pool);

  g_mutex_clear (&sink->wayland_lock);

  G_OBJECT_CLASS (parent_class)->finalize (object);
}
コード例 #10
0
ファイル: demo.c プロジェクト: AntonLanghoff/whitecatlib
int main(int argc, char *argv[])
{
   int c, w, h;
   char buf[256], buf2[256];
   ANIMATION_TYPE type;

   for (c = 1; c < argc; c++) {
      if (stricmp(argv[c], "-cheat") == 0)
         cheat = TRUE;

      if (stricmp(argv[c], "-jumpstart") == 0)
         jumpstart = TRUE;
   }

   /* The fonts we are using don't contain the full latin1 charset (not to
    * mention Unicode), so in order to display correctly author names in
    * the credits with 8-bit characters, we will convert them down to 7
    * bits with a custom mapping table. Fortunately, Allegro comes with a
    * default custom mapping table which reduces Latin-1 and Extended-A
    * characters to 7 bits. We don't even need to call set_ucodepage()!
    */
   set_uformat(U_ASCII_CP);
   
   srand(time(NULL));
   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_timer();
   install_mouse();

   if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL) != 0) {
      allegro_message("Error initialising sound\n%s\n", allegro_error);
      install_sound(DIGI_NONE, MIDI_NONE, NULL);
   }

   if (install_joystick(JOY_TYPE_AUTODETECT) != 0) {
      allegro_message("Error initialising joystick\n%s\n", allegro_error);
      install_joystick(JOY_TYPE_NONE);
   }

   if (set_gfx_mode(GFX_AUTODETECT, 320, 200, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
         set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
         allegro_message("Unable to set any graphic mode\n%s\n",
                         allegro_error);
         return 1;
      }
   }

   get_executable_name(buf, sizeof(buf));
   replace_filename(buf2, buf, "demo.dat", sizeof(buf2));
   set_color_conversion(COLORCONV_NONE);
   data = load_datafile(buf2);
   if (!data) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Error loading %s\n", buf2);
      exit(1);
   }

   if (!jumpstart) {
      intro_screen();
   }

   clear_bitmap(screen);
   set_gui_colors();
   set_mouse_sprite(NULL);

   if (!gfx_mode_select(&c, &w, &h))
      exit(1);

   if (pick_animation_type(&type) < 0)
      exit(1);

   init_display(c, w, h, type);

   generate_explosions();

   //stop_sample(data[INTRO_SPL].dat);

   clear_bitmap(screen);

   while (title_screen())
      play_game();

   destroy_display();

   destroy_explosions();

   stop_midi();

   set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);

   end_title();

   unload_datafile(data);

   allegro_exit();

   return 0;
}
コード例 #11
0
ファイル: simple-damage.c プロジェクト: feilen/weston-rift
int
main(int argc, char **argv)
{
	struct sigaction sigint;
	struct display *display;
	struct window *window;
	int i, ret = 0;
	int version = -1;
	int width = 300, height = 200, scale = 1;
	enum wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
	enum window_flags flags = 0;

	for (i = 1; i < argc; ++i) {
		if (strcmp(argv[i], "--help") == 0 ||
		    strcmp(argv[i], "-h") == 0) {
			print_usage(0);
		} else if (sscanf(argv[i], "--version=%d", &version) > 0) {
			if (version < 1 || version > 3) {
				fprintf(stderr, "Unsupported wl_surface version: %d\n",
					version);
				return 1;
			}
			continue;
		} else if (strcmp(argv[i], "--verbose") == 0) {
			print_debug = 1;
			continue;
		} else if (sscanf(argv[i], "--width=%d", &width) > 0) {
			continue;
		} else if (sscanf(argv[i], "--height=%d", &height) > 0) {
			continue;
		} else if (strncmp(argv[i], "--transform=", 12) == 0 &&
			   parse_transform(argv[i] + 12, &transform) > 0) {
			continue;
		} else if (strcmp(argv[i], "--rotating-transform") == 0) {
			flags |= WINDOW_FLAG_ROTATING_TRANSFORM;
			continue;
		} else if (sscanf(argv[i], "--scale=%d", &scale) > 0) {
			continue;
		} else if (strcmp(argv[i], "--use-viewport") == 0) {
			flags |= WINDOW_FLAG_USE_VIEWPORT;
			continue;
		} else {
			printf("Invalid option: %s\n", argv[i]);
			print_usage(255);
		}
	}

	display = create_display(version);

	window = create_window(display, width, height, transform, scale, flags);
	if (!window)
		return 1;

	sigint.sa_handler = signal_int;
	sigemptyset(&sigint.sa_mask);
	sigint.sa_flags = SA_RESETHAND;
	sigaction(SIGINT, &sigint, NULL);

	redraw(window, NULL, 0);

	while (running && ret != -1)
		ret = wl_display_dispatch(display->display);

	fprintf(stderr, "simple-shm exiting\n");
	destroy_window(window);
	destroy_display(display);

	return 0;
}
コード例 #12
0
ファイル: game.c プロジェクト: salahuddinasjad/TDT4258
int main(int argc, char *argv[])
{
    char c;
    int status = 0;
    
    printf("Hello World, I'm game!\n");
    
    status = init_display();
    if (status != 0)
    {
        printf("Error: Failed to init display\n");
        return status;
    }
    
    status = init_driver();
    if (status != 0)
    {
        printf("Error: Failed to init driver\n");
        destroy_display();
        return status;
    }
    
    status = setup_handler();
    if (status != 0)
    {
        printf("Error: Failed to init signal handler\n");
        destroy_display();
        close(file_gamepad_driver);
        return status;
    }
    time_handler();
    
    /* Intializes random number generator */
    srand((unsigned) time(&t));
    
    sigset_t myset;
    (void) sigemptyset(&myset);

    while(1)
    {
        clear_LCD();       
        draw_game();
        draw_score(p1_score, p2_score);
        redraw();
        
        waitForButton();      
        printf("start game\n");
        
        while((p1_score < 5) && (p2_score < 5))
        {
            random_timer = (rand() % 3) + 2;
            startTimer(random_timer);
            waitForTimer();
            
            random_button = (rand() % 4);
            
            draw_button(random_button, true, RED);
            redraw();
            
            gettimeofday(&time_button_appears, NULL);

            // start timer
            startTimer(3);
            buf = 0;
            while((playerButtonPressed(random_button) == 0) && (timer_expired == false))
            {
                waitForButton(); 
            }
            
            stopTimer();
            if (timer_expired == false)
            {
                time_elapsed = getGameTime();
                draw_time(time_elapsed, BLUE);
                redraw();
            }
      
            if (playerButtonPressed(random_button) == P1)
            {
                p1_score++;
                p1_time += time_elapsed;
                
            }
            else if (playerButtonPressed(random_button) == P2)
            {
                p2_score++;    
                p2_time += time_elapsed;
            }
                
            draw_score(p1_score, p2_score);    
            reset_button(random_button);
            redraw();
            
        }
        // draw winner
        button_pressed = 0;
        if (p1_score == 5)
        {
            winner = P1;
            winner_time = p1_time;
        }
        else if (p2_score == 5)
        {
            winner = P2;
            winner_time = p2_time;
        }
        
        while(button_pressed == 0)
        {
            startTimer(1);
            winner_blink(winner, winner_time);
            waitForTimer();
        }
               
        // print waiting
        waitForButton();
        p1_score = 0;
        p1_time = 0;
        p2_score = 0;
        p2_time = 0;
    }

}
コード例 #13
0
ファイル: game.c プロジェクト: salahuddinasjad/TDT4258
void quitGame()
{
    destroy_display();
    close(file_gamepad_driver);
    exit(EXIT_SUCCESS);
}
コード例 #14
0
ファイル: fastereo.c プロジェクト: BackupTheBerlios/fastereo
/**
 * Fonction principale
 * @param argc nombre d'arguments
 * @param argv tableau d'arguments
 * @return program exit code
 */
int
main(int argc, char *argv[])
{
    /* debug trace start */
    Edbg(("main(argc=%d, argv=%s)", argc, argv[0]));
    Initdbg((&argc, argv));

    int c;
    char display_opengl = FALSE;
    int ret;
	static struct sigaction act;

    /* on récupère les options */
    while ( (c = getopt(argc, argv, "hga:z:")) >= 0) 
    {
        switch (c) 
        {
            case 'h':
                /* print help */
                print_usage();
                Rdbg(("main return EXIT_SUCCESS"));
                return EXIT_SUCCESS;
            case 'g':
                /* display in OpenGL */
                display_opengl = TRUE;
                break;
            case 'z':
                /* display in OpenGL */
                g_zoomim = strtod(optarg, (char **)NULL);
                break;
            case 'a':
                /* nombre de keyframes dans l'animation OpenGL */
                g_anim_nb_keyframes = strtol(optarg, (char **)NULL, 10);;
                break;
        }
    }

    /* il faut le nom du fichier de commandes dans les arguments */
    if ((argc-optind) != 1)
    {
        print_usage();
        Rdbg(("main return EXIT_FAILURE"));
        return EXIT_FAILURE;
    }

	/* on catche le Ctrl-C */
	act.sa_handler = terminate_program_catch;
	sigfillset(&(act.sa_mask));
	sigaction(SIGINT, &act, NULL);

    /* on charge les commandes */
    ret = execute_commands(argv[optind]);
    if (ret != RETURN_SUCCESS)
    {
        destroy_cameras();
        return EXIT_FAILURE;
    }

    /* on vérifie qu'il y a bien au moins 2 caméras chargées */
    if (g_cameras.nb < 2)
    {
        fprintf(stderr, "Il faut charger au moins 2 caméras!\n");
        destroy_cameras();
        return EXIT_FAILURE;
    }

    /* affichage */
    if (TRUE == display_opengl)
    {
        /* on utilise atexit car glut ne dit pas quand il quitte le programme
         * (ce gros malin...) 
         * cf 3.070 http://users.frii.com/martz/oglfaq/glut.htm
         * update: depuis j'utilise SDL mais je garde quand même atexit... */
        atexit(terminate_program);

        init_display();
        start_display();
        destroy_display();
    }

    /* nettoyage */
    destroy_cameras();

    /* debug trace end */
    Rdbg(("main EXIT_SUCCESS"));
    return EXIT_SUCCESS;
}