Register    Login    Forum    Search    FAQ

Board index » Everything




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post Posted: September 30th, 2017, 6:25 pm 
 

Joined: September 28th, 2017, 2:13 pm
Posts: 3
Location: Denmark
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 :?


Attachments:
Chili Framework 2016.rar [9.68 MiB]
Downloaded 5 times
Top 
 Profile  
Reply with quote  
 Post Posted: October 1st, 2017, 5:27 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2908
Location: Oklahoma, United States
Are you in Release mode or Debug mode?

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 1st, 2017, 5:41 am 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2908
Location: Oklahoma, United States
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.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
 Post Posted: October 1st, 2017, 12:17 pm 
 

Joined: September 28th, 2017, 2:13 pm
Posts: 3
Location: Denmark
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.


Top 
 Profile  
Reply with quote  
 Post Posted: October 1st, 2017, 5:58 pm 
 

Joined: February 28th, 2013, 3:23 am
Posts: 2908
Location: Oklahoma, United States
Yes, you would, doing it procedurally would really only cut down on the compile time in Release mode.

_________________
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com


Top 
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
 
Post new topic Reply to topic  [ 5 posts ] 

Board index » Everything


 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron