views:

172

answers:

1

I want to design & implement a simple windowing & widget for OpenGL running on top of SDL, much like Agar or GiGi, only much closer tied to SDL & OpenGL.

My general problem is this: what is the best design for a windowing system within an OpenGL context??

I want to have windows just for controls, and, if even possible, threaded windows with their own OpenGL contexts. The only way I've though about it even being possible is rendering to textures, and them adding window decoration around those...

I want to expose the workings to other programmers, but which way would be best. I am more of a C++ programmer and so inheritance was the first way I thought of. Make basic classes which I expose in a shared header file, the programmer then derives their own window object from that, overriding the Init() or Run() methods to implement what they need. The problem with this approach would be keeping the programmers in check, there would be no real way to 'keep' them from simply drawing wherever they want in the OpenGL screen.

Another possible way would be functors, passing the functors the programmer wants to use into the library which then calls it once it's finished rendering it's GUI components and what-not.

What is the best way of approaching any of this??

A: 

windows with their own OpenGL contexts

That's going to require hacking SDL, since it only provides one context per process. Unless you're thinking of doing a single GL context with multiple independent sub-viewports rendered in sequence.

genpfault
That's a very good point, messing with SDL itself wasn't really what I had in mind.Viewports work, except in handing off the drawing outside of the library. I was thinking more of using Frame Buffer Objects for the users 'rendering surface', then just texturing a quad for the window with some decorations.
Tim Jones