Index:
[thread]
[date]
[subject]
[author]
From: Andreas Beck <becka@rz.uni-duesseldorf.de>
To : ggi-develop@eskimo.com
Date: Sat, 24 Jul 1999 14:01:58 +0200
Re: GII problems and transparent blitter
> <begin code snippet>
> for(;;) {
> struct timeval tv = { 0, 100 };
>
- if(ggiEventPoll(graphics->GetVisual(),
- gii_event_mask(emKeyRepeat|emKeyPress), &tv)) {
+ while(ggiEventPoll(graphics->GetVisual(),
+ gii_event_mask(emKeyRepeat|emKeyPress), &tv)) {
This will make it process all already queued events in one gulp thus
significantly improving performance.
Processing events is usually fast compared to drawing a frame of a game, and
you might want to process multiple inputs per frame anayway (the user might
have moved the mouse and pressed a key at the same time).
There is a silightly more advanced method of doing that. Have a look at
programs/utils/monitest/flatpanel.c:
ggiEventPoll(vis, emKey|emPointer, NULL);
events = ggiEventsQueued(vis, emKey|emPointer);
while (events--) {
ggiEventRead(vis, &event, emKey|emPointer);
...
> ggi_event ev;
> ggiEventRead(graphics->GetVisual(), &ev,
> gii_event_mask(emKeyRepeat|emKeyPress));
As Andrew already pointed out, using Press/Release and a flag variable would
be better, as it is not guaranteed that and what kind of repeat is there.
> The keypress event works fine, in that each time there is a keypress the
> ship turns as desired. However, we want constant rotation when the key is
> held down, and so we tried the emKeyRepeat event. This even works as
> desired, until the key is released, and the result is that the ship keeps
> spinning because there are so many emKeyRepeat events in the event queue.
That means, that you would as well encounter serious delays when pressing
another key. "Batch-"processing the events and then drawing should cure
that.
> What we need is the ship to stop moving as soon as the key is
> released...we'd like to be able to simply listen for the emKeyRelease
> event
That would come late with your code anyway. O.K. - you could add another
loop that only selects for the Release anyway thus bypassing having to read
the Repeats first, but that isn't exactly good style.
> and, when it is encountered, flush the queue of all queued
> emKeyRepeat elements.
This can be dong by just EventRead()ing them all out. But you should just
disregard the repeats for your case.
Another option BTW is using LibGIC which automates the event handling for
you. It gives you Descent-style input configuration. Look at
libgic/programs/demos/ggidemo.c for how it works.
> Also, on a somewhat unrelated topic, I've heard that a transparent blitter
> for GGI is currently nonexistent. Is anyone working on one, have plans to
> work on one, or are we on our own and must implement one ourselves?
I have one and I'll woork with Marcus on integrating all of it into a
Sprite/Overlay and a Blit extension as soon as he is back.
I can send you the code in the meantime.
CU, Andy
--
= Andreas Beck | Email : <andreas.beck@ggi-project.org> =
Index:
[thread]
[date]
[subject]
[author]