multiple openGL irrlichtDevice

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.
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

Before rendering you have to tell which HDC to use.

So, if you are using an QIrrlichtWidget Class, declare HDC and Context in your header file:

Code: Select all

    HGLRC   My_hRC;
    HDC     My_hDC;
Following during your initialize part ::init()

Code: Select all

    My_hRC = wglGetCurrentContext();
    My_hDC = wglGetCurrentDC();
and before ->drawAll();

Code: Select all

wglMakeCurrent( My_hDC , My_hRC);

Make some noise if you got it working!
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post by bonsalty »

No, still stuck. Im using two win32 childwindows. wglGetCurrentContext() seems to be not an option, how does OpenGL know what context to give?



Interestingly works:


Adding HWND1 to irrlicht deviceA.
A_hRC = wglGetCurrentContext();
A_hDC = wglGetCurrentDC();

AddNodeA1 for deviceA
AddNodeA2 for deviceA
.
.

Adding HWND2 to irrlicht deviceB
B_hRC2 = wglGetCurrentContext();
B_hDC2 = wglGetCurrentDC();

AddNodeB1 for deviceB
AddNodeB2 for deviceB
.
.

Rendering both windows is ok this way.



What doesnt works. -if I add any node for deviceA after deviceB exists.

So:
B_hRC2 = wglGetCurrentContext();
B_hDC2 = wglGetCurrentDC();
AddNodeB1 for deviceB
AddNodeB2 for deviceB

AddNodeA3 for deviceA <- corrupted render later


the added NodeA seems to be rendered corrupted.



If I use :

hRC = wglCreateContext(GetDC(hWnd));
hDC = GetDC(hWnd);

instead of
hRC = wglGetCurrentContext();
hDC = wglGetCurrentDC();

I get two black windows...


