bracket-lib icon indicating copy to clipboard operation
bracket-lib copied to clipboard

WebGL: No resize, scaling, screenshot, or HiDPI support, and linear filtering is used

Open jasonjmcghee opened this issue 4 years ago • 1 comments

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 pixelated and 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): Screen Shot 2022-01-04 at 6 30 44 PM

Zoomed way in (blurry): Screen Shot 2022-01-04 at 6 30 14 PM

After

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

This is zoomed way in: Screen Shot 2022-01-04 at 6 23 27 PM

Scaling / Auto-resize:

Screen Shot 2022-01-04 at 6 27 53 PM Screen Shot 2022-01-04 at 6 34 18 PM

jasonjmcghee avatar Jan 05 '22 02:01 jasonjmcghee

Here is the screenshot example (Press S to take a screenshot):

Here are the WebGL (from main repo) examples hosted statically:

  • hello_minimal puts "Hello Minimal Bracket World" on the screen. Try it with WASM
  • hello_terminal puts a bouncing "Hello World" on the screen in color, with frames-per-second [FPS] counting, and frame-rate limiting. Try it with WASM
  • sparse is 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
  • walking lets you use your keyboard to walk an @ symbol around a random map. Try it with WASM
  • astar-mouse lets you use your mouse to move around a random map, using A-Star pathing (from the bracket-pathfinding crate) to avoid obstacles. Try it with WASM
  • tiles is similar to the walking demo, but uses two layers of graphical tiles (graphical back-ends only). Try it with WASM
  • rex demonstrates loading a sprite from REX Paint and rendering it to the terminal. Try it with WASM
  • postprocess demonstrates the library's post-processing effects - scan lines and screen burn. Try it with WASM
  • textblock demonstrates the TextBlock system, giving you a "builder" approach to constructing larger blocks of text with word-wrapping and formatting. Try it with WASM
  • dwarfmap demonstrates using the terminal with Algorithm3D to provide a Dwarf Fortress style 3D map (2D "slices" of a 3D world). It uses the bracket-noise library for terrain generation. Try it with WASM
  • keyboard demonstrates keyboard scan-code input. It's mostly useful for debugging. Try it with WASM
  • textsprites demonstrates multi-tile sprites. Try it with WASM
  • native_gl shows you how to access OpenGL directly. Only works with opengl back-ends, WASM or native. Try it with WASM

jasonjmcghee avatar Jan 08 '22 23:01 jasonjmcghee