Main Contents

Hybrid GUI Beta

May 21, 2008

As some of you may have read, I’ve released a beta version of my new GUI toolkit, Hybrid.

The projects section of my website has been listing Hybrid for quite some time, yet that version was merely a prototype. The current one is actually a third installment of my OpenGL-powered GUIs. Be it a photon mapping program or some interactive walk-through, I’ve always wanted to have an in-game / in-engine GUI to play with. Using external controls, such as a separate MinWin pane next to my OpenGL context just didn’t feel right. So I rolled my own.

The first one was a rather classic retained-mode GUI that could make pictures such as:

gui1.png

It also had a more grayish look. Nevertheless, what pissed me off the most about its programming model, was that I had to create tons of wrappers, ‘GUI action handlers’ and separate the program into GUI init, action binding and event handling. In some cases it would’ve been much nicer to just inline e.g. the button actions in normal code, somehow.

Then I watched the excellent video about Immediate Mode GUIs from Casey Muratori, read some of the posts on Molly Rocket’s forums and decided that I wanted an IMGUI too. But I didn’t like all of the features of a classic IMGUI, such as the manual ID management, stuffing all logic of widgets only in functions and delegating a lot of power to the widget, instead of something that looks upon it. Of course, there were alternatives, some were even proposed in the follow-up posts.

So the idea was to create a GUI that lives somewhere between immediate and retained modes. The API must be immediate mode, but widgets should be able to store any state behind the scenes without the user programmer explicitly saving it somewhere. I wanted to be able to define widgets as simple classes, by overriding a few methods and leaving the rest to a common base. This is how the prorotype of Hybrid was conceived. It turned out ot be a bit messy because of some rather weird design choices at the very beginning, but it worked really well for Deadlock and some toy apps, such as a draft of a shader editor:

hybridproto1.png

hybridproto2.png

hybridproto3.png

It was pretty pleasant to work with, in general. Yet, some ID management quirks were still there, and well - it was just a prototype.

Some time after finishing Deadlock, I took a univ course in ‘Software Analysis and Engineering’. After complaining to the lecturer, that the Waterfall model is not the best thing around, I was asked to make a non-standard project for the course. Most other folks on my year got project assignments and worked in teams. My objective was to create … documentation for Hybrid.

But well, who creates user-docs for a prototype? So I took the opportunity and rewrote Hybrid from scratch. This time I needed it to support some retained mode constructs in addition to the immediate mode API.

This is the result. And it makes nice pictures too:

hybrid1.png

So what’s the future of Hybrid? As written in the TODO, I’ve got some things to implement still. Probably easy style and css-ish widget-class management is going to be the most important. Animation of arbitrary properties will also be a must-have if it’s to become a useful game GUI toolkit. On top of that, I’ve got some widget orders that I need to deliver, such as a color picker… I’m considering (s)RGB + XYZ + HSV + Spectrum - based picking :P

There also remain a few usability and stability issues, but that’s the reason it’s a Beta and not a final release.

Filed under: Uncategorized | Comments (8)

DShade

January 19, 2008

The image in my ‘HAI WORLD!’ post, just as the following one …
DShade screenie #5

… was rendered with DShade, a 3d software rasterizer of mine.
DShade is mostly an experiment at abusing the D compiler, created a year ago as a final project for my “Graphics and Multimedia” course.

Thanks to some of D’s features, it can do simple software vertex and pixel shaders with on-the-fly recompilation and reloading. It also supports bilinear-filtered texturing, perspective-correct attribute interpolation, Sutherland-Hodgeman clipping, backface culling, z-buffering and alpha blending.

The demo app features a very simple loader for q3 bsp levels, it can also display ‘HME’ models, a custom text-based format exported from 3dsmax.

As far as the software shaders are concerned, these are actually parts of D modules, that get mixed into a wider scope, where they can be inlined in tight rasterization loops. Additionally, some metaprogramming tricks detect the inputs and outputs of the shaders in order to automatically extract and interpolate all required vertex parameters needed for the shader.
Each shader gets mixed into a Renderer instance and compiled into a dynamic library, which can be recompiled and reloaded when needed.

The user interface to DShade is fairly simple. ‘WSAD’ keys control camera movement; Holding the right mouse button and moving the mouse pointer allows camera rotation; The left button is used to bring up a context menu for objects. From this menu, shaders and textures can be changed, hierarchies between objects may be defined and simple movement can be specified. Hit space to bring up a menu for object creation.

While the program is running, try editing one of the files in the shaders/ directory. Saving it should trigger an automatic recompilation and reloading of it within DShade. The console window will contain error logs if something goes wrong.

Please note that DShade doesn’t make use of SSE or 3dNow or MMX, it may contain bugs and can bring very fast CPUs to their knees. If shaders don’t want to recompile, make sure you have DShade located in a path not containing spaces. Build/DMD/OPTLINK can get a bit lost with them.

Also note that DShade was conceived when DDL’s OMF backend wasn’t very stable. If I were to rewrite it, I’d definitely use DDL on Windows.

Hint: deleting the level from within the context menu will speed things up a lot.

You can download DShade along with its source code and play around (run Main.exe). Out of my pure laziness, the shader compilation and loading system only supports Windows.

P.S. Thanks to Walter Bright for allowing me to distribute a stripped-down version of DMD and OPTLINK with DShade :)

Filed under: Uncategorized | Comments (5)

HAI WORLD!

January 18, 2008

CAN HAS DEVLOG? KTNX.

DShade screenie #3

Filed under: Uncategorized | Comments (5)