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
_ FLTK
_ QT
_ …
For the win32 api, you can read the Nehe tutorial (nehe.gamedev.net) and modify the source to convert the openGL window (which is a parent window) to a child window.
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).
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.
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, www.qtcentre.org has a great forum that is more responsive than this forum! They are great. Good luck!