Lazarus
Programming => Graphics => Graphics and Multimedia => BGRABitmap and LazPaint => Topic started by: Roland57 on April 18, 2021, 06:19:40 am
-
Hello!
Here are bouncing balls with Phong effect.
https://github.com/rchastain/collisions
Adaptated (with the help (https://www.developpez.net/forums/d1476320/autres-langages/pascal/lazarus/anti-aliasing-fond-noir-bibliotheque-bgrabitmap/#post8309416) of an expert) from a program (https://corpsman.de/index.php?doc=beispiele/pingpong) found on the excellent website corpsman.de (https://www.corpsman.de/).
Regards.
Roland.
-
Nice.
Note that it doesn't show anything on MacOS. To make it compatible, you need to draw within the OnPaint event of the form. So for example, call Form1.Invalidate after you have rendered and do the final Draw in the OnPaint event.
-
Note that it doesn't show anything on MacOS. To make it compatible, you need to draw within the OnPaint event of the form. So for example, call Form1.Invalidate after you have rendered and do the final Draw in the OnPaint event.
Done, thank you.
-
Yep, that fixes the problem.
Does it work the same way after this change on your system?
-
Does it work the same way after this change on your system?
I have the impression that the movement is a little less fluid.
-
Hmm
What if you call Repaint instead of Invalidate?
Note that is doesn't really fix this problem on MacOS but it might on Windows.
Edit: something that seems to work, is to add a boolean WaitingForDisplay. After calling Invalidate, set this boolean to True. In the Idle event, do not call render when it is True. And in the FormPaint, set it to False.
-
Hmm
What if you call Repaint instead of Invalidate?
Note that is doesn't really fix this problem on MacOS but it might on Windows.
Edit: something that seems to work, is to add a boolean WaitingForDisplay. After calling Invalidate, set this boolean to True. In the Idle event, do not call render when it is True. And in the FormPaint, set it to False.
I don't see a clear difference here (on Linux). Still less fast and smooth than the first version. (I did reset the code on GitHub to the initial state, so that everybody can try and compare.)