GUI + OpenGL = how?

How can i make windows like GUI? currently I am making a program that is similar to the one this or anything like game’s map/level builder

*GUI that can adjust values
*Graphical display that can render what the stuff i want

Every good GUI API allow the use of an OpenGL area (in a canvas or in a child window,…).

This is an example list of GUI API which support OpenGL:
_ Win32 API or Winforms under Windows
_ wxWidgets
_ GTK+
_ FoxToolkit
_ QT
_ …

For the win32 api, you can read the Nehe tutorial ( and modify the source to convert the openGL window (which is a parent window) to a child window.

thank you, one more question. what’s the different in the different API u mentioned above?

win32 API : well, its windows, that means extensive but non-portable. can be messy too.

GTK+: I found it messy

QT: full featured, portable.

FLTK: simple and portable, I would say for a level editor is would be a good choice.

It is your decision to choose a GUI API for your project, but I’d like comment about using Windows API alone without MFC or .NET.

There is a very good Window API tutorials explaining how to create Windows GUI applications without using MFC.
Windows API Tutorial

Based upon the tutoral, I built own a framework for OpenGL GUI applications using MVC paradigm (Model-View-Controller).

Here is a screenshot of an example and code:

Model component is the brain part of the application containing all OpenGL implementations. View component is a Windows specific part; getting a rendering context from Windows, rendering the visual by swapping the buffers, defining all controls(buttons, textboxes), etc. Controller component is handling user input, such as keyboard and mouse movements.

For example, whenever a user slides a trackbar (declared in Controls.h), ControllerFormGL module captures WM_HSCROLL message first. The message handler for WM_HSCROLL in CotrollerFormGL gets the current position of the cursor, and then tells ModelGL component the current value of the background, and at the same time, ControllerFormGL module sends the current cursor position to ViewFormGL component, so the cursor position of the trackbar can be updated.

I posted a detailed descriptions on other forum. Please check this post , too (The last post of the thread).

What’s the problem of MFC? is it very bad? (i rarely use C++ until recently =.=)

Originally posted by GameProgrammerWannabe:
What’s the problem of MFC? is it very bad? (i rarely use C++ until recently =.=)
MFC is not really bad, but every API has both cons and pros. For me, the advantages of MFC could not overcome its disadvantages.

MFC provides a thin layer over Windows OS for rapid development and hides some aspects of Windows API. But, using MFC still need basic knowledges of the underlying OS, for example, how Windows message loop works.

The above application (glWin.exe) is about 40KB, and does not depend on a heavy MFC runtime DLL (~1MB, .NET Framework is much larger, +10MB). It is simply too complex for my needs.

thanks for the help, songho.

do you mind if i use your program as a skeleton codes?

Originally posted by GameProgrammerWannabe:
do you mind if i use your program as a skeleton codes? [/QB]
I don’t mind. I love to share it with anyone. Please contact me if you have any question regarding to the design or implementation.

I would recommend using Qt. It is a great GUI API for C++. I have used it extensively with OpenGL for over a year now and have had no problems with it. I have created an OpenGL plotting library and displayed it inside Qt for Solaris 8, Solaris 9, RedHat 4 32-bit, RedHat 4 64-bit, and Windows XP with minimal or no code change. It is because OpenGL and Qt are both cross-platform.

Qt has an excellent documentation located on their website. It is free to use (unless you plan to use it commercially, then there is a commercial license) and real easy to grasp. I prefer to write the code myself but Qt comes with a Qt Designer program for a WYSIWYG GUI developer. Good luck with your developing but if you choose Qt and have problems with it, has a great forum that is more responsive than this forum! They are great. Good luck!