search


Draw triangle with WGPU and Rust
Mon Sep 25 00:00:00 UTC 2023

Drawing a simple triangle with low-level graphics API like WGPU is not easy.

Here is an summary:

  1. Create a device and an adapter.
  2. Create a shader module for your triangle.
  3. Create a pipeline layout for your triangle.
  4. Create a pipeline for your triangle.
  5. Create a vertex buffer for your triangle.
  6. Create a command encoder.
  7. Begin a render pass.
  8. Set the pipeline.
  9. Draw your triangle.

Building for WASM

install wasm-pack
#install a webserver to serve the html,js,wasm files
% npm install -g http-server

# change into your project dir
% cd your-project

# use wasm-pack to build
% wasm-pack build --release --target web

# start webserver
% http-server                                                                                       
open in browser http://localhost:8080/index.html


ClojureScript Development with Shadow.cljs
Mon Mar 06 00:00:00 UTC 2023

Shadow CLJS makes it easy to use javascript libraries from ClojureScript

Shadow CLJS has two REPLs. A clj REPL and a cljs REPL. First start the clj REPL as follows:

% npx shadow-cljs clj-repl

shadow-cljs - config: /Users/sto/workspace/reagent/examples/material-ui/shadow-cljs.edn
shadow-cljs - updating dependencies
shadow-cljs - dependencies updated
shadow-cljs - HTTP server available at http://localhost:3000
shadow-cljs - server version: 2.19.9 running at http://localhost:9630
shadow-cljs - nREPL server started on port 3333
shadow-cljs - REPL - see (help)
To quit, type: :repl/quit


Now that you have nrepl running, you can connect to it from emacs with M-x cider-connect. Enter localhost and port. Once connected to nrepl, call the following function to start watching from cljs changes and then start the cljs REPL


shadow.user=>(shadow/watch :app)
shadow.user=>(shadow/repl :app) ;;start cljs REPL

Now you can evaluate ClojureScript code from emacs. If you cannot, it means you're haven't started the cljs REPL or you started the cljs REPL from the shell and not from nREPL via cider-connect

Refer to Shadow CLJS User's Guide for additional documentation