Recent

Author Topic: Bouncing balls with Phong effect  (Read 376 times)

Roland57

  • Full Member
  • ***
  • Posts: 170
Bouncing balls with Phong effect
« 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 of an expert) from a program found on the excellent website corpsman.de.

Regards.

Roland.

circular

  • Hero Member
  • *****
  • Posts: 3710
    • Personal webpage
Re: Bouncing balls with Phong effect
« Reply #1 on: April 18, 2021, 12:44:55 pm »
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.
Conscience is the debugger of the mind

Roland57

  • Full Member
  • ***
  • Posts: 170
Re: Bouncing balls with Phong effect
« Reply #2 on: April 18, 2021, 04:03:48 pm »
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.

circular

  • Hero Member
  • *****
  • Posts: 3710
    • Personal webpage
Re: Bouncing balls with Phong effect
« Reply #3 on: April 18, 2021, 06:43:34 pm »
Yep, that fixes the problem.

Does it work the same way after this change on your system?
Conscience is the debugger of the mind

Roland57

  • Full Member
  • ***
  • Posts: 170
Re: Bouncing balls with Phong effect
« Reply #4 on: April 18, 2021, 07:05:51 pm »
Does it work the same way after this change on your system?

I have the impression that the movement is a little less fluid.

circular

  • Hero Member
  • *****
  • Posts: 3710
    • Personal webpage
Re: Bouncing balls with Phong effect
« Reply #5 on: April 18, 2021, 07:34:16 pm »
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.
« Last Edit: April 18, 2021, 07:56:47 pm by circular »
Conscience is the debugger of the mind

Roland57

  • Full Member
  • ***
  • Posts: 170
Re: Bouncing balls with Phong effect
« Reply #6 on: April 18, 2021, 10:03:20 pm »
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.)

 

TinyPortal © 2005-2018