Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <allegro5/allegro.h>
- #include <allegro5/allegro_font.h>
- #include <assert.h>
- #include <stdio.h>
- int main (int argc, char * argv [])
- {
- int const MAX_X = 2500;
- int const MAX_Y = 1500;
- int result = al_init ();
- assert (result != 0);
- ALLEGRO_DISPLAY * display = al_create_display (MAX_X, MAX_Y);
- assert (display != NULL);
- int w = al_get_display_width (display);
- int h = al_get_display_height (display);
- ALLEGRO_EVENT_QUEUE * queue = al_create_event_queue ();
- assert (queue != NULL);
- al_install_mouse ();
- al_init_font_addon ();
- al_register_event_source (queue, al_get_mouse_event_source ());
- bool exit = false;
- int x = 0;
- int y = 0;
- while (!exit)
- {
- ALLEGRO_EVENT event;
- while (al_get_next_event (queue, &event))
- {
- if (event.type == ALLEGRO_EVENT_MOUSE_AXES)
- {
- x = event.mouse.x;
- y = event.mouse.y;
- printf ("w = %d, h = %d, ", w, h);
- printf ("x = %d, y = %d\n", x, y);
- }
- else if (event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN)
- {
- exit = true;
- }
- }
- al_clear_to_color (al_map_rgb_f (0.0, 0.0, 0.0));
- al_draw_pixel (MAX_X / 2, MAX_Y / 2, al_map_rgb_f (0.5, 0.5, 0.5));
- al_draw_pixel (x, y, al_map_rgb_f (1.0, 1.0, 1.0));
- al_flip_display ();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement