Making a GUI with OpenGL
Posted on 2004-11-02
I'm looking for more of a discussion on this one rather than a specific solution. Basically, I'm looking to write a largely platform independent user interface using OpenGL as a base to render the various controls and windows. The main question/debate is is this a viable solution?
What I'm considering is using a similar method to how Windows works (i.e. using update regions, message maps to windows, etc), but making sure that I restrict the API calls to a small set which I can replace on a platform by platform basis in a seperate source file, with pretty much all of the graphics work being done using OpenGL. I want to be able to implement most of the standard windows controls (edit boxes, list boxes, etc), as well as writing something to allow windows and toolbars to be docked.
One aspect I'd like discussed is that I was planning on making the interface as fast as possible by using glReadPixels to cache the drawing of the rendered OpenGL windows to enable them to be dragged around, resized, etc. as fast as possible by either rendering the cached pixels as a texture, or by directly blitting the pixels to the window (the second option probably not being such a good idea for platform independence). The general idea is that this method would limit the amount of redraw and hopefully make the whole thing fairly fast. Then again... it might just cause slowdown if there are too many textures being created and thrown around in general. I don't know, hence this question.
Is this a good way of going about doing things, or does anyone have any better ideas?
The reason I want to use OpenGL is for various reasons:
- easy portability across platforms if it becomes necessary later on
- maximum control over the look and feel of the GUI (rather than using MFC as a base)
- total customisability - to allow for easy creation of various application specific controls
- to avoid the complexity of, say, writing ActiveX controls and getting into the whole ATL side of things
- to allow for maximum integration into any 3D viewports that I create
I'm looking for general feed back on these issues. Anyone raising negative issues on this direction of development will be just (if not more) as likely to receive points awarded to them. Don't hold back!
P.S. In case anyone noticed, I posted this previously in the OpenGL area. I didn't get any responses, so I deleted the original question and moved it here - I think this is probably a more appropriate Topic Area to post it in. I hope there's no problem with doing that.