For example there is no risk of making a mistake while specifying the names and offsets of your vertex attributes, since Glium automatically generates this data for you. High-level functions are much easier to use and thus less error-prone. Glium provides the same guarantees with OpenGL objects that you have with regular objects in Rust. It also uses Rust's borrow system to ensure that objects are still alive and in the right state when you use them. Creating a Texture2d struct creates a texture, and destroying the struct destroys the texture. Glium also allows you to safely replace the current OpenGL context with another one that shares the same lists. You don't need to worry about thread safety, as it is forbidden to change the thread in which OpenGL objects operate. The OpenGL context is automatically handled by glium. Just like Rust does everything it can to avoid crashes, glium does everything it can to avoid OpenGL errors. If the OpenGL context triggers an error, then you have found a bug in glium. Examples include requesting a depth test when you don't have a depth buffer available, not binding any value to an attribute or uniform, or binding multiple textures with different dimensions to the same framebuffer. Glium detects what would normally be errors or undefined behaviors in OpenGL, and panics, without calling glGetError which would be too slow.
![gdi generic opengl 4.6 gdi generic opengl 4.6](http://static.euronews.com/articles/356421/1024x538_356421.jpg)
The same set of function calls will always produce the same results, which greatly reduces the number of potential problems. There are no set_something() functions in the entire library, and everything is done by parameter passing. You no longer need to create them explicitly as they are automatically created when needed and destroyed when their corresponding object is destroyed. Glium handles framebuffer objects, samplers, and vertex array objects for you. This reduces the overall complexity of OpenGL. For example the VertexBuffer struct contains information about the vertex bindings, because you usually don't use several different bindings with the same vertex buffer. Glium provides easier ways to do common tasks. Thanks to glutin, glium is very easy to setup compared to raw OpenGL.
![gdi generic opengl 4.6 gdi generic opengl 4.6](http://ecx.images-amazon.com/images/I/51oE%2BiKUrvL._SY300_.jpg)
You can directly pass vectors, matrices and images to glium instead of manipulating low-level data. If something is missing, please open an issue. Glium should allow you to do everything that OpenGL allows you to do, just through high-level functions. Glium's API tries to be as Rusty as possible, and shouldn't be much different than using any other Rust library. Link to a work-in-progress tutorial Why should I use Glium instead of raw OpenGL calls?įunctions are higher level in glium than in OpenGL. If you have some knowledge of OpenGL, the documentation and the examples should get you easily started.
![gdi generic opengl 4.6 gdi generic opengl 4.6](https://playroider.com/wp-content/uploads/2018/02/gpu-caps-viewer.jpg)
Be compatible with all OpenGL versions that support shaders, providing a unified API when things diverge.Provide an API that enforces good practices such as RAII or stateless function calls.Many aspects of OpenGL that can trigger a crash if misused are automatically handled by glium.