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.

Postby Escen » Wed Apr 28, 2010 8:52 pm

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!
Escen
Competition winner
 
Posts: 132
Joined: Sun Jul 19, 2009 11:27 am

Postby bonsalty » Thu Apr 29, 2010 1:16 pm

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: 111
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Postby bonsalty » Thu Apr 29, 2010 5:32 pm

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
bonsalty
 
Posts: 111
Joined: Thu Dec 10, 2009 1:30 pm
Location: Budapest,Hungary

Postby HydroNom » Mon Jun 14, 2010 8:11 am

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 ...
HydroNom
 
Posts: 7
Joined: Thu Jul 10, 2008 8:16 am

Postby irrspring » Tue Nov 16, 2010 1:25 pm

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.
irrspring
 
Posts: 10
Joined: Tue Oct 05, 2010 6:38 am

Postby hybrid » Tue Nov 16, 2010 4:48 pm

Irrlicht has an ogl-es driver in a SVN branch. It will move into the main engine sooner or later.
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby irrspring » Wed Nov 17, 2010 6:46 am

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
irrspring
 
Posts: 10
Joined: Tue Oct 05, 2010 6:38 am

Postby hybrid » Wed Nov 17, 2010 10:23 am

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.
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Postby Digan » Sat Apr 02, 2011 9:51 am

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
User avatar
Digan
 
Posts: 16
Joined: Tue Aug 24, 2010 11:21 am

Re: multiple openGL irrlichtDevice

Postby YankzzDev » Mon Oct 10, 2011 2:22 am

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!!
YankzzDev
 
Posts: 23
Joined: Wed Oct 05, 2011 4:37 am
Location: Indonesia

Re: multiple openGL irrlichtDevice

Postby hybrid » Mon Oct 10, 2011 7:26 am

Test node has been renamed to cube node in Irrlicht 1.2 or so.
hybrid
Admin
 
Posts: 13946
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: multiple openGL irrlichtDevice

Postby REDDemon » Tue Oct 11, 2011 5:19 am

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.
OpenGL is not hard. What you have to do is just explained in specifications. What is hard is dealing with poor OpenGL implementations.
User avatar
REDDemon
 
Posts: 831
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: multiple openGL irrlichtDevice

Postby drcreep » Thu Feb 16, 2012 11:53 am

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
cpp Code: Select all
 
    m_device = irr::createDeviceEx( params );
    m_exposedVideoData = m_device->getVideoDriver()->getExposedVideoData();
 


- add the ExposedVideoData to the beginScene method call
cpp 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?
drcreep
 
Posts: 1
Joined: Thu Feb 16, 2012 11:39 am

Previous

Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest