Skip to content

Conversation

@raj
Copy link

@raj raj commented Aug 21, 2024

add some timer methods

fun get_ticks64 = SDL_GetTicks64 : UInt64
fun get_performance_counter = SDL_GetPerformanceCounter : UInt64
fun get_performance_frequency = SDL_GetPerformanceFrequency : UInt64
fun delay = SDL_Delay(ms : LibC::UInt) : Void

@Hadeweka
Copy link
Owner

Hadeweka commented Aug 21, 2024

First of all, thank you!

A few things:

Firstly, the files in the src directory are generated automatically. A simple rerun of the generator script would just overwrite your code as it currently is, so you'd have to make sure that the generator scripts explicitely generate the bindings by using the SDL header files. You'd have to include the methods or libraries there.

Secondly, is there a specific reason to use the SDL time measuring functions over the ones natively provided by Crystal? Because so far I don't see the need for these methods. A similar discussion arose some years ago in another SDL repository:
ysbaddaden/sdl.cr#17

@charles-esterbrook
Copy link

Reasons to supply the SDL timer funcs:

  • Improve the experience for people following SDL tutorials and who may also be fairly new to Crystal (this happened to me).
  • In case there are differences in the implementations, the programmer has the option of using either to meet their needs.

@Hadeweka
Copy link
Owner

Hadeweka commented Oct 7, 2024

Compatibility with examples or tutorials is a good point, but then again the examples to this repository could simply be ported to work with the time functions provided by Crystal.

As far as I could read from the linked pull request, the methods provided by Crystal are more stable and extensive than the ones provided by SDL anyway. I am not aware of anything that the SDL timer library is better at.

Technically it would be no problem to include the SDL timer library, but essentially it is just a library that doesn't provide any new functionality - at the cost of requiring more maintenance.

@raj
Copy link
Author

raj commented Oct 7, 2024

yes i forgot to remove this pr, i use crystal method also

@raj raj closed this Oct 7, 2024
@raj raj deleted the performance-methods branch October 7, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants