Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
github.com/schabby/go-wasm-webgl
A small, stingy and light-weight (= little functionality) webgl2 layer in Go for WASM.
Wasp comes with a small set of convenience structs and functions that easy the work with WebGL2. The main concepts are the following.
shader.go
: Common shader functionality such as loading, compiling shader sources as well as caching attributes and uniforms.webglapp.go
: A setup for a fullpage WebGL2 application with requestAnimationFrame
, mouse events and resize callbacks. Reduces common boilerplate code on the application level.mesh.go
: a simple data structure for manipulating triangle meshes and uploading to WebGL2 as interleaved VertexArrayObjects.webgl/renderingcontext.go
: Wrapper for WebGl2RenderingContext
in JavaScript for typesafety and convenience.Check out the examples in the examples
folder for further research.
There are currently three examples that demonstrate the usage of Wasp.
The simple cube example in examples/simplecube.go
shows a colored, rotating cube. It uses a very basic shader without lighting.
The simple sphere example in examples/simplesphere.go
shows a colored sphere without lighting.
The example in examples/simplelighting.go
shows spheres with classical lighting shading.
The example in examples/simpletexture.go
shows a crate with a textured mapped on its faces.
While not strictly necessary, it may help to have some prior knowledge on WASM with Go. There are plenty of great tutorials out there which help you understand how Go and WASM work together.
On the terminal of your choice, move into the project directory and run
GOOS=js GOARCH=wasm go build -o examples/hellocube.wasm examples/hellocube.go
This will compile the cube example into a wasm file in examples/hellocube.wasm
where it will be picked up
by the javascript loader in examples/hellocube.html
.
Make sure that examples
also contains wasm_exec.js
which is shiped along the standard Go installation, such that you may just need to copy it over cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./examples
.
To run the example, you need any webserver to serve the static content in the examples
directory (HTML files and WASM files.). Any http server will do, but you may want to run [goexec][https://github.com/shurcooL/goexec]
goexec 'http.ListenAndServe(`:8080`, http.FileServer(http.Dir(`.`)))'
in the examples
directory. Side note: goexec
is not on my PATH
environment variable, such that I need to call it will the
full path
~/go/bin/goexec 'http.ListenAndServe(`:8080`, http.FileServer(http.Dir(`.`)))'
Then, open a browser and request http://localhost:8080/hellocube.html
which will load the page with the embedded WASM
code, init the WebGL2 rendering context and show a rotating cube.
You may want to check out the browsers built-on console to see any logging output.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.