17cupsofcoffee / tetra

🎮 A simple 2D game framework written in Rust
MIT License
909 stars 63 forks source link

Setting the swap interval at startup fails on some platforms #290

Closed 17cupsofcoffee closed 2 years ago

17cupsofcoffee commented 2 years ago

Summary

When starting up the game, some platforms (such as Raspberry Pi 3, or a VM) throw an error when we try to set vsync to be on/off.

We should probably just ignore errors in this case, as there's nothing we can actually do about them.

The alternative would be to throw the error and then have a specific 'ignore vsync errors' flag that could be set, but I don't like this, as you'd either have to retry building the context in response to the errors (which is extra boilerplate) or just always have it on (which defeats the purpose of making it configurable).

window::set_vsync throwing an error is fine, as the user has the choice to ignore it or handle it in that scenario (e.g. in a settings dialog, you'd want to tell the player if vsync wasn't working!).

Steps to Reproduce

Run any example on a Raspberry Pi 3 (though I can't verify this myself)

Additional Info

The suggested fix matches up with how FNA and Love2D handle vsync errors at startup (i.e. they don't).

Tairesh commented 2 years ago

I experienced the same issue in VirtualBox VM with Windows 7 where I tested my project.

17cupsofcoffee commented 2 years ago

Whether this will make stuff work in VMs I have no idea (not sure if it might run into further issues when it actually starts calling into OpenGL), we'll see!

Chronophylos commented 2 years ago

This might be because of a missing GPU

17cupsofcoffee commented 2 years ago

Fixed on main - I will release a new version over the weekend if I get time, but if you want to use this fix in the meantime, you can use a Git dependency.