Skip to content

WGPU with winit 0.35.0. Draw window with triangle. Based on the learn WGPU example.

Notifications You must be signed in to change notification settings

N3xus8/wgpu_starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WGPU starter with Winit 0.30.5 and WGPU version 23.0.1

Date: 14/12/2024

What is it?

This is an example as an introduction to WGPU. In this example we simply draw the famous triangle on a window. This is based on the example from Learn WGPU (https://sotrh.github.io/learn-wgpu/) but refactored to update to the latest lib/API version. I also took inspiration from the Youtube series from GetIntoGameDev (https://www.youtube.com/watch?v=I8Uf7akOYo0).

Why?

Winit 0.30.5 has introduced breaking changes to its API. The examples on Learn GPU and GetIntoGameDev, no longer work with latest version of Winit and WGPU. I had troubles finding online documentation for Winit updated API.

Luckily I found this brilliant code that resolves the issue:

https://github.com/w4ngzhen/wgpu_winit_example

So credit to them! The refactoring around the window is neat using ARC to be able to get a reference on a mutable reference asynchronously.

Rainbow_triangle

How to run it?

  • for the desktop version simply run:

    > cargo run 
  • for the WASM browser version, you can install Trunk (https://trunkrs.dev/) and run :

    > trunk serve

    And open your navigator and enter the URL. Default is http://127.0.0.1:8080/

"I want to give a shoutout to Daxpedda for all the help with fixing and cleaning up the code, especially with the async stuff in WASM."

About

WGPU with winit 0.35.0. Draw window with triangle. Based on the learn WGPU example.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published