Re: [AD] multiple windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I like it.



Elias Pschernig wrote:
I'm just playing around with a minimal display driver for the new API,
and it works like this:

AL_DISPLAY *display1 = al_create_display(640, 480, AL_WINDOWED);
AL_DISPLAY *display2 = al_create_display(640, 480, AL_WINDOWED);

Will give me two independent windows.

It works like this:

al_create_display() uses the system_driver to get a list of available
display drivers, e.g. the X11 driver, and creates an AL_DISPLAY with
that driver. The display driver will create a new window with an event
loop. To get e.g. keyboard events, you would do something like:

AL_KEYBOARD *keyboard1 = al_get_keyboard(display1)
AL_KEYBOARD *keyboard2 = al_get_keyboard(display2)

Then if you simply want to read keys from any window, you do:

AL_EVENT_QUEUE *queue =  al_create_event_queue();
al_register_event_source(queue keyboard1);
al_register_event_source(queue keyboard2);

AL_EVENT event;
al_get_next_event(queue &event);

Does it all make sense? So basically, xwin.c in 4.2 is not executed by
allegro_init(), but by each al_create_dispay().





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/