change frame rate

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.
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

Post by charles88 »

Hi guys, at last I manage to set the frame rate to 32 FPS by using multimedia timer:

Code: Select all

#include <irrlicht.h>
#include <windows.h>
#include <MMSystem.h>

#pragma comment(lib, "Irrlicht.lib")
#pragma comment(lib, "winmm.lib")

         :
         : 
         :
int main()
{
         :
         :
         :
    while(device->run())
        if (device->isWindowActive())
           {
                          :
                          :
                          :
              DWORD myTime = timeGetTime();
              while(timeGetTime()<(myTime+30));
                smgr->drawAll();
                          :
                          :
                          :
     }
            device->drop();

   return 0;
}

However, there are still little flickers left. :( sigh...

PS: thanks jontan6 for your code, have tried but not working maybe I set wrongly.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

charles88 wrote:Although my model doesn't pass through the wall, there are flickers when my model collide with it. My friend said the flickers are caused by the scene manager try to draw everything at a very high frame rate
I think your friend may want to look for another cause for that. Is there any chance that you could make your project (code and models) available, so that we can help you debug it?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

rogerborg wrote:I think your friend may want to look for another cause for that.
so do I... :lol:
charles88 wrote:Anyway is this the correct code to disable culling and setNearValue()? :P sorry was not quite familiar with irrlicht. :)

Code: Select all

node->setMaterialFlag(video::EMF_BACK_FACE_CULLING, false);
cam->setNearValue(10f);
no, not correct... ;)
try this:

Code: Select all

node->setAutomaticCulling(EAC_OFF);
cam->setNearValue(0.01f); // or maybe even smaller
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
charles88
Posts: 29
Joined: Tue Nov 04, 2008 10:02 am

Post by charles88 »

Hi, sorry for my late response. Yes, we found the cause of the flickers, it was not the scene manager but the terrain map that we were using. :( After we changed the terrain map, everything worked like a charm. :) lol... thanks guys for all your help, and please pardon my poor debugging skill. :oops:

PS: Thx Acki, I've tried your code on the map, but it still didn't work (yeah, because of my stupid map).
pakata
Posts: 18
Joined: Tue Sep 23, 2008 11:51 pm
Location: korea rep of

very simple...

Post by pakata »

Sleep(1000/30); // 1000 = 1 sec

before drawall()
jontan6
Posts: 278
Joined: Fri Jun 13, 2008 5:29 pm

Post by jontan6 »

charles88 wrote:Hi, sorry for my late response. Yes, we found the cause of the flickers, it was not the scene manager but the terrain map that we were using. :( After we changed the terrain map, everything worked like a charm. :) lol... thanks guys for all your help, and please pardon my poor debugging skill. :oops:

PS: Thx Acki, I've tried your code on the map, but it still didn't work (yeah, because of my stupid map).
maybe try simplify your scene next time to track down the problem easier
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Re: very simple...

Post by rogerborg »

pakata wrote:Sleep(1000/30); // 1000 = 1 sec

before drawall()
A note for posterity: this will not sync you anywhere near 30fps, since all Sleep() guarantees is that it will not return until sometime after the specified time.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply