Hey,
I'm writing a fairly simple game however on older PCs (without OpenGL) there is a significant drop in FPS when drawing images. For example I am drawing clouds in a similar way to the LOVE demos. I changed the clouds to use a sprite sheet which has made the fps better though I have multiple images to draw for trees/enemies/bullets etc and it doesn't look like a sprite sheet is really meant for constantly changing objects like bullets. Is there a better way than sprite sheets or iterating through each object and drawing the image straight?
Thanks
tree
Efficient Image Drawing
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Efficient Image Drawing
A couple things in how you worded that have me worded. You you post an example of what you're doing?
Draw a handful of images shouldn't immediately devastate your FPS, spritesheets or not.
Draw a handful of images shouldn't immediately devastate your FPS, spritesheets or not.
Kurosuke needs beta testers
Re: Efficient Image Drawing
The images combined are probably rendering to 80% of the screen at once if that makes a difference? Tbh, the PC I'm testing this on is a bit weird. The FPS fluctuates constantly and reaches 40 FPS max even when using the sheets though is mostly around 20. I'm starting to wonder if its just this computer, though I want to at least try make it work.tentus wrote:A couple things in how you worded that have me worded. You you post an example of what you're doing?
Draw a handful of images shouldn't immediately devastate your FPS, spritesheets or not.
The actual drawing is something like this (don't have actual code with me atm):
Code: Select all
function love.draw()
for i = 1, Cloud.count() do
love.graphics.draw(cloudImg, clouds[i].getX(), clouds[i].getY(), 0, 1, 1)
end
end
There are 6 clouds 350px by 250px png format.
Last edited by thetree on Wed Feb 08, 2012 3:54 pm, edited 1 time in total.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Efficient Image Drawing
Yeah, nothing in that code looks like a problem. Odds are its the machine then.
Kurosuke needs beta testers
Re: Efficient Image Drawing
Ok, just wanted to check to make sure I hadn't done anything horrifically bad.tentus wrote:Yeah, nothing in that code looks like a problem. Odds are its the machine then.
Thanks for the quick response
Re: Efficient Image Drawing
Could you post a .love file so we can take a look anyway? I'm curious
Re: Efficient Image Drawing
Unless your Cloud.count hides something terrible like recalculating without need the clouds. love file please!thetree wrote:Ok, just wanted to check to make sure I hadn't done anything horrifically bad.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Efficient Image Drawing
What's your computer's hardware? I think some GPUs/drivers revert to software rendering when trying to draw an image with non power-of-two dimensions, rather than making it blank. Try using images with power of 2 dimensions, like 512x512 or 128x256 or whatever.
Re: Efficient Image Drawing
I'm using the latest 0.8.0 build to get round the PO2 problem, though I did try it with 0.7.2 and PO2 images but if anything it was slower.slime wrote:What's your computer's hardware? I think some GPUs/drivers revert to software rendering when trying to draw an image with non power-of-two dimensions, rather than making it blank. Try using images with power of 2 dimensions, like 512x512 or 128x256 or whatever.
Regarding the other code, I don't think thats the problem as I've already debugged the rest of the code to check its not my code. Commenting out the actual love.graphics.draw() function was the only thing that affected the FPS.
I don't know what the specs were, I was testing it on a PC that I do not own. I remember all the stats apart from the graphics ( Intel Core 2 Duo @ 2.2 GHz, 3GB RAM, XP Professional 32bit ), though its definitely integrated motherboard graphics. Intel HD or something similar would be my best guess.
As a side note, my main PC with all the normal stuff you'd expect on a mid/high range rig seems to be capped at 60 FPS, though my old crappy laptop doesn't have this cap and runs fine at ~150 FPS. This normal?
I'll test it on every machine I have access to and just check to see if its a problem with that specific PC.
Re: Efficient Image Drawing
Yes. LÖVE enables vertical synchronization (vsync) by default which limits the frame rate to the refresh rate of the display. This is 60 Hz for most displays today.thetree wrote:As a side note, my main PC with all the normal stuff you'd expect on a mid/high range rig seems to be capped at 60 FPS, though my old crappy laptop doesn't have this cap and runs fine at ~150 FPS. This normal?
You can change the setting with love.graphics.setMode, but the graphics driver can froce vsync on, off, or not support it at all. Keep this in mind while programming time-related game logic and animations.
Shallow indentations.
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 3 guests