Hacker News new | ask | show | jobs
by skocznymroczny 2348 days ago
I'm considering switching away from OpenGL just to get rid of the global state. It's too tiring to track the OpenGL state just to realize you forgot to unset some texture in a completely different part of code.

My favourite of the newest APIs is Metal, because it's very easy to jump from OpenGL (triangle in Metal is about 30 lines of code). Perhaps WebGPU is an alternative once desktop translation layer is created (Google is working on one called Dawn).

2 comments

There is another translation layer called wgpu (https://github.com/gfx-rs/wgpu) being developed as well. It's written in Rust and has bindings for C, Rust (https://github.com/gfx-rs/wgpu-rs), and some initial support for other languages (Python, Julia, Scopes, etc.).

Dawn and wgpu have also been collaborating to create a common set of WebGPU headers. The WIP headers are located at https://github.com/webgpu-native/webgpu-headers if you're interested in contributing or following.

TBH, opengl has been improving in that respect. See, e.g., glTextureSubImage2D[1], which takes a pointer to the referred texture, unlike glTexSubImage2D.

1: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl...

Yes, I am aware of the direct state access extensions. It was a good step forward, but a bit too late. And it still applies only to GL objects like buffers, samplers, textures. For things like setting scissor test, blending, depth test/write, color masks, binding textures, you're back to the global state.