PDA

View Full Version : Strategy for offscreen and onscreen gl contexts



mckinnon
22nd December 2010, 02:01
Hi,
I am in the process of creating a QT application for some GPGPU code that I have been working on for some time.

I first use glewInit() then discover the capabilities of the card. Then I go about setting up an offscreen gl context using glut and a hidden window. This approach works well for my GPGPU computations (I use mostly FBO's).



glutInit(&argc, &argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
glutInitWindowSize(1, 1);
glut_id = glutCreateWindow("VWGL");
glutHideWindow();


Now I am process of writing a GUI using QT I am trying to work out the most effective use of textures for display. What I would like to do is to get my existing texture manager to be able to share the textures that it sets up in a pool with the on-screen gl context for QT. This would be ideal as it would save having to load textures from disk multiple times and have multiple copies in graphics memory for display.

In the QT gui I am building I will have multiple windows that will all possibly display the same GL textures at any given point in time. Reading other posts I have setup a hidden QGLWidget and then I am passing this to any new windows that are created using the const QGLWidget * shareWidget option upon the creation of the new QGLWidget's which seems fine.

My question is, can I share the textures created in the off-screen (glut hidden window) context with the shared on-screen context for QT. Or am I better of just making a new texture manager for QT and duplicating the loading of textures for the GUI?

I have a feeling that the second option may be better as this may allow for me to thread the GPGPU computations and not worry about the GUI context interfering with the compute context.

Any thoughts.

Regards,
Dave...