diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-11 11:49:04 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-12 13:48:30 -0800 |
| commit | f4bac750504ae2d21068a87b6a6bf4a733476993 (patch) | |
| tree | 644741a31d045d17f9456f07078a2fca2bb21412 /chapter31/docs/examples | |
| parent | a269fa7e8aea51b4fbdd2f2c6c24e84ef26f9ca4 (diff) | |
| download | Simple-f4bac750504ae2d21068a87b6a6bf4a733476993.tar.gz Simple-f4bac750504ae2d21068a87b6a6bf4a733476993.zip | |
First cut graphics
Diffstat (limited to 'chapter31/docs/examples')
| -rw-r--r-- | chapter31/docs/examples/Graphics.smp | 17 | ||||
| -rw-r--r-- | chapter31/docs/examples/README.md | 4 |
2 files changed, 20 insertions, 1 deletions
diff --git a/chapter31/docs/examples/Graphics.smp b/chapter31/docs/examples/Graphics.smp new file mode 100644 index 00000000..7ba5c6e7 --- /dev/null +++ b/chapter31/docs/examples/Graphics.smp @@ -0,0 +1,17 @@ +// Optional graphics smoke test: pixels are drawn entirely in Simple. +// Pass any argument for a short, self-closing test; otherwise close or press Esc. +val main = { u8[~][] args -> + if( sys.gfx.open("Simple pixels",320,240) != sys.gfx.OK ) return 1; + val pixels = new u32[320*240]; + for( int y=0; y<240; y++ ) + for( int x=0; x<320; x++ ) + pixels[y*320+x] = (x*255/319 << 16) | (y*255/239 << 8) | 64; + int result = sys.gfx.present(pixels); + int frames = 0; + while( result == sys.gfx.OK ) { + result = sys.gfx.poll(true); + if( args# > 1 && ++frames == 5 ) break; + } + sys.gfx.close(); + return result == sys.gfx.ERROR ? 1 : 0; +}; diff --git a/chapter31/docs/examples/README.md b/chapter31/docs/examples/README.md index 58f7817b..2f19f09c 100644 --- a/chapter31/docs/examples/README.md +++ b/chapter31/docs/examples/README.md @@ -1,7 +1,9 @@ # Runnable examples These programs live beside the documentation so readers can find and run them. -Their native regression tests still run as part of `make tests`. +Their non-graphical native regression tests run as part of `make tests`. +The optional [pixel-window example](Graphics.smp) uses MiniFB; see +[graphics setup](../graphics.md). `make run-graphics` opens it explicitly. From `chapter31`, build the tic-tac-toe executable (without starting it): |
