I have a sleep function.
Code: Select all
void sleep(float waitSec)
{
clock_t waitClock;
waitClock = (clock_t) (waitSec * CLOCKS_PER_SEC);
clock_t goal;
goal = waitClock + clock();
while (goal > clock());
}
Code: Select all
void draw5pictures (IGUIEnvironment * environment, IVideoDriver * driver, IrrlichtDevice * device)
{
button2 = environment->addButton(rect<s32>(10, 500, 138, 564), 0, 19, 0, L"Starts the Virtual ELA House");
button2->setImage(driver->getTexture("buttons/start.jpg"),rect<s32>(0, 0, 128, 64));
image1 = environment->addImage(rect<s32>(10, 10, 266, 266),0,0,0);
image1->setScaleImage(1);
image2 = environment->addImage(rect<s32>(270, 10, 536, 266),0,0,0);
image2->setScaleImage(1);
image3 = environment->addImage(rect<s32>(540, 10, 796, 266),0,0,0);
image3->setScaleImage(1);
image4 = environment->addImage(rect<s32>(144, 300, 400, 556),0,0,0);
image4->setScaleImage(1);
image5 = environment->addImage(rect<s32>(444, 300, 700, 556),0,0,0);
image5->setScaleImage(1);
sleep(5);
image1->setImage(driver->getTexture("pics/76.jpg"));
image2->setImage(driver->getTexture("pics/136.jpg"));
image3->setImage(driver->getTexture("pics/9.jpg"));
image4->setImage(driver->getTexture("pics/81.jpg"));
image5->setImage(driver->getTexture("pics/69.jpg"));
}
My problem is, that first the sleep(5) and only after that the whole function runs.
But i need the code run till sleep, after that sleep for 5 seconds, and after that the image1->setImage part.
What may be the problem?