extreme frame rate drop
Sylvarant

So I'm started using openlayer and one of the first things I wanted to do Is check my framerate, when I just did this :

1int main()
2{
3 // step 1 : setup the sytems
4 setup();
5 // step 2 : load stuff
6 TextRenderer arial = load_font("Fonts/Arial.ttf",10,15,Rgba::WHITE);
7 // actual game loop
8 while(!keypressed())
9 {
10 // start counting fps
11 FpsCounter::NewFrameStarted();
12// fill screen
13 Canvas::Fill( Rgba::BLUE );
14// print fps
15 float fps = FpsCounter::GetFps();
16 string frame_string = "FPS : "+ToString(fps);
17 arial.Print(frame_string,20,20 );
18 // Refresh the contents of the active canvas //
19 Canvas::Refresh();
20 }
21}END_OF_MAIN()

I got an average framerate of about 470

then I decided that it would be better to make a print fps function for the sake of keeping my main loop tight.
the function looks like this :

void print_fps(TextRenderer var)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : "+ToString(fps);
  var.Print(frame_string,20,20 ); 
}

and in my main I replaced the old code by print_fps(arial);

these actions downed my framerate from 470 to 37 fps average?
I know I must be doing something wrong but I have no clue what.

CursedTyrant

Shouldn't it be like this?

1int main()
2{
3 // step 1 : setup the sytems
4 setup();
5 // step 2 : load stuff
6 TextRenderer arial = load_font("Fonts/Arial.ttf",10,15,Rgba::WHITE);
7 // actual game loop
8
9 FpsCounter::Start(85); //or other value
10
11 while(!keypressed())
12 {
13 // start counting fps
14 FpsCounter::NewFrameStarted();
15// fill screen
16 Canvas::Fill( Rgba::BLUE );
17// print fps
18 float fps = FpsCounter::GetFps();
19 string frame_string = "FPS : "+ToString(fps);
20 arial.Print(frame_string,20,20 );
21 // Refresh the contents of the active canvas //
22 Canvas::Refresh();
23}
24}END_OF_MAIN()

HoHo

FPS doesn't change linearly with added scene complexity. How low does your FPS drop when you call the print_fps function two or more times?

Sylvarant

@cursedtyrant
I already do that in the setup function :

void setup() 
{ 
  // Sets up the devices needed
  Setup::SetupProgram(true, false, true);
  // Sets up the screen dimensions  
  Setup::SetupScreen(480,320,WINDOWED);    
  set_window_title("Project - Metroid Version 0.1");
  // Set up the delta time routines with the default fps of 100.0 //
  FpsCounter::Start( 100.0 );
}


@HOHO
it drops to 22.71 :(

Ariesnl

Do you have an AMD Dual core 64 bit ??

Richard Phipps

Comment out each line in the print_fps function and see how each line affects the FPS.

piccolo

I have an AMD Dual core 64 bit. dose it have something to do with the fps. I had some similar problem to what this person is having.
edit:
i would like to know what the amd could be at fault i notes that the the allegro cpu split dose not work as well on my cpu as it dose on a Intel single core of higher Mhz

Ariesnl

I have a AMD Dual core 64 bit processor.And I had speed/ timing/framerate problems with my own games and with professional games.
A few days ago I read an artickle about this it's a problem with timing (timestamps) and AMD Dual cores..

You should install AMD's Dual Core Optimizer!!!

It fixed everything for me and al games run a lot smoother with much higher and more stable FPS

HoHo
Quote:

A few days ago I read an artickle about this it's a problem with timing (timestamps) and AMD Dual cores..

Actually it should be a problem with XP, not specifically with AMD (or Intel) dualcores.

Ariesnl

It had something to do with correcting the timing for the fact you have 2 processors.

but that optimizer is a true gem.. Oblivion runs like a dream now ;D

Sylvarant
Ariesnl: said:

Do you have an AMD Dual core 64 bit ??


no I'm using an Intel pentium 4 .
what makes this really strange is the fact I've never had these problems in allegro.

Kauhiz
Quote:

what makes this really strange is the fact I've never had these problems in allegro.

Allegro and OpenLayer have little in common in this respect.

Kris Asick

Try this...

void print_fps(TextRenderer *var)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : "+ToString(fps);
  var->Print(frame_string,20,20 ); 
}

And call the routine with:

print_fps(&arial);

Just a wild guess, but it couldn't hurt.

--- Kris Asick (Gemini)
--- http://www.pixelships.com

monkeyCode
// or by reference :P
void print_fps(TextRenderer& renderer)
{  
  float fps = FpsCounter::GetFps(); 
  string frame_string = "FPS : " + ToString(fps);
  renderer.Print(frame_string, 20, 20); 
}

piccolo

thanks for the link i'm going to try it out now.

when i had a fps problem it was because i did not completely separate the update from the drawing

edit:
did you get it fixed i only get 170 max fps on my game i need more.

HoHo
Quote:

i need more.

With what HW and how many details? I wouldn't worry about speed bofore betatesting and when it is too slow with all the details. With empty gameworld any kind of benchmarking is meaningless

piccolo

i want it to run faster on slower computers im thinks that my main cpu load is the tile animation and layers world 100*100 32bit tile. 4 layers

HoHo

You think or you profiled? Never ever think anything. Profile!

Ariesnl
Quote:

You think or you profiled? Never ever think anything. Profile!

Assumption is the mother of all fuckups ;)

Fladimir da Gorf
Quote:

void print_fps(TextRenderer& renderer)
{
float fps = FpsCounter::GetFps();
string frame_string = "FPS : " + ToString(fps);
renderer.Print(frame_string, 20, 20);
}

Yeah, use a reference (or a pointer) to a TextRenderer, otherwise it'll regenerate all the character images and reload them to the video memory every frame...

Quote:

I already do that in the setup function

I'd recommend starting the FpsCounter right before the game loop, or otherwise it'll think that the first frame takes a long time to render and adjusts itself accordingly... Which means that you'll get a hiccup at the start of the game if you use the delta time.

Thread #589548. Printed from Allegro.cc