Making a GUI with OpenGL

Posted on 2004-11-02
Last Modified: 2013-12-03
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!

Many thanks,


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.
Question by:fxnut
    LVL 48

    Assisted Solution

    Did you learn existing solutions? You may use them directly or as samples for your own development.

    I am sure you can find more libraries.

    LVL 55

    Expert Comment

    by:Jaime Olivares
    OpenGL functions to manipulate bitmaps are really messy, and you have to pay attention to scaling options. I think openGL won't make a fast job for a traditional 2D GUI.
    Have you considered to use a portable GUI library like QT or wxWindows?
    LVL 1

    Author Comment

    Thanks for the GLUI link Alex. That could be pretty helpful for seeing how he implemented that. I'd be looking to do something similar.

    Jaime, I'd partly dispute what you said regarding speed, since I've done some tests with writing a Node graph editor and didn't find it caused too many problems. I was preferably looking for an answer in terms of performance with regards to the caching issue I mentioned in my first post. Scaling and bitmaps won't be much of a problem, since the majority of the bitmaps I'll be using will be for text (i.e. unscaled). BTW, QT doesn't offer a downloadable trial for Windows, so that's a no-go option.

    Anyway, I don't really want to use a third party library since I may want to use the software in a variety of ways (commercial or otherwise), and I don't think that any of the various GPL based licenses would accomodate that. But thanks for the suggestions.

    Can anyone comment a bit more about how feasible the project I mentioned above is? What pitfalls I may encounter?
    LVL 55

    Accepted Solution

    Well, it is totally feasible, AlexFM's link is proof of that. But as I said to you, OpenGL is a bit messy handling bitmaps, because its paradigm is texture-oriented.
    Read some discussions about that:

    There is another ready made GUI lib at

    LVL 1

    Author Comment

    Thanks Jaime, the links pointed to the sort of discussion I was looking for.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
    Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    875 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now