I'm still at solving technical issues
finally figured out a solution for the vsync problem:
- so the thing is the rendering and game logic was optimised out of the wazoo but there were still problems
- turns out swapping the buffers takes time too - and if vsync is turned on it pretty much blocks everything
- also I need to issue a glFinish (it just waits until all drawing operations are complete) otherwise I get weird flickering
- in theory the video card (or gpu) and cpu work in parallel so you could just wait until the gpu finishes
- but in practice the gpu driver is usually a weird black box where anything can happen inside
(e.g. you have no control over triple buffering - only works in fullscreen - or not - if the gpu feels like it - and afaik that is for every graphics api)
- so I had to move the rendering into a seperate thread
- which at first sounds sensible and obvious but sharing an opengl context between two windows is a minefield
- so now the game works great on my laptop (which is about 10 years old btw)
- works great on my potato machine for testing ( win XP and 20 years old)
- and goes completely wackoo on my third test machine (3 years old Win10 and has some bogus Intel celeron gpu)
- it's a driver problem on the last one but I cannot seem to update the driver (installer just doesn't start and it's supposed to be the latest )
- the good news is that the game is fully playable otherwise and there are just some graphical shenanigans .. but it bothers me
- now the strange thing is I measure about 10-12ms for the vsync swap on single thread
- but now that it's on a seperate thread it's only 1-2ms
- also all rendering had to be moved to the seperate thread because I cannot just swap in a different thread - I'm not sure why
- so my main problem is that things seem to behave a bit differently on every PC
- I looked into other frameworks and engines and they seem to have the same problem - so at least I'm not the one who got mad
- and I almost forgot the best part - in the end I had to revert to the old single thread rendering
because using more than one thread caused the textures to not load
(sharing textures between context just doesn't seem to work as intended .. or there is some black magic trick to it that I'm not aware of )
- in the end what optimisation that sort of worked is to put the cart before the horse: do the rendering first and then the game update
and in the end I gave up on vsync - of course this was just a quest to get vsync work with 60fps so nothing really happened
and there is now just a choice in the options to turn it on - with vsync on you get 30fps tops but no weird glitches
otherwise the game renders at 60fps and either has tearing or glitches or not
some exclusive shaky cam footage running on my mini-laptop (win10 and worlds crappiest gpu)
of course I didn't quite master recording and playing at the same time
anyway moving on to problems actually caused by my shenanigans:
- so I added an optimization where enemies don't bother to update their physics until they get activated
- this resulted in an amusing scenario - where I placed a miniboss on a vent
and after it notices you the physics kick in and he immediately flies upwards Mach3.. observe:
until next time!