Advertisement
Gassa

Allegro 5 oversized window and mouse

Aug 15th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. #include <allegro5/allegro.h>
  2. #include <allegro5/allegro_font.h>
  3. #include <assert.h>
  4. #include <stdio.h>
  5.  
  6. int main (int argc, char * argv [])
  7. {
  8.     int const MAX_X = 2500;
  9.     int const MAX_Y = 1500;
  10.     int result = al_init ();
  11.     assert (result != 0);
  12.     ALLEGRO_DISPLAY * display = al_create_display (MAX_X, MAX_Y);
  13.     assert (display != NULL);
  14.     int w = al_get_display_width (display);
  15.     int h = al_get_display_height (display);
  16.     ALLEGRO_EVENT_QUEUE * queue = al_create_event_queue ();
  17.     assert (queue != NULL);
  18.     al_install_mouse ();
  19.     al_init_font_addon ();
  20.     al_register_event_source (queue, al_get_mouse_event_source ());
  21.     bool exit = false;
  22.     int x = 0;
  23.     int y = 0;
  24.     while (!exit)
  25.     {
  26.         ALLEGRO_EVENT event;
  27.         while (al_get_next_event (queue, &event))
  28.         {
  29.             if (event.type == ALLEGRO_EVENT_MOUSE_AXES)
  30.             {
  31.                 x = event.mouse.x;
  32.                 y = event.mouse.y;
  33.                 printf ("w = %d, h = %d, ", w, h);
  34.                 printf ("x = %d, y = %d\n", x, y);
  35.             }
  36.             else if (event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
  37.             {
  38.                 exit = true;
  39.             }
  40.         }
  41.  
  42.         al_clear_to_color (al_map_rgb_f (0.0, 0.0, 0.0));
  43.         al_draw_pixel (MAX_X / 2, MAX_Y / 2, al_map_rgb_f (0.5, 0.5, 0.5));
  44.         al_draw_pixel (x, y, al_map_rgb_f (1.0, 1.0, 1.0));
  45.         al_flip_display ();
  46.     }
  47.     return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement