closing the window

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
moekkog
Posts: 44
Joined: Tue Feb 24, 2009 6:02 am

closing the window

Post by moekkog »

Is there any way to put some code to do something when the user close the window, especifically when he press the x button i have a loop but i want that when the user press the x button to close it a method end the loop is there any way to do it if it you have an example or something
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Yes, IrrlichtDevice::run() returns false when the device wishes to close (when the user presses X), so if you have code like so, you need only add code to the end of the loop:

Code: Select all

while ( Device->run() )
{
// Main Loop
}

// Code here will happen when the device is closed
moekkog
Posts: 44
Joined: Tue Feb 24, 2009 6:02 am

i had it a little bit different

Post by moekkog »

Code: Select all

while(device->run() && resultado !=50){
   //press esc
   // resultado == 50
}
I have that code but when the user close the window the program keeps continue in the background
Ion Dune
Posts: 453
Joined: Mon Nov 12, 2007 8:29 pm
Location: California, USA
Contact:

Post by Ion Dune »

Well, as long as you just want the window to close when resultado != 50, you could do this:

Code: Select all

while( device->run() )
{
   //press esc
   // resultado == 50 
   if ( resultado !=50 )
      device->closeDevice() ; 
} 
// on quit
moekkog
Posts: 44
Joined: Tue Feb 24, 2009 6:02 am

XDD

Post by moekkog »

i havent thought about that possibility once you see it you feel really dumb thanks

bad new i have tried and it doesnt work
i have a class could called de main class that pass de device as a aparameter to do other things the problem is if i close the window running the second class comes up an error if i close the program in the main class the program close right

editing for thirth time

i finally solve it thank for your advices they help me a lot thanks
Post Reply