GUI in directx - online resources?

Started by
9 comments, last by circlesoft 18 years, 1 month ago
Hello, I am still toying with the idea of building my own GUI for my game. I was hoping to avoid it, due to the extra work, but have not had much success with existing GUIs out there. I tried the customUI SDK sample, but thats VERY slow, and dabbled with Crazy Eddies GUI, but it's very complex. Are there any others I could play with, or any advice online or books about how to go about this? At lease by doing my own, I could produce something original.... :) Many thanks Simon
Advertisement
Either you use "complex" GUIs like CrazeEddie or you go and make your own (like the majority) which will start simple and easy, but at the end it will also be "complex" and you will notice it ate lots of your time.
This is what happend to me ;)
One advantage of your own GUI is that it will perfectly fit into your game/app.
Can I ask -

Are the controls in your GUI entirely 'home made', or can you inherit some functionality from windows controls?

How do you go about structuring it? Are you continually checking the mouse position against all the visible controls?

I already have raytracing working for 3d objects in game - can I just use this for my GUI objects as well? Or should I just keep them in screen space?

Thanks for geting me started!

Si
Personally, I don't like CEGUI all that much. I've used it for one of my projects and I think that will be enough. It's rather easy to learn, but I dislike the use of singletons. It makes tracking down memory leaks harder. I like singletons in general, but one or two of em is quite enough.

I think i'll write my own GUI lib...sometime. =)
Quote:Original post by publicmmi
but at the end it will also be "complex" and you will notice it ate lots of your time.
Yeah, I agree - writing a GUI system has a tendency to "snow ball" and just get bigger-and-bigger-and-bigger [oh]

BUT it was a great learning exercise. Not so much for graphics/DirectX but more for OOP concepts and code construction. I made a few decisions early on that seemed to make sense but later came back to cause me a lot of trouble. Nothing like learning from your own mistakes [lol]

Quote:can you inherit some functionality from windows controls?
I don't think you'll be able to do this. Or, rather, if you could you'd probably end up with some fugly code that has lots of restrictions - to the extent that it probably won't be much better than what you'd have if you rolled it all yourself!

Quote:Are you continually checking the mouse position against all the visible controls?
You will find it's both easier to code and faster to execute if you design some sort of heirarchical system:

if( Mouse is in window )    Check_All_Frames        if( Mouse is in frame )            Check_All_Controls_In_Frame


That way if it fails one of the early tests you won't need to test any of the objects it contains...

Quote:Or should I just keep them in screen space?
Screen space is probably easier (unless you specifically hate the mapping texels to pixels thing [grin]), but putting it into projection space (or world space with an orthogonal projection) allows you to apply vertex shaders and other hardware transforms - which can be a pretty neat feature [wink]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

there's some pretty good tutorials on gui design here:
http://www.c-unit.com/tutorials/mdirectx/
tutorials 23-26 (managed c# though)

this is what i started with. it does have it's problems, it's not very fast for one. but it's a good starting point, and there are plenty of optimizations to be made.

hth,
n.
Quote:You will find it's both easier to code and faster to execute if you design some sort of heirarchical system:

if( Mouse is in window )    Check_All_Frames        if( Mouse is in frame )            Check_All_Controls_In_Frame


That way if it fails one of the early tests you won't need to test any of the objects it contains...


Yes, I imagined I might implement a heirachy, even a offshoot of my terrain quadtree....

Quote:putting it into projection space (or world space with an orthogonal projection) allows you to apply vertex shaders and other hardware transforms - which can be a pretty neat feature [wink]

hth
Jack


Hardware shaders are definately part of the attraction of producing my own implementation.


...............

To confirm - the best way to keep the speed up is to keep all components from one or two textures. One is a static one, with all the unchanging elements, the second is a dynamic texture rendertarget, used to draw occasionally, then reused frame to frame. This textureis redrawn when something changes.

Really dynamic stuff is just drawn straight to screen, without using the render target.

What do you think?

Si
You could also try the GUI which is given in the DirectX SDK.
It's quite easy to understand, you have almost anything that you'll need, and adding a new control is quite straightforward (I added a tree view control recently, took me half a day or so)

So I think it would be a good idea to look at that sample. It will give you a good start, and you'll probably learn a few things that will help you.
I've written a GUI and while its not the best or the most effecient, it can give you another idea.

my website

Go to the BX libraries and download one of the examples to get a feel for the GUI and then decide if its worth checking out. Source code provided.
Yeah, I've been using the SDK custom UI so far, but like I say, its very slow.

Thanks Joey, I will take a look...

This topic is closed to new replies.

Advertisement