multiple OpenGL window problem and videodata question.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

multiple OpenGL window problem and videodata question.

Post 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?
Tomi
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

HWnd is automatically set. Maybe you didn't share the context properly?
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post 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.
Tomi
Post Reply