wxDialog Irrlicht

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
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

wxDialog Irrlicht

Post by strale »

Hello All

i would like to control the irrlicht in the dialog from an other dialog.

Serching the forum and pasting code i succeded in using irrlich into a popup dialog in wxWidget

Code: Select all

wxIRRDialog::wxIRRDialog(wxWindow* parent ,const wxString & title ,int Width,int height)
    :wxDialog(parent,-1, title, wxPoint(0,0), wxSize(Width,height) )
    ,GRF3D(wx_reinterpret_cast(unsigned long, this->GetHandle()), Width,height){


}
...
...
My problem :arrow:
is that, when my wxIRRDialog has not the focus the model is not rendered,
(but the application has the focus)

this, i belive occurs because wxwidget does not repaint the frame/windows without the focus (also if irrlicht render and send data to the wxwidget).

Does someone noticed this problem?

Does someone knows how to avoid this problem?,

may bee this a quirks of windows? if yes does it occurs also in linux?

Cheers
RoBaTte
Posts: 10
Joined: Thu Jun 07, 2007 2:34 pm

Post by RoBaTte »

You have to differ between no repaint and not reacting on user input. It could be, that Irrlicht is rendering your scene at 100 frames per second but only react on your mouse/keyboard actions, if your Dialog is manually focused.

You can easly check this, if you youse a helper like FRAPS or you write your fps into your captionbar (look at the 1. or 2. tutorial).

The thing is, that every "window" -- even your dialog -- has it's own windowprocedure, that threats your messages like input, repaint...(in Wx you won't see it, because it is capsulated). Normally, ever inyput is sent to your parent-window (and your dialog is "only" an child of your main-window), that means, that your dialog gets only explicit sent input (if it's focused).

Sorry -- a lot of bla.
1. use the animation-tutorial for create a simple animation and see if it animates without focusing your "irr-Dialog". Or use FRAPS to see your FPS.

2. If it works, you have to change your rewrite your message-workflow.
I can't tell you how, from here. First try and than repost.

Greetings. Rob
[/i]
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Thankyou Rob for the answare

i make the test for FPS copying from tutorial 2

Code: Select all

int fps = driver->getFPS();
...
When the Dialog lose the focus nothing is repainted
but as i clik on the dialog giving focus the FPS is incremented in relation to the time passed without focus.
so i assume that IRRLICHT works also without dialog having focus.

i have tried some way to force wxWidget to repaint:

Code: Select all

void wxIRRDialog::OnIdle(wxIdleEvent& event){

        wxIRRDialog::TickRun();
        event.RequestMore();
        return;
}

void wxIRRDialog::TickRun(void){

        //wxDialog::Show(0);

        GRF3DSgt::Draw3D();
        GRF3DSgt::RotateModel();

        //wxDialog::Show(1);
        //Refresh(FALSE);
        //wxDialog::SetFocus();
        //wxDialog::Raise();
        return;
}
TickRun is called from ("child Dialog OnIdle") and from the other OnIdle event of the parent window.

Every way to get around the quirk does not solve well the problem.

A):

Code: Select all

        //wxDialog::Show(0);
     ...
        //wxDialog::Show(1);
is slow, repaints the whole Dialog and the window repaint flickering


B):

Code: Select all

        //Refresh(FALSE);
        //wxDialog::SetFocus();
        //wxDialog::Raise();
Work but giving the focus to de dialog so i presume this will give problems
ex. traying to write on input in other dialogs.
:? anyway better than nothing.


Cheers
Paolo
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

What does your render block look like (the code which is usually in the main render loop in usual apps)?
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Hi hybrid

herre it is with the fps test

Code: Select all

void GRF3DSgt::Draw3D(void){

       Device->run() ;
       if (Device->isWindowActive()){
                driver->beginScene(true, true, colBackground);
                smgr->drawAll();
                env->drawAll();
                driver->endScene();

                int fps = driver->getFPS();
                  if (lastFPS != fps){

                     core::stringw str = L"Irrlicht ";
                     str += driver->getName();
                     str += ", FPS:";
                     str += fps;
                     Device->setWindowCaption(str.c_str());
                     lastFPS = fps;

                  }

        }
        return;
}

called always on wxWidget Onidle event ,
But i belive it s a window problem as Rob wrote

Code: Select all


void GRF3DSgt::RotateModel(void){

        if(node){
            vector3df NodeRot = node->getRotation();
            NodeRot.Y += 0.1f;
            node->setRotation(NodeRot);
        }
        return;
}

:D rotate correctly only when the wxWidget dialog has focus

:( if the "IrrlichtwxDialog" as not the focus the model stay still until i regive the focus.
:!: at this point the fps is updated with a considerable increment
and the model rotate of several degree much more than if irrlicht was still

sorry for my english

Cheers
RoBaTte
Posts: 10
Joined: Thu Jun 07, 2007 2:34 pm

Post by RoBaTte »

Allright,

I don't know wxWindow, so I can't give you explicit advices. But what you have to do is, to put the Irrlicht-main stuff
( driver->beginScene(true, true, colBackground);
smgr->drawAll();
env->drawAll();
driver->endScene(); )

in the message-loop of the main-window.

Remember the following:
After you created your window(s) you loose the controll of your "main-loop". Everything what is happening after this, is an (nearly) endless repeating of
peekmessage() ("is there any message for me?") and
translatemessage()
.

And if there is anny message, then the message-procedure of your (main)-window has to react on this messages.
If there is any message for a child-window (like your Irr-Dialog) then the message is forwarded to the message-procedure of this child-window.
And only then, in your case, your Irr-dialog is doing something (e.g., calling the Irrlicht-render-procedures). That's why you see only something if you force a action to your Irr-dialog.

So you have to put the Irrlicht-stuff in the message procedure of your main-window. You can let draw everything in another window with
driver->endScene ( (s32) hwndOfYourIrrDialog)

If you understand what I mean, try to to it. If not , then you have to post your whole code (godness).

Good luck. Rob
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

hi RoBaTte

Ok if i have understand: the irrlicht stuff is continuosly called (i have put a break point there) but may be it does not render the scene until his windows get the focus.

I have not posted the code as it is 9 different modules and i belivet it could be a bit difficult to get, so i posted only the "key part"

I will post if it could be useful to someone but in this moment i doubt :( .

i did not know about this
"driver->endScene ( (s32) hwndOfYourIrrDialog) "
il will check

Thank you
Paolo
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

I made an other test

i have run one of may irrlicht project and as the window of the project lose the focus irrlicht stop render the window and restart as the application get the focus.

same beavior of the wxDialog :? .

Cheers
RoBaTte
Posts: 10
Joined: Thu Jun 07, 2007 2:34 pm

Post by RoBaTte »

Hi,

It would be to easy, but did you try to remove the

Code: Select all

if (Device->isWindowActive()){
stuff?
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

Hi Rob


that was !

Code: Select all

if (Device->isWindowActive()){
that is copy and paste without reading ! :oops:
I just remouved and now work fine

as i have a good code i ll post it

Thankyou
Paolo
strale
Posts: 119
Joined: Wed Nov 23, 2005 1:58 pm
Location: Lambrugo Italy
Contact:

Post by strale »

hi all

i have just posted the wxIRRDialog code in the "Code Snippets" area

Thank again
Paolo
Post Reply