|
Author |
Topic: 0046: differentiation between setup() and loop() (Read 271 times) |
|
Glen Murphy
|
0046: differentiation between setup() and loop()
« on: Dec 9th, 2002, 6:18am » |
|
I know this is more of a documentation thing (and probably doesn't belong in the bugs() section), but is there an explanation as to why output-related functions (eg, image()) in setup() fail? For example, if I were to create a program with a static background that could be drawnover, I can't set noBackground() and put image() in setup(); I have to put noBackground in setup(), and set image() to run only once in loop(). The code below explains what I'm doing: /////// IDEAL SITUATION //////// BImage imgbg; void setup() { size(300,400); noBackground(); imgbg = loadImage("bg1.gif"); image(imgbg, 0, 0); } void loop() { [draw things over the top] } /////////////////////// vs. what has to be done at the moment: /////////////////////// BImage imgbg; void setup() { size(300,400); noBackground(); imgbg = loadImage("bg1.gif"); } int first = 1; void loop() { if(first == 1) { image(imgbg, 0, 0); first = 0; } [draw things over the top] } ////////////////////////// Disclaimer: Since discovering P5, I've completely forgotten the intricacies of Java applets, so any dumbness is therefore not my fault. ahem .
|
|
|
|
fry
|
Re: 0046: differentiation between setup() and loop
« Reply #1 on: Dec 9th, 2002, 8:31am » |
|
how is it failing? just that those things don't show up, or that you're actually getting an error? from quickly looking at things, it seems like that should work from setup(), and if it's not, that could be a nasty bug. the situation you describe is why we have setup() versus loop(), so that the usual first == 1 code doesn't have to be written into every single program; so if that's breaking, that stinks and needs to be fixed.
|
|
|
|
Glen Murphy
|
Re: 0046: differentiation between setup() and loop
« Reply #2 on: Dec 9th, 2002, 10:05am » |
|
It doesn't display (white screen). I can't use any drawing commands in there, either. (commenting out noBackground() makes it a grey screen, as expected). At least now I know I'm not crazy.
|
|
|
|
fry
|
Re: 0046: differentiation between setup() and loop
« Reply #3 on: Aug 15th, 2003, 6:47pm » |
|
k, this should be fixed with the new compiler.
|
|
|
|
|