All aboard the GUI boat!

Started by
1 comment, last by ph0ngwh0ng 20 years, 6 months ago
Hi there!! I am using DX9.0 and C++. I want to build a GUI for a game. Basically it would have all characteristics of a "normal" GUI: title bars, edit controls, list controls, buttons, etc. I have read many tutes and articles, and about all of them were using blitting for painting their windows and controls. Is this the only way to do it or can I use texturing also. I figured the mouse cursor could as well be a small textured quad, and a window with an edit control could be a bigger textured quad, with a smaller overlayed quad being the edit control? Your opinions? ph0ng^_^wh0ng
ph0ng^_^wh0ng
Advertisement
If you want to render a GUI in 2D you can use everything you want! Just render 2D triangles and everything is possible.
To make your life a lot more easy you could use sprites (see: D3DXCreateSprite for more info), this wil make drawing of texture in 2D a lot more easy...

Cheers,
Your on the right track ph0ngwh0ng. I recently developed a GUI using C++ and DX9 and it really wasn''t that bad. I used transformed (RHW) vertices. (These are vertices already in screen space). I created a "Widget" class which all other controls (dialog boxes, title bars, edit boxes, etc) inherit from. A widget basically just draws a textured quad at its position on the screen. It''s important to realize that each widget has a pointer to its parent and an array of its children widgets.

So for each type of control you want you just derive a class from the Widget and add whatever functionality you need. Another tip I can give you is that if you want your parent controls to clip their children (e.g. a resizable dialog box which clips its children) you can use IDirect3DDevice9::SetViewport so that widgets only draw within their clipped space.

Hope this made some sense. Heres an early development shot of the GUI I was working on:



Thats an edit box in the dialog with the button. Dialogs can be resized.

ATS

This topic is closed to new replies.

Advertisement