Skip to content

Commit 7bbe510

Browse files
committed
examples: update rotating_textured_quad.v with instructions on how to compile/run it with emscripten and a browser
1 parent ccd709c commit 7bbe510

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎examples/gg/rotating_textured_quad.v‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import gx
33
import os.asset
44
import sokol.sgl
55

6+
// If you have emscripten (see https://emscripten.org/docs/getting_started/index.html), you can compile this program to WASM, using:
7+
// `v -os wasm32_emscripten -o examples/gg/rotating_textured_quad.html examples/gg/rotating_textured_quad.v`, and later check with:
8+
// `emrun examples/gg/rotating_textured_quad.html` .
9+
#flag wasm32_emscripten --embed-file @VEXEROOT/examples/assets/logo.png@/assets/logo.png
10+
#flag wasm32_emscripten --embed-file @VEXEROOT/examples/assets/fonts/RobotoMono-Regular.ttf@/assets/RobotoMono-Regular.ttf
11+
612
pub struct Window {
713
pub mut:
814
ctx &gg.Context = unsafe { nil }
@@ -19,7 +25,7 @@ pub fn (mut window Window) draw() {
1925
window.ctx.begin()
2026
sgl.load_pipeline(window.ctx.pipeline.alpha)
2127

22-
sgl.translate(400, 400, 0) // center of the screen
28+
sgl.translate(250, 250, 0) // center of the screen
2329
sgl.rotate(angle, 0.0, 0.0, 1.0) // rotate around the Z axis pointing towards the camera
2430

2531
sgl.enable_texture()
@@ -40,11 +46,12 @@ fn main() {
4046
window.ctx = gg.new_context(
4147
window_title: 'Rotating V logo'
4248
bg_color: gx.light_green
43-
width: 800
44-
height: 800
49+
width: 500
50+
height: 500
4551
user_data: window
4652
init_fn: window.init
4753
frame_fn: window.draw
54+
font_path: asset.get_path('../assets', 'RobotoMono-Regular.ttf')
4855
)
4956
window.ctx.run()
5057
}

0 commit comments

Comments
 (0)