Advertisement
Guest User

test.c

a guest
Dec 23rd, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. #include <allegro5/allegro.h>
  2. #include <allegro5/allegro_opengl.h>
  3. #include <allegro5/allegro_direct3d.h>
  4. #include <stdio.h>
  5.  
  6. int main() {
  7.     al_init();
  8.  
  9.     al_set_new_display_flags(ALLEGRO_DIRECT3D);
  10.     //al_set_new_display_flags(ALLEGRO_DIRECT3D | ALLEGRO_FRAMELESS);
  11.     //al_set_new_display_flags(ALLEGRO_OPENGL);
  12.     //al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_FRAMELESS);
  13.  
  14.     ALLEGRO_DISPLAY *display = al_create_display(640, 480);
  15.     ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
  16.  
  17.     al_install_keyboard();
  18.     al_install_mouse();
  19.  
  20.     al_register_event_source(queue, al_get_keyboard_event_source());
  21.     al_register_event_source(queue, al_get_mouse_event_source());
  22.     al_register_event_source(queue, al_get_display_event_source(display));
  23.  
  24.     al_set_window_position(display, 200, 200);
  25.    
  26.     int exit = 0;
  27.     while (!exit) {
  28.         ALLEGRO_EVENT ev;
  29.         while (al_get_next_event(queue, &ev)) {
  30.             if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
  31.                 exit = 1;
  32.             }
  33.             if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
  34.                 if(ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
  35.                      exit = 1;
  36.                 }
  37.                
  38.                 int x = 0;
  39.                 int y = 0;
  40.  
  41.                 al_get_window_position(display, &x, &y);
  42.                 al_set_window_position(display, x, y);
  43.  
  44.                 printf("Coords: %d, %d\n", x, y);
  45.             }
  46.         }
  47.  
  48.         al_flip_display();
  49.     }
  50.    
  51.     al_destroy_event_queue(queue);
  52.     al_destroy_display(display);
  53.  
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement