Allegro.cc - Online Community

Allegro.cc Forums » Game Design & Concepts » Game GUI, Part II

This thread is locked; no one can reply to it. rss feed Print
 1   2 
Game GUI, Part II
spellcaster
Member #1,493
September 2001
avatar

Quote:

Allegro doesn't support a feature that it, by all rights, ought to. Instead of pushing for Allegro to be more feature complete, you're suggesting we all simply force ourselves to use the codepaths that can be used to work around (aka: hack) Allegro's deficiencies.

No. I'm simply suggesting that you design with these limitations in mind if you want to use allegro. Anything else but these two other options would be stupid:
- Add the feature and submit the changes
- Don't use allegro.

But it's really, really stupid to know about a limitation, ignore it and then start whining. That makes no sense at all.
As far as I'm concerned, there's just one problem with the GUI for example: The fact that widgets use:

while (gui_mouse_b()) {
}

because that's really a bad thing.
The remaining problems can be dealt with with some effort.

Oh... and I did the search for you:

Bob said:

It would be possible if DDraw had facilities to do this. Unfortunately, it doesn't. This means that Allegro needs to destroy the DDraw surfaces, including all video bitmaps, then recreate them, every time the user moves the mouse to resize, and all while the application is drawing on to them at the same time.

Oh.. and one post above that post from Bob you realize for the first time that there's a GDI driver for Allegro... :)

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Korval
Member #1,538
September 2001
avatar

Quote:

Yes. I petition for Korval to fix the Allegro GUI.

No can do. I don't write pure-C code anymore, so it could never become truly part of Allegro.

Quote:

Oh... and I did the search for you:

Just because Bob said it doesn't make it true.

For example, I'm looking at a piece of MFC-based DDraw (IDirectDraw4) code right now that, while it does have to destroy it's back-buffer surface on resizing, it does not need to destroy it's other surfaces.

Now, granted, I'm no DDraw expert, so I could easily be misreading something. However, it certainly isn't destroying dozens of surfaces in its OnSize procedure. And it runs just fine. I can resize it, and it all just works fine.

Also, I would like to point out that, even if this deficiency in DDraw existed, that doesn't excuse not having the functionality if the user requests it. After all, Linux, *nix, and other OS's don't have these problems; only DirectDraw. As such, if you ask for an AUTODETECT_WINDOWED_TOOL, it simply won't be able to give you a DirectDraw surface.

Steve Terry
Member #1,989
March 2002
avatar

Quote:

while (gui_mouse_b()) {
}

I understand why the looping is a bad thing and I couldn't agree more, but do you have an example of a way around this? Besides that GUI's aren't really made for games, or to be drawn on top of a game, I don't really see the windows desktop displaying a full screen game while widgets are drawn on top... that's the whole concept of windows, make the game inside a window, that way the GUI has control over the game window. It's not that hard to put a game in a window anyway, my GUI pretty much does that with the spectrum proc, you could have anything inside that window.. even pong. I think that would be kinda nice to do one day is make a game completely inside a dialog box that's resizable and has menus etc. Then you could play the game and switch between windows, etc. like any other windowed environment that's currently out.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

spellcaster
Member #1,493
September 2001
avatar

The widget in question could request a "mouse grab" and get all mouse events until the widget releases it.
Another option (which wouldn't break older programs) would be to send an event just before entering the active wait.
This would allow helper procs to get into "mouse_wait_mode" (ie.: they know that they have to do special things, like refreshing the screen, etc)
As soon as the mouse button is released, send another event...

While this is just a workaround, it will allow add-ons to provide DRS and double buffering whithout breaking older gui programs.

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

For example, I'm looking at a piece of MFC-based DDraw (IDirectDraw4) code right now

Yeah... Allegro uses DX3. didn't you know? It may require a later set of headers to compile, but the interface it uses is pure DX3 IIRC.

Quote:

After all, Linux, *nix, and other OS's

IIRC, you can't ask to resize a DGA buffer either. Or an FBCon, or Svgalib... or a plain Allegro memory bitmap. Weird no?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Korval
Member #1,538
September 2001
avatar

Quote:

Allegro uses DX3. didn't you know? It may require a later set of headers to compile, but the interface it uses is pure DX3 IIRC.

That's no real excuse. Yes, you can use the DDraw3 device for systems that don't support higher DDraw versions (and you can even test which version is avaliable via some simple COM querries), but that is hardly an excuse for not even making the attempt.

Quote:

you can't ask to resize a DGA buffer either. Or an FBCon, or Svgalib... or a plain Allegro memory bitmap. Weird no?

You can't resize a DDraw4 surface either. That doesn't prevent a DDraw4 app from supporting resizing.

spellcaster
Member #1,493
September 2001
avatar

Stop complaining, add this feature, oh master Korval..

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Cage
Member #1,277
March 2001

Quote:

while (gui_mouse_b()) {
}

Why not, upon click of the mouse, set a global function pointer to whatever needs to be done from this widget, and then upon release of the mouse, run this? Or you could have it run it instantly, and have like this: (taken directly from sources from my project)

1// in getInput()
2 if(input==CHOOSE)
3 {
4 if(key[KEY_CHOOSE] || joy[which].button[choose].b)
5 {
6 if(!careAboutHeld) return 1;
7 else
8 {
9 if(!chooseHeld)
10 {
11 chooseHeld=TRUE;
12 return 1;
13 }
14 }
15 }
16 else chooseHeld=FALSE;
17 }

careAboutHeld is passed to the function to decide if we should care whether the button was previously held down. If it was, it won't register a keypress until you release, then repress it. chooseHeld is a static var within this function that tells us whether this key is currently held or not. It returns a 1 upon finding a keypress (although if the key was held and it's supposed to careAboutHeld, it will return a 0) and a 0 upon no keypress... perhaps not the best of code but you get the idea.
Therefore, you can still have stuff going on in the background, no need for any locking-up while loops or silly stuff like that.

