wolfiewerewolf / rustkit Goto Github PK
View Code? Open in Web Editor NEWA place to learn Rust with a focus on Webgl2
License: MIT License
A place to learn Rust with a focus on Webgl2
License: MIT License
I'm starting to add some basic functionality to the example like loading assets, in particular, GLSL. A lot of engines will use GLSL Generators and provide a fixed set of uniforms and attributes and while that may be something to do later for the most common stuff, for now, I simply want to be able to load arbitrary GLSL and hack around with it.
I've always used XHR for this kind of thing in the browser.
Fortunately Emscripten provides the "fetch" api which also works in rust. I found the following tutorial:
https://qiita.com/_likr/items/71817953b237a32a3015
The tutorial itself is complete and works but if I were writing it I would have called out this particular point:
"build": "EMMAKEN_CFLAGS=\"-s FETCH=1\" cargo build --target=wasm32-unknown-emscripten --release"
The EMMAKEN_CFLAGS are necessary in order to link the fetch api with the Emscripten build.. it's discussed here:
emscripten-core/emscripten#5063
So I've updated the package.json to include the build command line. It will be necessary to build this commit as follows:
npm run-script build
I also found that this only works with the wasm32-unknown-emscripten target. Whenever I attempt to use the flags with asmjs the flags seem to be ignored.
So far I've implemented the tutorial only but the intention is to use the fetch api to load glsl. I was initially going to jump straight into porting over an example from webgl2Fundamentals and then decided a more simple test would be to just load the existing shaders, parse them, and attempt to use them first. So that's what I'll do next. Once that works I'll see about re-producing the webgl fundamentals example which is included in the JS folder as javasript. If you uncomment the JS Test section in index.html and comment out the WASM loader you can see it for yourself.
I am most interested in seeing what kind of performance differences, if any, there are between the WASM vs JS versions...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.