Jump to content
  • Advertisement
  • entries
  • comments
  • views

Direct3D GUI

Sign in to follow this  


Got a bit distracted by writing a Direct3D GUI system. Click the below for a fullsize picture.

Nice, huh? All the windows can be dragged around by their title bar, child windows are automatically clipped and cannot be dragged beyond the bounds of their parent windows and the client areas of windows with title bars are seperate classes, so you can derive a class from GDX::Window, say to represent a list view or a drawing canvas, then create a GDX::Frame, passing a pointer to your custom class.

You automatically get a draggable, title barred and bordered window, but all the OnRender(), OnMouseMove() etc methods of your derived class automatically recieve client translated mouse-coords, clipped rendering space and any actual drawing calls, via the GraphicsDevice passed to OnRender, are automatically translated to the client area behind the scenes.

Here's a little demo if anyone wants to have a play around with it.

Alt-F4 to quit.

If you edit the convex.xcs file with Notepad, you can change the resolution if you want.

Edit gdx.xcs with Notepad and you can mess about with all the GUI colors. The colour strings are in the format "A R G B" (A - alpha).

This is quite a nice example of the usefulness of XCS actually. The gdx.xcs file looks like this:

// Convex 1.0 GDX configuration settings


hi { a="255 0 128 128"; b="255 0 64 64"; }
lo { a="255 100 100 100"; b="255 50 50 50"; }

fonthi="255 255 255 255";
fontlo="255 0 0 0";

hi="255 0 64 64";
lo="255 50 50 50";

It allows for quite nice organising of data in the config file, and reading it at runtime is as simple as, for example:

void GDX::Window::LoadSettings(const std::string &Base,const std::string &Xcs)
xcs::node Root;

if(!DefaultFont.Acquire(Base+Root["defaultfont"].value,256)) throw Exception(101,Base+Root["defaultfont"].value);





Colors is a std::map and ColorFromString() just parses a std::string into a D3DCOLOR_ARGB thingy.
Sign in to follow this  


Recommended Comments

Very nice demo! clean and elegant. Do you plan to add widgets, scrollbars etc.?

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!