WebGL: No resize, scaling, screenshot, or HiDPI support, and linear filtering is used
I've been on a deep dive in WebGL and there is a fair amount of missing functionality.
I've managed to implement the aforementioned missing features on a separate branch.
It'd be great to integrate the features into the main repo.
This is the branch: https://github.com/jasonjmcghee/bracket-lib/tree/issue_254_webgl_missing-features
(Here's an link for the comparison)
If there is support here / buy-in I'm happy to add comments / documentation to ensure everything is abundantly clear, or test coverage anywhere that makes sense. I've just been following existing patterns for this code.
So - what changed?
- Added automatic resize support
- Added scaling support
- Added HiDPI monitor support
- Added ability to take a screenshot
- Use NEAREST filtering + CSS
pixelatedand equivalent to make super sharp visuals
Note: On the branch I have a number of CSS changes on the index.html itself - no reason it couldn't be all rust.
Before
(only using my fix in #251, to fix the black screen):
Generally how it looks (locked at 640x480, with no HiDPI):

Zoomed way in (blurry):

After
This is taken with the new screenshot method :)
(make sure to click the image - 0 blurriness)

This is zoomed way in:

Scaling / Auto-resize:
Here is the screenshot example (Press S to take a screenshot):
-
fontswitch: Try it with WASM
Here are the WebGL (from main repo) examples hosted statically:
-
hello_minimalputs "Hello Minimal Bracket World" on the screen. Try it with WASM -
hello_terminalputs a bouncing "Hello World" on the screen in color, with frames-per-second [FPS] counting, and frame-rate limiting. Try it with WASM -
sparseis the same demo, but with a second layer in a VGA 8x16 font on a second layer, no frame-rate limiting, and utilizing batched command submission. Try it with WASM -
walkinglets you use your keyboard to walk an@symbol around a random map. Try it with WASM -
astar-mouselets you use your mouse to move around a random map, using A-Star pathing (from thebracket-pathfindingcrate) to avoid obstacles. Try it with WASM -
tilesis similar to thewalkingdemo, but uses two layers of graphical tiles (graphical back-ends only). Try it with WASM -
rexdemonstrates loading a sprite from REX Paint and rendering it to the terminal. Try it with WASM -
postprocessdemonstrates the library's post-processing effects - scan lines and screen burn. Try it with WASM -
textblockdemonstrates theTextBlocksystem, giving you a "builder" approach to constructing larger blocks of text with word-wrapping and formatting. Try it with WASM -
dwarfmapdemonstrates using the terminal withAlgorithm3Dto provide a Dwarf Fortress style 3D map (2D "slices" of a 3D world). It uses thebracket-noiselibrary for terrain generation. Try it with WASM -
keyboarddemonstrates keyboard scan-code input. It's mostly useful for debugging. Try it with WASM -
textspritesdemonstrates multi-tile sprites. Try it with WASM -
native_glshows you how to access OpenGL directly. Only works withopenglback-ends, WASM or native. Try it with WASM