This repository has been archived by the owner on Nov 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cxx
80 lines (59 loc) · 2.09 KB
/
main.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// public domain
#include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <imgui.h>
#include "imgui_impl_a5.hxx"
int main(int argc, char **argv)
{
ALLEGRO_DISPLAY *disp;
ALLEGRO_EVENT_QUEUE *queue;
al_init();
al_install_keyboard();
al_install_mouse();
al_init_primitives_addon();
//al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_DONTCARE);
disp = al_create_display(1280, 800);
queue = al_create_event_queue();
al_register_event_source(queue, al_get_display_event_source(disp));
al_register_event_source(queue, al_get_keyboard_event_source());
al_register_event_source(queue, al_get_mouse_event_source());
ImGui_ImplA5_Init(disp);
bool show_test_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImColor(114, 144, 154);
bool running = true;
while (running) {
ALLEGRO_EVENT ev;
while (al_get_next_event(queue, &ev)) {
ImGui_ImplA5_ProcessEvent(&ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) running = false;
}
ImGui_ImplA5_NewFrame();
{
static float f;
ImGui::Text("Hello, world!");
ImGui::SliderFloat("float", &f, 0.0f, 1.0f);
ImGui::ColorEdit3("clear color", (float*)&clear_color);
if (ImGui::Button("Test Window")) show_test_window ^= 1;
if (ImGui::Button("Another Window")) show_another_window ^= 1;
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f/ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
}
if (show_another_window) {
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
ImGui::Begin("Another Window", &show_another_window);
ImGui::Text("Hello");
ImGui::End();
}
if (show_test_window) {
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
ImGui::ShowTestWindow(&show_test_window);
}
al_clear_to_color(al_map_rgba_f(clear_color.x, clear_color.y, clear_color.z, clear_color.w));
ImGui::Render();
al_flip_display();
}
ImGui_ImplA5_Shutdown();
al_destroy_event_queue(queue);
al_destroy_display(disp);
return 0;
}