Created
June 10, 2025 20:29
-
-
Save lockie/d60064a9181e9896fb217adb2a083ae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <allegro5/allegro.h> | |
const float FPS = 60; | |
void trace_handler(const char* str) | |
{ | |
fprintf(stderr, "%s", str); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
al_set_config_value(al_get_system_config(), "trace", "level", "debug"); | |
al_register_trace_handler(trace_handler); | |
if (!al_init()) { | |
fprintf(stderr, "Failed to initialize allegro.\n"); | |
return EXIT_FAILURE; | |
} | |
ALLEGRO_DISPLAY* display = al_create_display(640, 480); | |
if (!display) { | |
fprintf(stderr, "Failed to create display.\n"); | |
return EXIT_FAILURE; | |
} | |
ALLEGRO_EVENT_QUEUE* event_queue = al_create_event_queue(); | |
if (!event_queue) { | |
fprintf(stderr, "Failed to create event queue."); | |
return EXIT_FAILURE; | |
} | |
al_register_event_source(event_queue, al_get_display_event_source(display)); | |
bool running = true; | |
while (running) { | |
ALLEGRO_EVENT event; | |
while(al_get_next_event(event_queue, &event)) | |
{ | |
if(event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) | |
{ | |
running = false; | |
break; | |
} | |
} | |
al_clear_to_color(al_map_rgb(0, 0, 255)); | |
al_flip_display(); | |
} | |
al_destroy_display(display); | |
al_destroy_event_queue(event_queue); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment