1/26/2024 0 Comments Instaling AssetsGen![]() And if you’re like me, you’ll learn to love the fine details you’re forced to think about. Once you’ve got a triangle though, building on top of that is relatively easy. As mentioned previously, gfx-hal is pretty verbose. Now that that’s all ready, we can start working towards our modest goal. I’d encourage you to copy that, but otherwise, you’ll have to compile the glsl shaders in that repo to SPIR-V. I’ve also chosen the Metal backend because I’m working on macOS - but you should be able to swap this out with another backend trivially.Īs for that build dependency - the shaders in that repo are compiled using the method I wrote about here. See the full code for a more up-to-date example. (I’ll try to keep the version up to date in the tutorials repo.)ĮDIT : As was inevitable, there have indeed been some small breaking changes. This is just in case gfx introduce some breaking changes before release - I don’t want my tutorials to stop compiling. You’ll notice that gfx-hal isn’t currently published to crates.io, so we’re picking a specific commit to lock to. Feel free to let me know (via Twitter, or Github issue) if I make any mistakes.įirst of all, you’ll need to set up the dependencies in your Cargo.toml file. It’s also worth noting that I’m still learning, and it’s entirely possible I’ll get some things wrong. This tutorial does assume that you’re familiar with Rust code in general, and it probably helps if you have at least some experience with graphics programming. Honestly, I’ll try to explain as much as I can here, but the full example code is going to be more useful. Looks like it’s gonna be a long one, so here’s a nice table of contents: ![]() Now any of those could be considered a disadvantage depending on your requirements, but if it all sounds good to you, then read on! It’s written in Rust! Perfect for projects that are, also, written in Rust.It’s very explicit, arguably making it easier to understand and debug.It abstracts over multiple backends, including Metal, DX12, and Vulkan, making it cross-platform. ![]() Its API is very close to Vulkan, so skills and documentation are roughly applicable to both.It’s low-level and versatile (although that does make it more verbose and hard to learn).So what’s a Rustacean to do then? Well it just so happens that gfx-rs have a shiny new low-level graphics API, gfx-hal, that’s close to stable and ready to use. (It doesn’t help that Apple have deprecated its use on macOS and iOS in favour of their Metal API.) It’s stateful, with a large number of invalid states (hello, blank screen!) - it’s bogged down with legacy, fixed-function API design, preventing you from making full use of your modern graphics card - and since it doesn’t capture your intent with its usage, it’s also harder for your graphics driver to optimize it. I used it for a long time, and it was damn good while it lasted, but it has a lot of drawbacks. ![]() Gfx-hal Tutorial part 0: Drawing a triangle ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |