tags:

views:

1282

answers:

7

There are tons of GUI libraries for C/C++, but very few of them are based on the idea that opengl is a rather multiplatform graphics library. Is there any big disadvantage on using this OpenGL for building my own minimal GUI in a portable application?

Blender is doing that, and it seems that it works well for it.

EDIT: The point of my question is not about using an external library or making my own. My main concern is about the use of libraries that use opengl as backend. Agar, CEGUI or Blender's GUI for instance.

Thanks.

A: 

The obvious one is that you're basically building the GUI elements yourself, instead of having a nice designed like for wxWidgets or Qt.

rlbond
A: 

If you want a GUI as in windows/button etc. Don't do it yourself. There a lot of free solutions for this, wxwidgets,qt or GTK. All have OpenGL support if you want a 3d window

PoweRoy
+8  A: 

Here's an oddball one that bit a large physics experiment I worked on: because an OpenGL GUI bypasses some of the usual graphics abstraction layers, it may defeat remote viewing applications.

In the particular instance I'm thinking of we wanted to allow remote shift operations over VNC. Everything worked fine except for the one program (which we only needed about once per hour, but we really needed) that used an OpenGL interface. We had to delay until a remote version of the OpenGL interface could be prepared.

dmckee
Yes, this is the kind of answer I was looking for. Thanks dmckee!
alvatar
Good point. Generally anything that uses 3D acceleration will be invisible to apps like VNC. There are some ways to make it work, but it causes a lot of performance issues and so isn't a great idea.
Herms
I think to fix this you have to think an app as GUI-core-decoupled so you don't need VNC to control it.
alvatar
I was not involved in the solution, but they arranged to display the OpenGL on the remote host. A little clunky, but it meant I could sit shift in my PJs in my usual time-zone, so I was happy.
dmckee
Actually, there are several possibilities to use OpenGL enabled applications remotely, such as for example xvnc/xf4vnc, virtualgl or even just plain X11. The best solution depends on whether you want the OpenGL hardware acceleration to be done on the remote machine, or locally on the viewer.
none
+1  A: 

You cant just use opengl, you need a platform specific code to set up a window for opengl. From the freely available opengl red book:

OpenGL is designed as a streamlined, hardware-independent interface to be implemented on many different hardware platforms. To achieve these qualities, no commands for performing windowing tasks or obtaining user input are included in OpenGL; instead, you must work through whatever windowing system controls the particular hardware you're using.

There are multiplatform solutions for this like glut, qt, wxWidgets, ...

And if you have to use them anyway, why not use built in GUI elements. They also give you the opportunity to build your own, and make use of the framework to handle mouse/keyboard events and stuff.

Emile Vrijdags
It's very easy to make a multiplatform opengl program using preprococessor conditions and glut. It's far from using a huge library like qt for the whole GUI system.
alvatar
It very similar to make a multiplatform opengl program using qt: derive from QGLWidget; override initialiseGL, paintGL, resizeGL; assign your new class as mainwidget to a QApplication, and thats it. The library is bigger, yes. But i dont see the problem with that?
Emile Vrijdags
+2  A: 

Re-inventing the Wheel: Yeah, you'd be doing it. But I note OP used the word "minimal" in the problem statement, so assuming it really doesn't need to scale up to all that, it may be a small enough wheel as to not matter. The product I currently work on supports OpenGL on three platforms (Win, Mac, Linux) and we built all our own widgets (text boxes, buttons, dialogs). It's a lot of work but now that we've done it we own a huge chunk of our stack and don't have to debug into third party frameworks when things don't work as expected. It's nice having complete control of the experience. There's always something you want to do that a framework doesn't support. Like everything in our business, it is a trade-off and you just have to weigh your needs against your need to finish on time.

Portability: Yes, you will still have to write platform specific code to boot-strap everything. This will be difficult if you've not done it before as it requires you to understand all the target platforms.

Windows Drivers: We've found that graphics card manufacturers have much better support for DirectX on Windows than OpenGL, since that's what is required to get MSFT certification. Often low- to mid-range cards have bugs, missing functionality, or outright crashes in their OpenGL support.

jeffamaphone
+6  A: 

You're losing the native platforms capabilities for accessibility. For example on Windows most controls provide information to screen readers or other tools supporting accessibility impaired users.

Basically unless you have a real reason to do this, you shouldn't.

__grover
+1  A: 

With Qt 4.5 you can select if you want to use OpenGL as window renderer.

More info: http://labs.trolltech.com/blogs/2008/10/22/so-long-and-thanks-for-the-blit/

Read the comments to know about the problems about this.

xgoan