Form drawings flickering

ExcludeReality

Active Member
Licensed User
I have a problem with form drawings "flickering" on the screen.
I attached a small example of a 3D cube being drawn on the forelayer.
Use the arrow-keys to move the cube around. Every time the cube is redrawn it turns completely white and then appears.
I can understand this behavior because the cube is being redrawn very often and the forelayer is being erased just before drawing.
But I was hoping there is a better way to do this, or perhaps cover it up, so that it doesn't appear far too much.

Thanks.
 

Attachments

  • 3D Cube 2.sbp
    1.8 KB · Views: 354
Last edited:

derez

Expert
Licensed User
Longtime User
The way around this problem is to draw the cube somewhere else (another form or a bitmap object) and when drawing is complete - to copy the bitmap to the form.
In your code there is only one drawing action (fpoligon) each cycle so it will not change anything.
The erasing will better be done only on the cube area - you have its points from the last render action, instead of the whole form.

Running the code - I see only the existing image and not the drawing of the cube, and it fails on the second pressing of arrow. ????
 
Last edited:

ExcludeReality

Active Member
Licensed User
Running the code - I see only the existing image and not the drawing of the cube, and it fails on the second pressing of arrow. ????

I removed the existing image, so the whole cube is drawn on the forelayer. I also erase only the cube area of the screen.
But I haven't noticed any improvements. Please look at the new attached file.
 

derez

Expert
Licensed User
Longtime User
I had this problem before and ignored it - the poligon doesn't work with the old type parameters (xlist ,ylist) but only with the new method using one array of points.

I think this is a bug in 6.90.

The drawing takes time and this is the flicker you see.

I changed your program to work with array of points and I see the flickering, but the only solution for it is to draw on another form or bitmap and copy the new image to the form. This way the drawing is done while the image is still on the main form.

Check this http://www.b4x.com/forum/share-your-creations/3908-exercise-3d-rotation.html#post22546
 

Attachments

  • cube_2.sbp
    2.4 KB · Views: 352
Last edited:

derez

Expert
Licensed User
Longtime User
Here is a modified program without flickering. The picture is used to clear the form from previous drawing.
 

Attachments

  • cube_2.sbp
    1.8 KB · Views: 345
  • blank.jpg
    blank.jpg
    13.5 KB · Views: 313

ExcludeReality

Active Member
Licensed User
Here is a modified program without flickering. The picture is used to clear the form from previous drawing.

I get an error message while running the code. It has a problem with this line:
Form1.Polygon (List(),0,4,cGreen,f)
The message says that the value can't be null.

But anyway, I don't think drawing the polygon on one form then moving it to another will make any difference, since I only have one drawing action.
In addition, wouldn't it be more efficient to set the form color to gray than to load a gray picture?
 

derez

Expert
Licensed User
Longtime User
I get an error message while running the code. It has a problem with this line:

I guess that you are not running 6.90 because this works only in 6.90.

Use your program but draw on another form after "clearing" it with the picture. this is necessary because changing the background color does not affect the image of the form.
Copying the image by MainForm.image = Form1.image is immediate and does not cause flicker at all.

Edit: I attach the mod prog. Maybe you need to modify in the polygon line listx() to listx and listy() to listy

Edit: cube3 is doing it with imagelibEx instead of another form.
 

Attachments

  • cube2.1.sbp
    1.8 KB · Views: 349
  • cube3.sbp
    2 KB · Views: 375
Last edited:

ExcludeReality

Active Member
Licensed User
Use your program but draw on another form after "clearing" it with the picture. this is necessary because changing the background color does not affect the image of the form.
Copying the image by MainForm.image = Form1.image is immediate and does not cause flicker at all.

You're right, the flickering doesn't appear now. Thanks for your help.
And yes, I'm still running version 6.80.
 
Top