:D :) :? :(
Tomi
bonsalty
Posts: 120
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Post by bonsalty »

So it looks like OpenGL simply sucks when you want to render into more windows from more then one device. Has anybody archieved this ever? Implementing threads is hardcore. I tried with boost. But when the device is initialised in thread, it is locked and cannot be accesed from other thread, from the main window for instance.

I see no other solution...
Tomi
HydroNom
Posts: 7
Joined: Thu Jul 10, 2008 8:16 am

Post by HydroNom »

I tried it with QThreads but whatever I do leads always to the same result, either one widget is not drawn, or - and most thread tests have unfortunately this result - even both.
I tested also some other cases, making a window and draw one widget there. Then open a second window (child of first) of same type. The widget there is drawn, but when the second window is closed, in the first is nothing drawn anymore. This also happens if I close the device before opening the second window and reinitialize it after second window is closed.
The only thing I'm wondering is that Qt is able to use OpenGL without any problems. So the problem can only have one reason: the Problem is not really OpenGL! The Qt initialization of OpenGL seems to be very different from Irrlicht.
But however, if you are limited to one window/device, the GUI advantages of Qt against all Irrlicht GUI implementations feels like you cut off your hands and feets. The only solution up to here is to use D3D but limiting to Windows for this reason is also a type of bondage ...
irrspring
Posts: 10
Joined: Tue Oct 05, 2010 6:38 am

Post by irrspring »

If I may ask, what version of Irrlicht use for this, that I am trying to make an application for Nokia devices over qt creator.

And how do you work as Irrlicht does not support Open GL ES ?

I'm very curious, and please help.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Irrlicht has an ogl-es driver in a SVN branch. It will move into the main engine sooner or later.
irrspring
Posts: 10
Joined: Tue Oct 05, 2010 6:38 am

Post by irrspring »

OK, I find version with OpenGL ES support, and It's good to now that there is a version for that, but why there are no more examples or guides how to create mobile phone projects using IrrLicht, for example for iOS, Android or in special case what I'm interesting Symbian devices.
Why there is no more explain about this ?


EDIT :

I manage to run the project with no errors in Qt Creator ( I use irrlichtfors60 ) , but I don't see anything in simulator ?

It's just wrote this :
Starting C:\Irrlicht\QT\irrtest2-build-desktop\release\irrtest2.exe...
C:\Irrlicht\QT\irrtest2-build-desktop\release\irrtest2.exe exited with code -1073741515
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Basically because most of us don't own the phones and devices, and building up a new tool chain costs a lot of time. Each tool and device comes with its own technique, we're simply not able to work with everything immediately.
Digan
Posts: 16
Joined: Tue Aug 24, 2010 11:21 am

Post by Digan »

QtGraphDev, many thanks for example. I modify it for Irrlicht 1.7.2 and Qt 4.7.1.
Escen wrote:Maybe try this to get it working.

First you have to make sure you are using a FPS camera.

Code: Select all

scene::ICameraSceneNode* cam = manager->addCameraSceneNodeFPS(0,100,0.5f,-1,0,false,0,false,true );
Tell QT to enable mousetracking when initialize the widget class, and grab keyboard.

Code: Select all

setMouseTracking(true);//enable constant mouse movement
this->grabKeyboard(); 

Declare mouseMoveEvent in your header file:

Code: Select all

virtual void mouseMoveEvent(  QMouseEvent* event );
Paste Method to your class:

Code: Select all

void QIrrlichtWidget::mouseMoveEvent(  QMouseEvent* event )
{
    irr::SEvent irrEvent;

    irrEvent.EventType = irr::EET_MOUSE_INPUT_EVENT;

     if ( device != 0 )
    {
    irrEvent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;

    irrEvent.MouseInput.X = event->x();
    irrEvent.MouseInput.Y = event->y();
    irrEvent.MouseInput.Wheel = 0.0f; // Zero is better than undefined


    device->postEventFromUser( irrEvent );
    }


   event->ignore();
};
... so... humn... (scratching head)
Don't do that to much, or you getting bald early.

Cheers,
Escen
Escen, thanks for it.
Image
YankzzDev
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: multiple openGL irrlichtDevice

Post by YankzzDev »

i got this error 1>.\main.cpp(18) : error C2039: 'addTestSceneNode' : is not a member of 'irr::scene::ISceneManager'

can somebody help me?

i try the code example
Nobody is Perfect!!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: multiple openGL irrlichtDevice

Post by hybrid »

Test node has been renamed to cube node in Irrlicht 1.2 or so.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: multiple openGL irrlichtDevice

Post by REDDemon »

bonsalty wrote:So it looks like OpenGL simply sucks when you want to render into more windows from more then one device. Has anybody archieved this ever? Implementing threads is hardcore. I tried with boost. But when the device is initialised in thread, it is locked and cannot be accesed from other thread, from the main window for instance.

I see no other solution...

Yeah I achieved it by using a mutex for renderings. So only 1 window is rendered and all other windows are waiting to enter the Critical section or doing other tasks wich not requires renderings.

Can happen that sometimes rendering is implicitly done inside a critical section. Only on newest machines this can happen explicitly without entering a critical section. (I think).

EDIT:

this is referred of course about 2 or more different windows using each one a different GLcontext and a different scene. I'm actually trying to solve the following problem:
Sharing a context between multiple windows, and sharing resources (hardware buffers, textures etc) between multiple contexts. I actually din't solved this problem (but looking at GL documentation this is possible) for making a decent WindowManager and SceneManager.
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
drcreep
Posts: 1
Joined: Thu Feb 16, 2012 11:39 am

Re: multiple openGL irrlichtDevice

Post by drcreep »

Hi,

i m trying to render two scenes in two qt widgets with irrlicht 1.7.2 on linux. What i did is:

- save the current ExposedVideoData after device creation in the widget instance

Code: Select all

 
    m_device = irr::createDeviceEx( params );
    m_exposedVideoData = m_device->getVideoDriver()->getExposedVideoData();
 
- add the ExposedVideoData to the beginScene method call

Code: Select all

 
void QIrrlichtWidget::autoUpdateIrrlicht( irr::IrrlichtDevice* device )
{
    if(device != 0)
    {
        irr::video::SColor color (255,0,0,0);
        device->getTimer()->tick();
        device->getVideoDriver()->beginScene(true, true, color, m_exposedVideoData);
        device->getSceneManager()->drawAll();
        device->getGUIEnvironment()->drawAll();
        device->getVideoDriver()->endScene();
    }
}
 
unfourtunatly i get an SIGSEGV on glXMakeCurrent (in COpenGLDriver::changeRenderContext)

can someone help me with that?
Post Reply