40 #include <allegro5/allegro.h>
41 #include <allegro5/allegro_primitives.h>
43 #include <allegro5/allegro_windows.h>
45 #define ALLEGRO_HAS_CLIPBOARD (ALLEGRO_VERSION_INT >= ((5 << 24) | (1 << 16) | (12 << 8))) // Clipboard only supported from Allegro 5.1.12
49 #pragma warning (disable: 4127) // condition expression is constant
70 al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA);
79 ALLEGRO_TRANSFORM transform;
80 al_identity_transform(&transform);
81 al_use_transform(&transform);
82 al_orthographic_transform(&transform, L,
T, 1.0
f, R, B, -1.0
f);
83 al_use_projection_transform(&transform);
96 ALLEGRO_TRANSFORM last_transform = *al_get_current_transform();
97 ALLEGRO_TRANSFORM last_projection_transform = *al_get_current_projection_transform();
98 int last_clip_x, last_clip_y, last_clip_w, last_clip_h;
99 al_get_clipping_rectangle(&last_clip_x, &last_clip_y, &last_clip_w, &last_clip_h);
100 int last_blender_op, last_blender_src, last_blender_dst;
101 al_get_blender(&last_blender_op, &last_blender_src, &last_blender_dst);
120 dst_v->
uv = src_v->
uv;
121 unsigned char* c = (
unsigned char*)&src_v->
col;
122 dst_v->
col = al_map_rgba(c[0], c[1], c[2], c[3]);
144 for (
int cmd_i = 0; cmd_i < cmd_list->
CmdBuffer.
Size; cmd_i++)
168 al_set_blender(last_blender_op, last_blender_src, last_blender_dst);
169 al_set_clipping_rectangle(last_clip_x, last_clip_y, last_clip_w, last_clip_h);
170 al_use_transform(&last_transform);
171 al_use_projection_transform(&last_projection_transform);
183 int flags = al_get_new_bitmap_flags();
184 int fmt = al_get_new_bitmap_format();
185 al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP|ALLEGRO_MIN_LINEAR|ALLEGRO_MAG_LINEAR);
186 al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE);
188 al_set_new_bitmap_flags(
flags);
189 al_set_new_bitmap_format(
fmt);
193 ALLEGRO_LOCKED_REGION *locked_img = al_lock_bitmap(
img, al_get_bitmap_format(
img), ALLEGRO_LOCK_WRITEONLY);
196 al_destroy_bitmap(
img);
200 al_unlock_bitmap(
img);
203 ALLEGRO_BITMAP* cloned_img = al_clone_bitmap(
img);
204 al_destroy_bitmap(
img);
214 ALLEGRO_BITMAP* mouse_cursor = al_create_bitmap(8,8);
216 al_destroy_bitmap(mouse_cursor);
236 #if ALLEGRO_HAS_CLIPBOARD
237 static const char* ImGui_ImplAllegro5_GetClipboardText(
void*)
245 static void ImGui_ImplAllegro5_SetClipboardText(
void*,
const char* text)
263 ALLEGRO_VERTEX_ELEMENT elems[] =
296 #if ALLEGRO_HAS_CLIPBOARD
331 case ALLEGRO_EVENT_MOUSE_AXES:
339 case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
340 case ALLEGRO_EVENT_MOUSE_BUTTON_UP:
341 if (ev->mouse.display ==
g_Display && ev->mouse.button <= 5)
342 io.
MouseDown[ev->mouse.button - 1] = (ev->type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN);
344 case ALLEGRO_EVENT_TOUCH_MOVE:
348 case ALLEGRO_EVENT_TOUCH_BEGIN:
349 case ALLEGRO_EVENT_TOUCH_END:
350 case ALLEGRO_EVENT_TOUCH_CANCEL:
351 if (ev->touch.display ==
g_Display && ev->touch.primary)
352 io.
MouseDown[0] = (ev->type == ALLEGRO_EVENT_TOUCH_BEGIN);
354 case ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY:
358 case ALLEGRO_EVENT_KEY_CHAR:
362 case ALLEGRO_EVENT_KEY_DOWN:
363 case ALLEGRO_EVENT_KEY_UP:
365 io.
KeysDown[ev->keyboard.keycode] = (ev->type == ALLEGRO_EVENT_KEY_DOWN);
385 ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id = ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT;
386 switch (imgui_cursor)
396 al_set_system_mouse_cursor(
g_Display, cursor_id);
414 double current_time = al_get_time();
419 ALLEGRO_KEYBOARD_STATE keys;
420 al_get_keyboard_state(&keys);
421 io.
KeyCtrl = al_key_down(&keys, ALLEGRO_KEY_LCTRL) || al_key_down(&keys, ALLEGRO_KEY_RCTRL);
422 io.
KeyShift = al_key_down(&keys, ALLEGRO_KEY_LSHIFT) || al_key_down(&keys, ALLEGRO_KEY_RSHIFT);
423 io.
KeyAlt = al_key_down(&keys, ALLEGRO_KEY_ALT) || al_key_down(&keys, ALLEGRO_KEY_ALTGR);
424 io.
KeySuper = al_key_down(&keys, ALLEGRO_KEY_LWIN) || al_key_down(&keys, ALLEGRO_KEY_RWIN);