husker-dev / openglfx

OpenGL implementation for JavaFX
Apache License 2.0
80 stars 10 forks source link

Suggest renaming OpenGLCanvas#createTimer() #11

Closed orange451 closed 2 years ago

orange451 commented 2 years ago

The method name and input param seem to conflict with each-other. Normally when creating timers you specify the time in between each iteration. Whereas this is specifying the desired FPS.

Might I suggest renaming this method to OpenGLCanvas#setDesiredRefreshRate()

Also is there a way to unlimit the fps? No documentation that I can find currently (I don't think many of the methods have documentation)

orange451 commented 2 years ago

In fact the timer concept is quite confusing. createTimer() also seems to have the effect of applying the timer to the object containing the method. I think that's a pretty confusing API design for a public-facing API.

orange451 commented 2 years ago

To keep in the spirit of JavaFX, perhaps make the public facing api use a two-way bind variable to control refresh rate (DoubleProperty)? If you decide to go with it, maybe the public facing api could be: OpenGLCanvas#desiredFPSProperty(): DoubleProperty As well as OpenGLCanvas#getDesiredFPS() OpenGLCanvas#setDesiredFPS(double fps)

husker-dev commented 2 years ago

Yes, the Timer was created "just to be". In the future, I want to fully remake it.

husker-dev commented 2 years ago

I redesigned the Timer class. Now it’s called Animator. See the readme for details