4 ms·
Tried SDL2 a couple of times but never really got into it. Recently though, I’ve created a native application with wgpu and Rust, that I can run on my MacBook
by codetrotter 5y ago
Tried SDL2 a couple of times but never really got into it.
Recently though, I’ve created a native application with wgpu and Rust, that I can run on my MacBook Pro M1 where it uses Metal, and on my Linux desktop where it uses Vulkan.
wgpu translates into Vulkan, Metal, Direct3D 12, Direct3D 11 or OpenGL ES depending your platform. I like it so far.
I used the guide at https://sotrh.github.io/learn-wgpu/ https://sotrh.github.io/learn-wgpu/ as a starting point and built the thing I wanted to build.
My application is a LED simulator that makes use of wgpu and Rust to visualize LED strips, and uses FFI to call functions that I’ve written for Arduino in C++. With a thin layer of wrapping that I also wrote in C++, I have made it so that the same code that runs on physical Teensy 3.2 and is controlling physical LED strips, can also be compiled and run and visualized with my LED visualizer application on my desktop or laptop computer.
This allows me to iterate more quickly as well as to better be able to debug my code, because I can do all of the development without involving the steps of flashing the firmware to a physical microcontroller and without communicating with a physical microcontroller and LED strips.
When I have done a bit of work in my simulator I then flash it to the microcontroller where the physical LED strips are controlled to see it in the real world. But being able to work in this LED visualization simulator of mine is a great boon for the development process IMO.
- nextaccountic 5y agoI agree wgpu is great, but wgpu isn't a substitute for SDL. The Rust project that replaces SDL is called winit https://github.com/rust-windowing/winit https://github.com/rust-windowing/winit One can use wgpu with winit (which is more common) or, if they prefer, wgpu with sdl2. Here is an example: https://github.com/Rust-SDL2/rust-sdl2/tree/master/examples/raw-window-handle-with-wgpu https://github.com/Rust-SDL2/rust-sdl2/tree/master/examples/... edit: but, the "next-gen Vulkan API" the article refers to, that SDL will be developing, it would be a competitor to wgpu.
- codetrotter 5y ago> The Rust project that replaces SDL is called winit [...] One can use wgpu with winit Right, sorry, I should've specified that I am using winit and wgpu together, and that this is in comparison to my previous experience which includes using SDL2 alone (software rendering using SDL_Surface struct and the SDL_BlitSurface function) on one occasion during a game jam, and another time using SDL2 with Glad (OpenGL loading library) for an isometric terrain editor application that I tried to make. I think I also tried using SDL2 with GLEW at some point. > edit: but, the "next-gen Vulkan API" the article refers to, that SDL will be developing, it would be a competitor to wgpu. Yup, that's what prompted me to comment about wgpu, but I see how my comment ended up as incorrect because I didn't mention winit. Thanks for pointing it out.