PDA

View Full Version : about wglsharelists



TracoBata
04-14-2009, 06:49 AM
Hi all,
i'm working in a project that renders a live 3D volume and i'd like to draw the volume on 3 windows with different clipping

When i draw the 3 windows with the same Render Context and only change the Hdc it works but when i tried to use wglsharelists to share between the render contexts it gives me solid white box and only the main volume [for which i made all the initializations an i want to share from it] drawn well but the others no
--------------
What i do:
1.WglmakeCurrent(hdc1,hglrc1)
2. make all the initializations and texturing for hdc1,hglrc1
3.getDc for hdc2,hglrc2=Null
4.SetPixelformat and create context for=hdc2,hglrc2
5.WglmakeCurrent(hdc2,hglrc2)
6.get the current hdc,hglrc and put them in tempHdc,temphglrc
7.wglMakeCurrent(tempHdc,temphglrc)
8.WglSharelists (temphglrc,hglrc2)
Note : WglSharelists returns true

and then at display loop :
//This part works i.e it displays on the 1st Window
WglmakeCurrent(hdc1,hglrc1)
MyDisplay();
swapBuffers(hdc2)

//this part doesn't display
WglmakeCurrent(hdc2,hglrc2)
MyDisplay();
swapBuffers(hdc2)
----------------------------
if any one noticed the error in my steps
or have a sample code for using WglSharelist that will be great

yooyo
04-14-2009, 07:22 AM
If you have only one thread you cant have 2 RC's current at same time.. So when you switch context call wglMakeCurrent(hdc1, NULL), then wglMaceCurrent(hdc2, hglrc2);

And from my expeirence, call wglShareLists when both shared contexts is *not* current. I know its strange but it works.

Ido_Ilan
04-14-2009, 10:16 AM
I also remember you need not create anything in the second context before sharing or it will fail.