Some demo apps run slowly on ubuntu 11.04

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
uchan
Posts: 3
Joined: Sat Sep 10, 2011 12:42 pm

Some demo apps run slowly on ubuntu 11.04

Post by uchan »

Hello

When I run some demo programs, these run slowly. A window will be refreshed sometimes.
For example, when I run 06.2DGraphics, 2 imps flutter their wings about 1 time per sec (= 1FPS).
But when I run 01.HelloWorld and Demo, these run smoothly.
I think 2D programs are slow and 3D are fast.

This problem can be applied to my own program which uses draw2DImage().

My environment are listed below.
Irrlicht Engine version 1.7.2 (not apt package, I compiled it using g++ 4.6.1 and g++ 4.5.2)
Ubuntu 11.04 (Linux 2.6.38-11-generic-pae #48-Ubuntu SMP Fri Jul 29 20:51:21 UTC 2011 i686)
GeForce GTX 285 with NVIDIA Driver Version 280.13

And I found a quick-fix solution for this problem.
It is to select "Ubuntu Ubuntu(Safety mode)" or "Ubuntu Classic(no effect)" on login window.
I think compiz harms Irrlicht functions.

I don't know whether this problem is a bug of Irrlicht or not,
but I think many people are in trouble with this problem and I posted here.
I will be happy if this problem is fixed.

Thanks,
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Some demo apps run slowly on ubuntu 11.04

Post by serengeor »

I think I had this problem too, but then again most problems I had was the unity interface it self (too messy interface for me to work on :| ) so I just got rid of it. You should probably try posting this also on ubuntu forums.
Working on game: Marrbles (Currently stopped).
netpipe
Posts: 670
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Re: Some demo apps run slowly on ubuntu 11.04

Post by netpipe »

just put device->sleep(1); in the main run loop
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Some demo apps run slowly on ubuntu 11.04

Post by serengeor »

tecan wrote:just put device->sleep(1); in the main run loop
That's sort of a bad solution. Why would this even help with frame rate?
Working on game: Marrbles (Currently stopped).
uchan
Posts: 3
Joined: Sat Sep 10, 2011 12:42 pm

Re: Some demo apps run slowly on ubuntu 11.04

Post by uchan »

tecan wrote:just put device->sleep(1); in the main run loop
Thank you for the information.
I put it in the main loop, and the program runs smoothly.

I experimented with putting a for loop instead of device->sleep(1).

Code: Select all

while (device->run()) {
    if (device->isWindowActive()) {
        ...
        for (volatile int i = 0; i < 350000; ++i) ;
        ...
    }
}
The frame rate can be adjusted by changing "350000".

I found that a high frame rate causes the problem.
When the frame rate is too high (e.g. 4000FPS), I encounter the problem.
When I limit the frame rate (less than about 900FPS), the program runs smoothly.

I think that too high frame rate exhausts time for refreshing a window.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Some demo apps run slowly on ubuntu 11.04

Post by serengeor »

uchan wrote:
tecan wrote:just put device->sleep(1); in the main run loop
Thank you for the information.
I put it in the main loop, and the program runs smoothly.

I experimented with putting a for loop instead of device->sleep(1).

Code: Select all

while (device->run()) {
    if (device->isWindowActive()) {
        ...
        for (volatile int i = 0; i < 350000; ++i) ;
        ...
    }
}
The frame rate can be adjusted by changing "350000".

I found that a high frame rate causes the problem.
When the frame rate is too high (e.g. 4000FPS), I encounter the problem.
When I limit the frame rate (less than about 900FPS), the program runs smoothly.

I think that too high frame rate exhausts time for refreshing a window.
Oh I get why the problem happens now, but these two ways are still not the way to limit framerate because on lower end computers it may just make the app run too slow. You should instead use delta times between frames and pause for some time to make the time between frames the same(eg 16.666666ms for 60fps).
Working on game: Marrbles (Currently stopped).
uchan
Posts: 3
Joined: Sat Sep 10, 2011 12:42 pm

Re: Some demo apps run slowly on ubuntu 11.04

Post by uchan »

serengeor wrote:Oh I get why the problem happens now, but these two ways are still not the way to limit framerate because on lower end computers it may just make the app run too slow. You should instead use delta times between frames and pause for some time to make the time between frames the same(eg 16.666666ms for 60fps).
That's right.
I created FrameTimingProvider class that provides the end time of each frames.
The class can be used like this.

Code: Select all

FrameTimingProvider provider(60); // set a preferred frame rate
provider.set_base_time(timer->getTime()); // set the initial time
while (device->run()) {
    // do game logic
    now = timer->getTime();
    if (now < *provider) { // if the current time < the end time of this frame
        // draw all
    }
    now = timer->getTime();
    if (now < *provider) {
        device->sleep(*provider - now); // if there is spare time, sleep till the start time of the next frame.
    }
    ++provider; // advances a frame.
}
Post Reply