We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Background image framerate drop
Page Index Toggle Pages: 1
Background image framerate drop (Read 461 times)
Background image framerate drop
Apr 17th, 2009, 7:25am
 
Hi,
first of all sorry if this has been posted before or in the wrong section but the search terms for this problem are very common...

is there any way to have a background with an image and not get a huge drop in fps?

since i've added a background .jpg image to my looping sketch the framerate has dropped significantly. i suppose its due to the fact that the image is inside my draw() region and gets reloaded 60times per second (lowering framerate doesn't help). if i put it in the setup region it wont refresh like i need it to. you see my dilemma here...

.svg graphics of the same size work like a charm...maybe a small drop in fps but nothing major like with .jpg...

my computer should be able to handle the load (4gm ram, core2duo 2,1ghz)

thanks in advance
Re: Background image framerate drop
Reply #1 - Apr 17th, 2009, 8:05am
 
You can load it in setup, and draw it in draw, so you get it refreshing fast, without having  to reload it every frame:

Code:
PImage bg;

void setup()
{
//... normal setup stuff...
bg=loadImage("MyBackground.jpg");
}

void draw()
{
background(bg);
}
Re: Background image framerate drop
Reply #2 - Apr 17th, 2009, 8:52am
 
thank you very much... what a dumb mistake of me ><
especially because i did it right with Pshape without noticing Cheesy
Page Index Toggle Pages: 1