Page 1 of 1

Massive framerate loss when drawing.

Posted: September 30th, 2017, 6:25 pm
by Magei00
Hi there.
I have been following the beginner series ( also some of the intermediate) to learn some c++, and a few days ago i finally decided to create my own project.
It's a simple arkanoid clone, using the basic concepts from lesson 1-8 + arrays and classes/objects.

My problem is now, that when i draw the breakable blocks my frame rate tanks, going from 120 to 37. I feel like this shouldn't be happening since it's not a complicated game by any means, but i also don't know what causes it or how to avoid it.

The only cause i can think of at this point is that the putPixel command isn't intended to be used so much?
Right now i call it approx. 218916 times each frame, which is a lot.

I've included my code, if that helps.

I hope you can help me out here :?

Re: Massive framerate loss when drawing.

Posted: October 1st, 2017, 5:27 am
by albinopapa
Are you in Release mode or Debug mode?

Re: Massive framerate loss when drawing.

Posted: October 1st, 2017, 5:41 am
by albinopapa
I get about 27 fps in Debug mode which you shouldn't really base your performance off of. As a comparison, I get 60+ fps in Release, with vsync enabled in the framework, I can't go above 60 fps on my monitor. You are probably correct about the PutPixel calls, though mostly because of the debug information attached when in Debug mode.

You could do away with the abundant putpixel calls with some procedurally generated objects. If you know how to interpolate between two numbers, you can write a draw function that will calculate the gradients used in your project.

Re: Massive framerate loss when drawing.

Posted: October 1st, 2017, 12:17 pm
by Magei00
Thank you!

I was running in debug mode and that caused the low framerate.
Changing to release fixed it :)

I'm not quite following the solution with procedurally generated objects. Even if the putPixel calls were done in a smarter way wouldn't I still be required to call them the same ammount of times?

I'm probably not gonna be toying with a solution like that anyway, but thanks for helping out.

Re: Massive framerate loss when drawing.

Posted: October 1st, 2017, 5:58 pm
by albinopapa
Yes, you would, doing it procedurally would really only cut down on the compile time in Release mode.