Beginner has a question about 3D drawing flicker

A simple program used to introduce people to 3D drawing was working fine the other day but now the image is flickering, why is it doing this and how can I stop it ?

size(100,100,P3D);
background(0);
translate(0,height/2,-height/4);
sphere(50);
translate(width,0,-height/2);
sphere(50);

Works just fine for me. But you should add all the code (include stuff like void setup() and draw()). I tried both background in setup and in draw and in both cases nothing flickered. It probably has something to do with either your complete code setup, or if that is really all the code you got, it might be an internal error in either your Processing, or maybe some other problem related to the execution of that code. Try doing the same in 2D. instead of sphere use ellipse() and delete that P3D part. Maybe also try using P2D instead afterwards.

Thanks, when I added all the code, setup() and draw(), the flickering stopped, and the 2D code works fine.

Wait, you executed the code without setup() and draw() ? Setup sets the size of the image and initializes everything, and draw repeats the code within itself, so technically draw can be left out, but setup() is needed to run any code and you also can’t run code outside of a function, so i don’t know how you did that, but that really would explain why it didn’t work^^. And although i say all that, i also tried to run it without anything and it just didn’t do anything for me, so i’m even more surprised… :slight_smile: Oh well, as long as it worked for you it’s fine^^

yeah, the code works to an extent without the setup() function or the draw(). it draws the shapes fine though they flicker back and forth between
black and white images