View Full Version : GLSL shaders and multiple rendering contexts
05-08-2005, 10:56 AM
my app uses four different OpenGL views (rendering contexts). One of them is a 3D view and in this context I create some shader objects. The problem is that the shader objects don't seem to persist after the contexts are switched to another one and then back to the 3D context: glUseProgramObjectARB generates GL_INVALID_VALUE error.
If remove all but the 3D view and run the app then shaders work okay, so obviously RC switching is the cause. Is there any workaround for this problem? I've tried wglShareLists already, but to no avail.
I have WinXP SP2 and ATI Radeon 9700 with Catalyst 4.8 drivers installed.
05-08-2005, 11:30 PM
wglShareList should work. Look at the restrictions of that function to see if you aren't doing all allright:
You can only share display lists with rendering contexts within the same process
All rendering contexts of a shared display list must use an identical pixel format
HGLRC hglrc1, // OpenGL rendering context with which to share
// display lists
HGLRC hglrc2 // OpenGL rendering context to share display lists
hglrc2 Specifies the OpenGL rendering context to share display lists with hglrc1. The hglrc2 parameter should not contain any existing display lists when wglShareLists is called. If this still doesn't work, try this: you don't really need 4 RC for 4 views. You can create one RC and use it in all windows, simply you must stablish the same pixel format for all windows and make current the one that you need (remember that wglMakeCurrent has two parameters)
I tried that in the past and worked perfectly for me, and has avoided me to the boring task of maintain 4 different OpenGL rendering contexts
05-09-2005, 05:51 AM
Thanks for your help! Originally, I created the shader objects before calling wglShareLists. I changed it so that wglShareLists is called first and it started working!
I tried that in the past and worked perfectly for me, and has avoided me to the boring task of maintain 4 different OpenGL rendering contextsThere are some advantages to this. For example, separate GL state is automatically maintained for each view. This is useful especially if we have textured 3D view and wireframe 2D views.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.