Quote:

Ok, the old thread grew to long, and was turning into somthing getting in the flame direcion.

ahem ::)

-----
"I'm dumb!. it prolly wont do anything just like Sub7 when u extract it to ur own system I'm dumb!." - theforgotten
"heh i got hit by sub7 before. I just dont know how i got it. It took me about 2 yrs to figure out which virus i had. I'm dumb!. then i started wanting to hack and i got sub7 just ot play around with it and i found the features in it that i had been affected by when i got the virus." - theforgotten

Matt Smith
Member #783
November 2000

I'm still of the opinion that the Allegro GUI can be fixed by making it non-modal (optionally, for backwards compatability) and with object-hierarchy and a DRS levered in somehow.

The fewer changes that are made to the existing GUI standard, the less work is needed to learn it and adapt existing code.

MasKing and DeGUI are already a good start at a C++ wrapper. dlg is a good start at a dialog editor. I really don't see any great benefits to starting from scratch.

When I get a server sorted. I will post my docs and invite further criticisms and contributions of examples etc.

It's hard to design a GUI system from the top-down because you can't see any problems until you actually use it for real. I say go ahead and just write a few programs, do whatever you need to do to get it working, then have a look at the ugly hacks you needed and then consider how to smooth things out or hide the hacks inside the GUI behind a regular API.

spellcaster
Member #1,493
September 2001
avatar

Quote:

Why not, upon click of the mouse, set a global function pointer to whatever needs to be done from this widget, and then upon release of the mouse, run this? Or you could have it run it instantly, and have like this: (taken directly from sources from my project)

Yep, that works. But it's not really backwards compatible... ;)

Quote:

The fewer changes that are made to the existing GUI standard, the less work is needed to learn it and adapt existing code.

Agreed.
But if you take a look at the guis which work with double buffering and DRS, they need to override every widget (to ensure that no blocking occurs).

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Steve Terry
Member #1,989
March 2002
avatar

I still can use a while(mouse_b & 1) loop in my GUI by broadcasting MSG_IDLE to the entire dialog while within it, this seems to work for me, it's blocking, but not stopping any animations.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Stop complaining, add this feature, oh master Korval..

Exactly. You keep making this argument, yet do nothing about it.. Have you even contributed anything to allegro? ie: submitted a patch?

edit: You want it? Do it your self. I don't need it.. Otherwise, I'd probably do it myself. Just like when I needed/wanted alsa midi support, I wrote a patch for allegro and whoopa, it was applied. :o

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Oscar Giner
Member #2,207
April 2002
avatar

My gui lib doesn't need the loop: the gui engine itself controls mouse clicks, and only sends a mouse click msg if the mouse is pushed and released under the same object. Also, while the mouse button is down, only the object that got the mouse_down event gets the mouse events (so no event is sent to other object if you move the mouse over it).

spellcaster
Member #1,493
September 2001
avatar

Quote:

I still can use a while(mouse_b & 1) loop in my GUI by broadcasting MSG_IDLE to the entire dialog while within it, this seems to work for me, it's blocking, but not stopping any animations.

Yep. But assume you set screen to an offscreen buffer for double buffering. Since the method doesn't return, you can't blit to the screen, unless you have a dummy proc that blits to the (real) screen.
Hm.. guess I forgot to mention the MSG_IDLE / update method in my list of possibilities above ;)

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Steve Terry
Member #1,989
March 2002
avatar

I don't have a dummy proc... instead I overwritten the do_dialog procedure to call a function at intervals that takes care of updating the screen contents.

Something along these lines:

while(player = update_player()){
     update_screen(buffer);
}

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

spellcaster
Member #1,493
September 2001
avatar

Steve... in case of the button, that won't help you. since update_player() won't return until the button is released... or am I missing something here?

--
There are no stupid questions, but there are a lot of inquisitive idiots.

Johan Henriksson
Member #11
April 2000
avatar

as for tools, I might throw in, allegro mixes well with GTK. portable and everything.

Thomas Fjellstrom
Member #476
June 2000
avatar

Yes. But GTK sucks :) IMO.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Steve Terry
Member #1,989
March 2002
avatar

Spell, I think you may be correct there, that's why I actually have my update_screen() procedure in two places, one inside the dialog_proc(), the other after update_player(). When a button is pressed, the update fps goes down... since of course i'm determining my fps inside update_screen(). The code is in both places so either event won't stall the system completely, it's crude but works anyway.

[edit]
yeah pretty much the way it is, if I remove the call in the MSG_IDLE segment of my dialog_proc() it will freeze if I push a button, it also makes for some pretty interesting effects when dragging teh dialog box... it seems to pause, then redraw in the new spot, but updates the background very slowly. Removing the update_screen() call after update_player() however does very little, it just reduces the total fps, so I'm pretty sure that call is uneccessary. So yep.. pretty much you have to have a call to update_screen in at least one proc, or a proc that does it separately in order for DRS to work.
[/edit]

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

 1   2 


Go to: