Code not working, please help !

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.
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Code not working, please help !

Post by mark01 »

After finding out that showing an animation during the loading process is really complicated I decided to do a static loading screen. But even this is not working :(

I try to draw the Image only during the loading process and I think therefore I need a Begin and EndScene Command.

Loop for the picture during the loadingprocess looks like this:

do{

driver->beginScene(true, true, 0);
driver->draw2DImage(driver->getTexture "../00.HdM/Hintergrund2.jpg"),
core::position2d<s32>(0,0));

driver->endScene();
//driver->clearZBuffer();

} while (mesh = smgr->getMesh("../00.HdM/mesh.my3d")->getMesh(0));



After the loading Process the Titlescreen should change to the main loop where the main scene is drawn. I also need Begin and EndScene here.


while(device->run())
if (device->isWindowActive())
{
driver->beginScene(true, true, 0);

smgr->drawAll();

driver->endScene();
}



how may I handle this? Dont know how to do this withous 2 Begin and EndScene Commands. If I do it like this either the picture is drawn and it doesnt go through to the main scene or the picture is not drawn but the scene instead.

Please help
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Re: Code not working, please help !

Post by JP »

mark01 wrote: do{

driver->beginScene(true, true, 0);
driver->draw2DImage(driver->getTexture "../00.HdM/Hintergrund2.jpg"),
core::position2d<s32>(0,0));

driver->endScene();
//driver->clearZBuffer();

} while (mesh = smgr->getMesh("../00.HdM/mesh.my3d")->getMesh(0));
What the HELL is that??

Sure the code within the loop is right but you don't want a loop there and the statement within the while statement is completely wrong for what you want and will NOT loop whilst the mesh is being loaded anyhow.

I've posted how to do a progress bar in another thread last night, it may have even been for you, so just do what i did there!
Image Image Image
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

yes that was my thread but its not possible, because I only have one big mesh and not several where I put the progress information between.

only want to display a picture and erase it when loading is done :(
FuzzYspo0N
Posts: 914
Joined: Fri Aug 03, 2007 12:43 pm
Location: South Africa
Contact:

Post by FuzzYspo0N »

It seems a lot of ppl believe you are unable to use the draw functions of the driver and gui etc.

For example :

IGUImage* image = guiEnv->addImage(driver->getTexture("image.jpg"));

guiEnv->drawall();

LOAD MESH

image->remove();
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

I know the drawing calls, but dont know where to put it to get the loadingscreen only during smgr-getmesh()

with guienv->addImage I dont get a result at all.
Only a blank screen.

With draw2dimage I got a result but dont no where to put it because it should be only during the texture loading

please help
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

you will probably need two while loopers, one for showing the loading screen and the other one the scene itself.

in the first loop, you can load a very small scene with a one or two textures, probably add a sound node just for fun.

before you enter the first loop, setup the code for loading the second scene. then check for isloaded() and then break out of the first and enter the second one when loading is done.
Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

Code: Select all


mesh = smgr->getMesh("../00.HdM/mesh.my3d")->getMesh(0); 
do{ 

driver->beginScene(true, true, 0); 
driver->draw2DImage(driver->getTexture "../00.HdM/Hintergrund2.jpg"), 
core::position2d<s32>(0,0)); 

driver->endScene(); 
//driver->clearZBuffer(); 
g_isloaded = mesh->something_that_returns_is_loaded();
} while ( !g_isloaded ) ; 
i'm assuming smgr->getMesh() is non-blocking.

otherwise, let's think of another way.
Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Why loop at all? Just call the draw and then load. The reason that you usually have a loop around that stuff is that you want to change the screen 60 times per second (or whatever your FPS). As long as it's not changing you don't need to redraw it all the time.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
mark01
Posts: 32
Joined: Sat Sep 08, 2007 1:27 am

Post by mark01 »

I think it stucks during the smgr-getmesh call.
Im also not sure if a loop is needed because after loading with smgr->getmesh it would maybe be enough to erase the picture. But dont know how this is done.

Like said before the GUIEnvironment call dont work so I cant use the image->remove thing.

Also I dont know if its possible to do Begin - EndScende twice, perhaps the error lies within this issue

all I know is that when doing the thing like above without the while loop is that it stucks on the loading screen
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

how about using two scene managers?

you're using only one, though.

try two and see how it works.
Image
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

mark01 wrote: all I know is that when doing the thing like above without the while loop is that it stucks on the loading screen
Sure it's stuck. You wrote a do while loop which runs as long as smgr->getMesh returns a true result. So it loads - returns true - starts loading again - returns true - start loading... (well, it will actually take it from the cache after the first time, but still - it will just continue doing so infinitely)

Did you try to just remove the do-while? If I don't miss something here, then it's just not needed.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

it would be nice to have it in a loop because i'll be using this feature later when the camera is focused on a guided dialogue scene, while the next scene is loading.

this way, loading time is minimized.
Image
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

lol......just do:

Code: Select all

driver->beginScene(true, true, 0);
driver->draw2DImage(driver->getTexture "../00.HdM/Hintergrund2.jpg"),
core::position2d<s32>(0,0));
driver->endScene(); 

mesh = smgr->getMesh("../00.HdM/mesh.my3d")->getMesh(0);

That will show the loading screen.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yes, just do as Sudi says. That will display a static screen for the duration of the mesh loading and will remain until you start your rendering loop.

getMesh IS blocking, i.e. it won't return until the mesh has been loaded.

Some of you people really need to go and learn some C++!
Image Image Image
dlangdev
Posts: 1324
Joined: Tue Aug 07, 2007 7:28 pm
Location: Beaverton OR
Contact:

Post by dlangdev »

well, it's finally here...getmesh() is blocking.

no sirreee, it's not possible to animate while loading.

splatting a texture first before calling loadmesh() is the way to....

....go.
Image
Post Reply