raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.03k stars 2.22k forks source link

[rcore] GIF recording depends on GetFrameTime() #4339

Closed infdivzero closed 1 week ago

infdivzero commented 2 weeks ago

If CUSTOM_FRAME_CONTROL is defined, CORE.Time.frame isn't updated and GetFrameTime() returns 0. In EndDrawing(), the GIF recorder calls GetFrameTime() and will never add GIF frames to the recording. UpdateCamera() also requires GetFrameTime().

I have a few ideas:

  1. Split out the gif recorder code. For example, the EndDrawing() code that updates the GIF could be called UpdateRecording(float deltaTime, ...).
  2. Allow GetFrameTime() to be overridden somehow, such as a callback, macro, or through static linking with a function defined in the application code. The last one seems hacky.
  3. Make CoreData CORE extern and define CoreData in a header, exposing CORE.Time.frame.
raysan5 commented 1 week ago

@infdivzero None of the proposed solution seems good enough, just adding code complexity to address a very specific use-case. CUSTOM_FRAME_CONTROL is intended for advance use case, users on that situation could easely adapt raylib for their specific needs.