![]() |
|
Problem solved: memory bitmaps not being converted |
Andrew Gillett
Member #15,868
January 2015
|
I found the reason for this issue: I was setting the bitmap flags to 0, which excludes ALLEGRO_CONVERT_BITMAPS. I also needed to make sure that I deleted and recreated shaders when recreating the display. UPDATE: and re-register both display (fair enough) and keyboard (unexpected) event sources. |
Peter Hull
Member #1,136
March 2001
|
Andrew Gillett said: and keyboard (unexpected) event sources Sounds like a bug. It's not needed on Mac AFAICT. [edit] 1#include <stdio.h>
2#include <allegro5/allegro.h>
3
4int main()
5{
6 al_init();
7 al_install_keyboard();
8 ALLEGRO_DISPLAY *display = al_create_display(640, 480);
9 ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
10 al_register_event_source(queue, al_get_keyboard_event_source());
11 bool running = true;
12 while (running)
13 {
14 ALLEGRO_EVENT event;
15 al_wait_for_event(queue, &event);
16 if (event.type == ALLEGRO_EVENT_KEY_CHAR)
17 {
18 printf("A key %c\n", event.keyboard.unichar);
19 if (event.keyboard.unichar == 'q')
20 {
21 running = false;
22 }
23 if (event.keyboard.unichar == 'd')
24 {
25 al_destroy_display(display);
26 display = al_create_display(320, 240);
27 }
28 }
29 }
30 al_destroy_display(display);
31 return 0;
32}
I know that Windows keyboard handling needs a (focussed) window to receive the WM_KEY* messages but I thought that any window managed by Allegro would do. Could you file an issue if you've got time?
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
If the window is re-created, so is it's keyboard event source. I don't think it's a bug. Different HWND = different keyboard source. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
Isn't that an implementation detail though? From a user perspective there's nothing in the Allegro API that ties a keyboard event source to a display. Also (unless I've misunderstood what Andrew was doing) deleting the display doesn't affect the keyboard on Macos, so it is inconsistent across platforms at the least. I'm not able to test on Windows so I don't know if the code I posted works or doesn't work.
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Theoretically it should be re-used. I can try it. I tested your code and in both debug and release mode I could press the d key as many times as I wanted to before pressing q to quit, or just q to quit. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Peter Hull
Member #1,136
March 2001
|
Thanks Edgar. I must have misunderstood what AG was saying the problem was.
|
|