Page 1 of 1

multiple OpenGL window problem and videodata question.

Posted: Mon May 03, 2010 11:23 am
by bonsalty
A question arises whether there is a chance to use two windows with two devices. DirectX is OK, but openGL is problematic. Normally there is the
wglMakeCurrent() and wglCreateContext() option for this in OpenGL.As far as I know, Irrlicht handles this with the SVideoData which can be used on rendering with driver->beginScene(true, true, 0, videodata);.

Taken a rip off from example 14 (irrlicht in win32). With only one window:

Code: Select all


//        Init device...
        . 
        .  

        if (driverType==video::EDT_OPENGL)
        {
                HDC HDc=GetDC(hIrrlichtWindow);
                PIXELFORMATDESCRIPTOR pfd={0};
                pfd.nSize=sizeof(PIXELFORMATDESCRIPTOR);
                int pf = GetPixelFormat(HDc);
                DescribePixelFormat(HDc, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
                pfd.dwFlags |= PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
                pfd.cDepthBits=16;
                pf = ChoosePixelFormat(HDc, &pfd);
                SetPixelFormat(HDc, pf, &pfd);
                videodata.OpenGLWin32.HDc = HDc;
                videodata.OpenGLWin32.HRc=wglCreateContext(HDc);
                wglShareLists((HGLRC)driver->getExposedVideoData().OpenGLWin32.HRc, (HGLRC)videodata.OpenGLWin32.HRc);
        }

.
.
.
while (device->run())
        {
                driver->beginScene(true, true, 0, videodata);
                smgr->drawAll();
                driver->endScene();
        }


Shouldnt be videodata.OpenGLWin32.HWnd set?
Second question if I implement window2 similar to the above settings, I got a black window and a corrupted render, why?

Posted: Mon May 03, 2010 9:11 pm
by hybrid
HWnd is automatically set. Maybe you didn't share the context properly?

Posted: Sat May 08, 2010 5:47 pm
by bonsalty
Ok I couldnt ask or answer, I wasnt here...

How should it be the correct way? I create the windows the correct way. I set the proper hWnd for the videodata. Then I use GetDC(hwnd) to get the device context for that window, this is also OK for videodata. And hRC is also set with wglCreateContext for each videodata. ShareList is also called, however I dont find it elegant to mix raw OpenGL functions with irrlicht calls...
From the two windows only one is rendereing and also incorrectly, everything looks black and white, images are not visible. What else should there be set? So how do I share the context properly?
The strange thing is, that leaving videodata and using wglmakecurrent doesnt help too.