Skip to content

About

An implementation of the Learn OpenGL tutorial, written in Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Learn Open GL, the Rust way

This repository is an adaptation of the Learn OpenGL website's OpenGL tutorial, adapted to use Rust's WASM backend through wasm-bindgen. The original tutorial documentation is written in C++, using GLFW and GLEW to create a window and expose an OpenGL context; this repository replaces this approach with an in-browser frontend with Rust/WASM and WebGL. The Rust/WASM implementation is largely based on examples from the Rust and WebAssembly book on github, and the WebGL Example in the Rust WASM book's $wasm-bindgen$ reference manual.

The mechanics are largely the same, and many of the odds an ends specific to C++ can be pretty directly translated to Rust, however there are some inconsistencies that needed to be addressed such as the way WebGL interprets GLSL files (particularly their pragmas and preprocessor directives). One of the sticking points at the moment is the synchronicity of the rendering cycle. Typically, graphical applications have an FPS-locked loop performing updates of internal logic, and rendering the results of those updates afterward, with a framewise timeout to save a few milliseconds of compute and cut down on unnecessary processing time. However the WebGL example on the EBook has an asynchronous flow built on the $requestAnimationFrame$ callback. Trying to add a synchronous loop to this code doesn't work well because it often blocks the main thread and can seize the application. I haven't found a way to run a background process in WASM yet that can handle this, so the rendering cycle may need to be event-driven and callback-driven.

Regardless, this approach shows potential in my opinion, and long-term could open the door to in-browser game development using WASM. If there is any goal for this repository it is exactly that; to make a framework for building small, in-browser games that are high-performance and can run anywhere. Once I find a better mechanism for handling event-driven programming and concurrency via in-browser Rust, I'll solidify this repo into a more streamlined API or Framework.

About

An implementation of the Learn OpenGL tutorial, written in Rust

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages