Sign in to follow this  

multiple rendering contexts

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have two windows I would like to render to, each with their own HDC. I tried switching to the second window during rendering doing: wglMakeCurrent(hDCSecondWindow, hRC); where hRC is the only one created for both windows, but was created when the first hDC was made. I do this but nothing shows up in the second window, and rendering in the first window stops. How can I use the same hRC for both windows, but have rendering switch between the two ?

Share this post


Link to post
Share on other sites
Well I created and initialized 2 HDCs and 2 HGLRCs, but when I call wglMakeCurrent , my app crashes.

Here's the code



HDC MeshPreviewhDC, ViewporthDC;
HGLRC MeshPreviewhRC, ViewporthRC;

void Init()
{
MeshPreviewhDC = GetDC(PanelMeshPreview->Handle);

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,
};
int PixelFormat = ChoosePixelFormat(MeshPreviewhDC, &pfd);
SetPixelFormat(MeshPreviewhDC, PixelFormat, &pfd);

MeshPreviewhRC = wglCreateContext(MeshPreviewhDC);

if(MeshPreviewhRC == NULL)
ShowMessage("hRC == NULL");
if(wglMakeCurrent(MeshPreviewhDC, MeshPreviewhRC) == false)
ShowMessage("MakeCurrent failed.");


ViewporthDC = GetDC(Viewport->Handle);

PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0,0,0,0,0,0,
0,0,
0,0,0,0,0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0,0,
};
int PixelFormat = ChoosePixelFormat(ViewporthDC, &pfd);
SetPixelFormat(ViewporthDC, PixelFormat, &pfd);

ViewporthRC = wglCreateContext(ViewporthDC);

if(MeshPreviewhRC == NULL)
ShowMessage("hRC == NULL");
if(wglMakeCurrent(ViewporthDC, ViewporthRC) == false)
ShowMessage("MakeCurrent failed.");

}

void Render()
{
wglMakeCurrent(ViewporthDC, ViewportRC);
// render stuff

wglMakeCurrent(MeshPreviewhDC, ViewportRC);
// render stuff
}



The error I get is an error with atioglxx.dll

Share this post


Link to post
Share on other sites
I figured out why it was crashing.

In my call to SwapBuffers I was passing the Viewport's hDC, instead of changing it to the second hDC.

But it is possible to use a single HGLRC and two HDCs.

Share this post


Link to post
Share on other sites

This topic is 4730 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this