E ExcludeReality Active Member Licensed User Aug 27, 2010 #1 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 3D Cube 2.sbp 1.8 KB · Views: 462 Last edited: Aug 27, 2010
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.
derez Expert Licensed User Longtime User Aug 27, 2010 #2 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: Aug 27, 2010
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. ????
E ExcludeReality Active Member Licensed User Aug 27, 2010 #3 derez said: 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. ???? Click to expand... 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 said: 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. ???? Click to expand... 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 Aug 27, 2010 #4 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 cube_2.sbp 2.4 KB · Views: 478 Last edited: Aug 27, 2010
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
derez Expert Licensed User Longtime User Aug 27, 2010 #5 Here is a modified program without flickering. The picture is used to clear the form from previous drawing. Attachments cube_2.sbp cube_2.sbp 1.8 KB · Views: 466 blank.jpg 13.5 KB · Views: 486
Here is a modified program without flickering. The picture is used to clear the form from previous drawing.
E ExcludeReality Active Member Licensed User Aug 27, 2010 #6 derez said: Here is a modified program without flickering. The picture is used to clear the form from previous drawing. Click to expand... I get an error message while running the code. It has a problem with this line: Form1.Polygon (List(),0,4,cGreen,f) Click to expand... 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 said: Here is a modified program without flickering. The picture is used to clear the form from previous drawing. Click to expand... I get an error message while running the code. It has a problem with this line: Form1.Polygon (List(),0,4,cGreen,f) Click to expand... 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 Aug 27, 2010 #7 I get an error message while running the code. It has a problem with this line: Click to expand... 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 cube2.1.sbp 1.8 KB · Views: 453 cube3.sbp cube3.sbp 2 KB · Views: 493 Last edited: Aug 28, 2010
I get an error message while running the code. It has a problem with this line: Click to expand... 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.
E ExcludeReality Active Member Licensed User Aug 28, 2010 #8 derez said: 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. Click to expand... You're right, the flickering doesn't appear now. Thanks for your help. And yes, I'm still running version 6.80.
derez said: 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. Click to expand... You're right, the flickering doesn't appear now. Thanks for your help. And yes, I'm still running version 6.80.