View Full Version : GUI + OpenGL = how?
08-15-2007, 12:09 AM
How can i make windows like GUI? currently I am making a program that is similar to the one this http://johanneskopf.de/publications/solid/viewer/index.html or anything like game's map/level builder
*GUI that can adjust values
*Graphical display that can render what the stuff i want
08-15-2007, 01:43 AM
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
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.
08-15-2007, 08:08 AM
thank you, one more question. what's the different in the different API u mentioned above?
08-15-2007, 09:05 AM
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.
08-15-2007, 09:56 AM
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 (http://www.relisoft.com/win32/index.htm)
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 (http://www.gamedev.net/community/forums/topic.asp?topic_id=456487&whichpage=1�) , too (The last post of the thread).
08-15-2007, 05:42 PM
What's the problem of MFC? is it very bad? (i rarely use C++ until recently =.=)
08-16-2007, 09:38 AM
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.
08-16-2007, 11:44 PM
thanks for the help, songho.
do you mind if i use your program as a skeleton codes?
08-17-2007, 10:13 AM
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.
08-21-2007, 01:34 PM
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 (http://www.qtcentre.org) has a great forum that is more responsive than this forum! They are great. Good luck!
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.