17cupsofcoffee / tetra

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

Is the OpenGL layer safe? #117

Open 17cupsofcoffee opened 5 years ago

17cupsofcoffee commented 5 years ago

...probably not!

This is a tracking issue for ensuring that the OpenGL layer in Tetra makes correct use of unsafe, and that there's no way to cause undefined behavior via Tetra's API.

Long term, we might want to move to using a more established library for the graphics backend (#51), but in the short term we should probably at least avoid shooting ourselves in the foot.

Issues found so far:

cheako commented 5 years ago

I wonder how much it maters? At some point u decide that all new development is against Vulkan... Though I know it's not well supported on OSX, there are projects looking to fix that.

xla commented 5 years ago

Instead of targeting Vulkan directly a better approach is to go for something like gfx-hal for a lowl-level/unsafe abstraction over the three modern graphics APIs (dx12, metal, vulkan) or for a higher level safe option like wgpu, venturing into the latter recently.

17cupsofcoffee commented 5 years ago

gfx-hal is definitely on my radar (and I'd definitely choose that route over raw Vulkan) - the main blocker for me switching is that I haven't been able to get it working with SDL (and I don't really want to switch to Winit for various reasons). That said, I know this is definitely possible, because Sev on Discord has managed to get it up and running.

Also the API is complicated and it scares me :p

Either way, discussion of switching backends entirely would be a better fit on #51 - this is more for ensure that our current backend isn't going to shoot people in the foot in the meantime :)