veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.21k stars 221 forks source link

On Linux GetTicks64 always returns 0 while GetTicks returns correct value #545

Open geniot opened 1 year ago

geniot commented 1 year ago

I'm using x86_64 Linux distributive. sdl.GetTicks64() always returns 0 while sdl.GetTicks() returns a correct value.

veeableful commented 1 year ago

Hi @geniot, could you let me know what version of go-sdl2 is being used? I believe it has been fixed in the newer versions such as v0.4.27.

geniot commented 1 year ago

I've been using 0.4.27 since the initial commit of my boilerplate code: https://github.com/geniot/go-sdl2-cp-examples/commit/36994f6e2b2c2be3c1b4fcd66263c8ee23c12c26#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6 The finding and the fixes came later: https://github.com/geniot/go-sdl2-cp-examples/commit/e2bf3aac9b2b9bae4743abd774989f9ed70b6ef7 https://github.com/geniot/go-sdl2-cp-examples/commit/4209ea562a2c9fd55dba64b3729e8bd52e8a467f

veeableful commented 1 year ago

Thanks @geniot for the response. Could you let me know what version of SDL2 is being used?

geniot commented 1 year ago

2.0:

vitaly@vitaly-laptop:~/GolandProjects/go-sdl2-cp-examples/bin$ ldd go_sdl2_cp_examples 
    linux-vdso.so.1 (0x00007ffd7cfae000)
    libSDL2-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 (0x00007fc9019d8000)
    libSDL2_ttf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libSDL2_ttf-2.0.so.0 (0x00007fc9017d0000)
    libSDL2_image-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libSDL2_image-2.0.so.0 (0x00007fc9015a0000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc901381000)
    libSDL2_mixer-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libSDL2_mixer-2.0.so.0 (0x00007fc901160000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc900d6f000)
...
veeableful commented 1 year ago

Hi @geniot, if SDL2 2.0.0 is being used then it needs to be updated to at least SDL2 2.0.18 as that function isn't available in the older versions, according to https://wiki.libsdl.org/SDL2/SDL_GetTicks64

geniot commented 1 year ago

Thanks. I guess I'll stick with my fix as I'm also cross compiling for a handheld device where updating SDL2 is not so trivial. 49 days of game time is fine with me :)

veeableful commented 1 year ago

Hi @geniot, you can try our master branch which has SDL2 2.0.20 static libraries and build your game statically using the command mentioned here. They haven't been tested but it may be worth a shot.

geniot commented 1 year ago

Thanks for the hint. I'll definitely try later.