I would like to write a simple GUI with textfields and buttons and so on. Are there are any good tutorials that adress something similar?

I have some GUI code in the example for the water rendering section of this book:

Download the code archive for it, there’s no tutorial on the GUI itself though.

Basically you follow mouse events and use it to track input focus (scaled to your viewport). Depending on the widget type you do different things on clicks and movements based on widget/mouse state. And of course you draw the widget in the right place altering appearance to reflect widget state.

Thanks a lot, I’ll check it out.

Hmm, I found a directory called “water” in chapter 8, but it doesn’t seem to work. There’s a directory called “MGLTemplate” which has an executable, but it requires MSVCR71D.dll.

You might also want to note that there already are projects which implement standard GUI functions on top of OpenGL. One of them is GLGooey:

I do not, however, know whether it is currently still being maintained.


You can get the missing dll here:

Nice work, Dorbie! And thanks!


Since the question was about a howto I thought some simple sample code would be preferred, if you actually want a gl based GUI off the shelf then there are obviously better options, something like FLTK for example:

or even PUI:

Sorry about the missing dll, it’s a known packaging issue that should have been fixed by now, since it’s supposed to be for developers who should have a VS.NET dev environment installed I guess it’s not seen as critical. The same dll is actually included elsewhere in the code examples.