mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Allegro 5 example: main.cpp matches other examples. added window title.
This commit is contained in:
parent
1845ff4690
commit
489e28ec11
@ -4,11 +4,10 @@ I choose to provide Visual Studio 10 .sln files and Makefile for Linux/OSX.
|
|||||||
Please let me know if they don't work with your setup!
|
Please let me know if they don't work with your setup!
|
||||||
You can probably just import the .cpp files into your own system and figure out the linkage from there.
|
You can probably just import the .cpp files into your own system and figure out the linkage from there.
|
||||||
|
|
||||||
|
|
||||||
opengl_example/
|
opengl_example/
|
||||||
OpenGL example, using GLFW + fixed pipeline.
|
OpenGL example, using GLFW + fixed pipeline.
|
||||||
This is simple and should work for all OpenGL enabled applications.
|
This is simple and should work for all OpenGL enabled applications.
|
||||||
Prefer following this example since it is the shortest one!
|
Prefer following this example to learn how ImGui works, because it is the simplest shortest one!
|
||||||
|
|
||||||
opengl3_example/
|
opengl3_example/
|
||||||
OpenGL example, using GLFW/GL3W + programmable pipeline.
|
OpenGL example, using GLFW/GL3W + programmable pipeline.
|
||||||
@ -28,3 +27,6 @@ ios_example/
|
|||||||
|
|
||||||
sdl_opengl_example/
|
sdl_opengl_example/
|
||||||
SDL2 + OpenGL example.
|
SDL2 + OpenGL example.
|
||||||
|
|
||||||
|
allegro5_example/
|
||||||
|
Allegro 5 example.
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
// ImGui Allegro 5 bindings
|
// ImGui Allegro 5 bindings
|
||||||
// by @birthggd
|
|
||||||
// public domain
|
|
||||||
// https://github.com/ocornut/imgui
|
// https://github.com/ocornut/imgui
|
||||||
|
// by @birthggd, public domain
|
||||||
|
|
||||||
#include <stdint.h> // uint64_t
|
#include <stdint.h> // uint64_t
|
||||||
#include <cstring> // memcpy
|
#include <cstring> // memcpy
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
// public domain
|
// ImGui Allegro 5 bindings
|
||||||
|
// https://github.com/ocornut/imgui
|
||||||
|
// by @birthggd, public domain
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct ALLEGRO_DISPLAY;
|
struct ALLEGRO_DISPLAY;
|
||||||
union ALLEGRO_EVENT;
|
union ALLEGRO_EVENT;
|
||||||
|
|
||||||
bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY *disp);
|
bool ImGui_ImplA5_Init(ALLEGRO_DISPLAY* display);
|
||||||
void ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT *ev);
|
|
||||||
void ImGui_ImplA5_Shutdown();
|
void ImGui_ImplA5_Shutdown();
|
||||||
|
|
||||||
void ImGui_ImplA5_NewFrame();
|
void ImGui_ImplA5_NewFrame();
|
||||||
|
|
||||||
|
void ImGui_ImplA5_ProcessEvent(ALLEGRO_EVENT* event);
|
||||||
|
|
||||||
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
bool Imgui_ImplA5_CreateDeviceObjects();
|
bool Imgui_ImplA5_CreateDeviceObjects();
|
||||||
void ImGui_ImplA5_InvalidateDeviceObjects();
|
void ImGui_ImplA5_InvalidateDeviceObjects();
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// ImGui - standalone example application for Allegro 5
|
||||||
// public domain
|
// public domain
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -6,42 +7,48 @@
|
|||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include "imgui_impl_a5.h"
|
#include "imgui_impl_a5.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
ALLEGRO_DISPLAY *disp;
|
// Setup Allegro
|
||||||
ALLEGRO_EVENT_QUEUE *queue;
|
|
||||||
|
|
||||||
al_init();
|
al_init();
|
||||||
al_install_keyboard();
|
al_install_keyboard();
|
||||||
al_install_mouse();
|
al_install_mouse();
|
||||||
|
|
||||||
al_init_primitives_addon();
|
al_init_primitives_addon();
|
||||||
|
ALLEGRO_DISPLAY* display = al_create_display(1280, 720);
|
||||||
//al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_DONTCARE);
|
al_set_window_title(display, "ImGui Allegro 5 example");
|
||||||
disp = al_create_display(1280, 800);
|
ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
|
||||||
|
al_register_event_source(queue, al_get_display_event_source(display));
|
||||||
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_keyboard_event_source());
|
||||||
al_register_event_source(queue, al_get_mouse_event_source());
|
al_register_event_source(queue, al_get_mouse_event_source());
|
||||||
|
|
||||||
ImGui_ImplA5_Init(disp);
|
// Setup ImGui binding
|
||||||
|
ImGui_ImplA5_Init(display);
|
||||||
|
//ImGuiIO& io = ImGui::GetIO();
|
||||||
|
//ImFont* my_font0 = io.Fonts->AddFontDefault();
|
||||||
|
//ImFont* my_font1 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/DroidSans.ttf", 16.0f);
|
||||||
|
//ImFont* my_font2 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/Karla-Regular.ttf", 16.0f);
|
||||||
|
//ImFont* my_font3 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyClean.ttf", 13.0f); my_font3->DisplayOffset.y += 1;
|
||||||
|
//ImFont* my_font4 = io.Fonts->AddFontFromFileTTF("../../extra_fonts/ProggyTiny.ttf", 10.0f); my_font4->DisplayOffset.y += 1;
|
||||||
|
//ImFont* my_font5 = io.Fonts->AddFontFromFileTTF("c:\\Windows\\Fonts\\ArialUni.ttf", 18.0f, io.Fonts->GetGlyphRangesJapanese());
|
||||||
|
|
||||||
bool show_test_window = true;
|
bool show_test_window = true;
|
||||||
bool show_another_window = false;
|
bool show_another_window = false;
|
||||||
ImVec4 clear_color = ImColor(114, 144, 154);
|
ImVec4 clear_color = ImColor(114, 144, 154);
|
||||||
|
|
||||||
|
// Main loop
|
||||||
bool running = true;
|
bool running = true;
|
||||||
while (running) {
|
while (running)
|
||||||
|
{
|
||||||
ALLEGRO_EVENT ev;
|
ALLEGRO_EVENT ev;
|
||||||
while (al_get_next_event(queue, &ev)) {
|
while (al_get_next_event(queue, &ev))
|
||||||
|
{
|
||||||
ImGui_ImplA5_ProcessEvent(&ev);
|
ImGui_ImplA5_ProcessEvent(&ev);
|
||||||
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) running = false;
|
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui_ImplA5_NewFrame();
|
ImGui_ImplA5_NewFrame();
|
||||||
|
|
||||||
|
// 1. Show a simple window
|
||||||
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
{
|
{
|
||||||
static float f;
|
static float f;
|
||||||
ImGui::Text("Hello, world!");
|
ImGui::Text("Hello, world!");
|
||||||
@ -53,28 +60,32 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_another_window) {
|
// 2. Show another simple window, this time using an explicit Begin/End pair
|
||||||
|
if (show_another_window)
|
||||||
|
{
|
||||||
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(200, 100), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin("Another Window", &show_another_window);
|
ImGui::Begin("Another Window", &show_another_window);
|
||||||
ImGui::Text("Hello");
|
ImGui::Text("Hello");
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_test_window) {
|
// 3. Show the ImGui test window. Most of the sample code is in ImGui::ShowTestWindow()
|
||||||
|
if (show_test_window)
|
||||||
|
{
|
||||||
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::ShowTestWindow(&show_test_window);
|
ImGui::ShowTestWindow(&show_test_window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rendering
|
||||||
al_clear_to_color(al_map_rgba_f(clear_color.x, clear_color.y, clear_color.z, clear_color.w));
|
al_clear_to_color(al_map_rgba_f(clear_color.x, clear_color.y, clear_color.z, clear_color.w));
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
ImGui_ImplA5_Shutdown();
|
ImGui_ImplA5_Shutdown();
|
||||||
|
|
||||||
al_destroy_event_queue(queue);
|
al_destroy_event_queue(queue);
|
||||||
al_destroy_display(disp);
|
al_destroy_display(display);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user