Commit graph

131 commits

Author SHA1 Message Date
Jay Oster 0e6c5286ff
Update line_drawing (#211) 2021-10-08 13:06:48 -07:00
JMS55 800dd931b7
Update to wgpu 0.11 (#209)
Co-authored-by: Jay Oster <jay@kodewerx.org>
2021-10-08 11:49:51 -07:00
Mohammed Alyousef a2529c63c3
update fltk-rs, and use raw-window-handle feature (#208) 2021-10-05 10:46:37 -07:00
Jay Oster db00a67c60
Add user-defined errors for render functions (#196)
- Fixes #189
2021-09-04 09:00:25 -07:00
Jay Oster 0f8b1abe87
Update dependencies (#195) 2021-09-04 00:39:03 -07:00
Jay Oster 6225f7225a
Workaround unusual Cargo bug with git dependencies (#194)
- See #193
2021-09-02 17:17:44 -07:00
Jay Oster 210b373882
Add resolver = "2" to all examples (#192)
- These are ignored, but it should prevent copy-pasta errors from users
2021-09-01 21:48:51 -07:00
Jay Oster e08c91bfd2
Update to wgpu 0.10 (#187)
- It would be nice to return an error from the render function
- imgui-winit is still a WIP (open PR: https://github.com/Yatekii/imgui-wgpu-rs/pull/66)
- Update README

Co-authored-by: Mohammed Alyousef <mohammed.alyousef@neurosrg.com>
2021-09-01 14:50:43 -07:00
Jay Oster 303f1d90f5
Prepare 0.5.0 (#183)
* Prepare 0.5.0

* Update dependencies
2021-07-17 08:57:25 -07:00
Jay Oster 288da3675f
Use the swapchain-preferred texture format by default (#182)
- Fixes #140
- Adds a public method to get the current GPU framebuffer texture format (AKA the render texture format).
- This wasn't as difficult as it seemed; the extra API is used by the examples to get the right texture format instead of being hardcoded.
2021-07-17 08:21:49 -07:00
Jay Oster ce549a79b6
Update to egui 0.13 (#181) 2021-06-27 11:32:17 -07:00
Jay Oster c4df23f65d
Update to wgpu 0.9 (#179)
* Update to wgpu 0.9

* Fix validation error in WGSL shader

- This moves the hardcoded vertex positions and texture coordinates to
  the vertex buffer.
- Replaces the two-triangle quad to 1 full-screen triangle (fixes #180)
- Rewrites the custom shader example to fix a bug with large surface
  textures;
  - The input texture size was used for the output texture, causing the
    purple rectangle to appear very jumpy on large displays in full screen.
- The `ScalingRenderer` now exposes its clipping rectangle. The custom
  shader example uses this for its own clipping rectangle, but it can
  also be used for interacting with the border in general.

* Switch to `wgpu::include_wgsl!()`

- This is a nice little simplification.
- Thanks to @JMS55 for the suggestion!
2021-06-27 11:09:29 -07:00
Jay Oster 294a875c8e
Update dependencies and prepare release (#177) 2021-06-17 20:00:24 -07:00
Jay Oster e5da717351
Update dependencies for egui-winit example (#176)
* Update egui-winit example to greatly simplify the platform event handler

- I was able to upstream this logic into the egui_winit_platform crate

* Fix the wgpu validation error
2021-06-08 07:34:47 -07:00
Jay Oster 338a63a40e
Minor improvement: only one shader module is necessary (#175) 2021-06-08 07:09:58 -07:00
Jay Oster 7913cbdb85
Update egui_winit_platform (#173) 2021-06-06 22:34:59 -07:00
Jay Oster 8d77ac2f8b
Rewrite shaders in WGSL (#172)
- Fixes #141
2021-06-05 18:40:33 -07:00
Jay Oster 23da739650
Update fltk (#169)
- Fixes #163
- Reimplements window resize
  - Still has problems on macOS; Resizing with the drag handle blocks the main loop. See:
    - https://github.com/glfw/glfw/issues/1251
    - https://github.com/rust-windowing/winit/issues/219
2021-05-29 03:27:33 -07:00
Jay Oster b76ae1f7bc
Update winit to 0.25 (#168)
- Update winit
- Update egui_winit_platform
- Update imgui_winit_support
- Fix hyperlink and resize in `egui-winit` example
2021-05-29 02:18:48 -07:00
Jay Oster 355448a7f1
Update egui-winit example dependencies (#167)
* Update egui-winit example dependencies

* Update MSRV
2021-05-12 18:50:33 -07:00
Jay Oster f3d2b0643e
Fix UI colors in imgui-winit example (#166)
- Removes the sRGB workaround that was needed before `imgui-winit` 0.12
2021-05-08 23:14:26 -07:00
Jay Oster cdcfe57868
Validate width and height inputs (#162)
* Validate width and height inputs

- Fixes #157

* Add window size check to `imgui-winit` demo

- There is really nothing better that can be done in this case.
- The surface, buffer, and world sizes must all be non-zero.
- A zero-length surface would (previously) panic in `wgpu`.
- A zero-length buffer would panic with the new assertions.
- A zero-length world would cause a divide-by-zero panic when drawing.
2021-05-08 17:26:21 -07:00
Jay Oster f238814d12
Update wgpu to 0.8 (#160)
- Also update other dependencies
2021-05-07 23:52:11 -07:00
Jay Oster 9bfed17a7f
Various fixes (#154)
* Cargo clippy

* Fix typo
2021-03-29 00:52:43 -07:00
JMS55 11c5961e4c
Use default() when making wgpu::RenderPipelineDescriptor (#152) 2021-03-11 18:14:34 -08:00
Jay Oster 8071f34a1f
Rename resize to resize_surface (#149)
- Also cleanup documentation.
- Workaround FLTK window resize issues by disabling resizability.
2021-03-09 04:15:24 -08:00
Jay Oster 509bb24b19
Update dependencies (#148) 2021-03-09 02:47:44 -08:00
Jay Oster 161b448a18
Add egui example. (#146) 2021-03-09 01:40:24 -08:00
Jay Oster 333ce71468
Fix resize in the imgui-winit example (#145)
- Was originally resizing the pixel buffer with `PhysicalSize` units, which is definitely incorrect. (The pixel buffer is created with `LogicalSize` units.)
- Updated the World struct to retain its own size information.
2021-03-07 03:50:10 -08:00
JMS55 f2d4a4f084
Upgrade to wgpu 0.7 (#134)
Co-authored-by: Jay Oster <jay@kodewerx.org>
2021-02-28 15:29:36 -08:00
Josh 26ae25c3d8
Resize buffer (#136)
- Fixes #125
2021-02-28 14:05:28 -08:00
Mohammed Alyousef f845d59213
add fltk example (#137)
* add fltk example

* fix clippy lint

* fix rustfmt check

* add missing trailing new line

* use no-pango feature

* remove call to win.draw()
2021-02-07 10:36:21 -08:00
Jay Oster c522d12e0e
Fix build for imgui-winit example (#138)
- The dependencies are a mess!
- Had to fork `imgui-wgpu`, which sits between 0.12 and 0.13 (has support for `winit` 0.24, but not `wgpu` 0.7)
- This is a temporary fix for CI, until https://github.com/Yatekii/imgui-wgpu-rs/pull/44 is merged and a new release of `imgui-wgpu` is out
- The WIP `wgpu` 0.7 update in https://github.com/parasyte/pixels/pull/134 will be needed for `imgui-wgpu` 0.14
- Update MSRV for `imgui` 0.7
2021-02-06 13:13:04 -08:00
Jay Oster 0a893d6eff
Update all dependencies (#130) 2021-01-05 18:20:36 -08:00
Jay Oster cb315ec0a1
Fix raqote example on high-DPI displays (#129) 2020-12-13 19:37:35 -08:00
Jay Oster 70ff52948b
Refactor builder (#128)
* Refactor PixelsBuilder into its own module

* Remove HasRawWindowHandle from public interface
2020-12-13 19:15:00 -08:00
Jay Oster f85145d774
Test all crates in the workspace (#127)
* Test all crates in the workspace

* Fix tests for Rust 1.41.0
2020-12-10 20:00:13 -08:00
Jay Oster d425cfee7f
Clippy (#126)
Changes `Rc<Vec<u8>>` to `Rc<[u8]>`. See: https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer
2020-12-10 19:28:54 -08:00
Jay Oster 6c36b3955b
Add an example with raqote (#118)
* Add an example with raqote

* Fix raqote dependency
2020-09-18 03:59:05 -07:00
Jay Oster 11dca72955
Add Dear ImGui example (#116)
* Add Dear ImGui example

- Closes #90

* Change argument order to match `render_with`

* Remove unnecessary borrow

* Refactor error messages

* Add a space

* Refactor Gui field privacy

* Add a menu bar and allow the about window to be closed

- The local bool is necessary because the menu bar closures are not allowed to borrow `self` for mutable access while `imgui::Ui<'ui>` is alive.
- The token-based menu bar lifetime is even more verbose than this.
2020-09-18 03:57:28 -07:00
Jay Oster 265ba2e5b3
Render API v2 (#112)
* WIP: Render API v2

* Fix doctests

* Expose all of PixelsContext (#110)

* Fix ScalingRenderer::new() taking &mut Device

* Replace getters with direct access to &mut PixelsContext

* Fix wrong reference type

* Fix unneeded mut

* Remove unnecessary mutable borrow, resurrect the shorter getter methods

* Initial port to wgpu master (0.6)
Surface creation is broken (see examples)
Does not support compressed textures

* Fix SurfaceTexture and examples

* Add support for compressed texture formats

* resize doesn't need mutability

* Update documentation

* Update wgpu

* Prepare release

* Goodbye Travis! Thanks for all the fish

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
2020-08-20 16:49:19 -07:00
Jay Oster 01d32c11f0
Bump beryllium version (#109)
- Closes #53
2020-07-29 19:07:34 -07:00
Jay Oster fcc8f9fe65
Fix surface texture size in some of the examples (#102) 2020-07-19 04:38:17 -07:00
Jay Oster 8190c18241
Add custom shader example (#100)
* Add custom-shader example

* Update README

* Allow log level to be changed in release mode
2020-07-19 02:18:02 -07:00
Jay Oster b5b55c43f7
Add feature flag to enable all log levels in examples (#98)
- Adds extra troubleshooting documentation to the README
2020-07-18 23:00:26 -07:00
Jay Oster b397eb4e48
Change Vsync setting to use Fifo present mode (#93)
And add a method to set `Mailbox` or other explicit modes.

Closes #88
2020-07-17 16:34:54 -07:00
Aeledfyr c96e46d3d4
Add a method to convert cursor coords to pixel coords (#77)
* Add a method to convert cursor coords to pixel coords

* Add method `window_pos_to_pixel` to Pixels struct
   * Converts cursor / window physical coordinates to pixel coords

* Fix formatting

* Return result rather than clamping pixel coordinates

* Use transformation matrices to convert from cursor coord to pixel

* Adds a struct ScalingMatrix that manages the creation and usage
  of the transformation matrix used in the renderer.
* Added an inverse function on ScalingMatrix - 4x4 matrix inverse
  (This should probably use a library, but it doesn't seem worth
  adding a dependancy for one function)

* Optimize matrix multiplication for cursor position calculation

* Use ultraviolet for matrix and vector math

* Add suggested changes

This keeps the split between usize and isize
This also changes the input cursor position to f32, because it was
immediately cast to an f32 for the transformations.
2020-05-20 21:37:29 -07:00
Jay Oster 91db963490
Fix panic in winit examples when pixels.render() returns Error (#70) 2020-04-13 20:38:51 -07:00
Jay Oster 9de2383712
Fix dependency bloat (#67)
* Move all examples to individual crates

* CI: Add libsdl2

* Use Ubuntu bionic for updated libsdl; 2.0.8

* Clippy

* libudev-dev is a dependency of libsdl2-dev

* Clippy

* Remove unnecessary dev-dependency

* `winit` is actually used in unit tests

* Fix a typo

* Move `simple-invaders` crate
2020-04-13 10:12:18 -07:00
Bernardo Meurer 246375f0e9
treewide: bump dependencies (#60) 2020-04-12 23:13:40 -07:00
Jay Oster bb898d78de
Add minimal-sdl2 example (#48) 2019-11-19 19:58:21 -08:00
Jay Oster 8061ce0ea4
Reorganize dependencies (#46)
* Reorganize dependencies

* Enable logging in the minimal-winit example

* Fix a very minor bug in the minimal-winit example
2019-11-19 19:37:36 -08:00
Jay Oster cb14f2d977
Add minimal example with winit (#45)
- Closes #44
2019-11-09 23:32:37 -08:00
Jay Oster 98983d201d Fix doc comment 2019-11-06 23:15:28 -08:00
Jay Oster d56625577d
Update READMEs (#42) 2019-11-06 22:37:16 -08:00
Jay Oster a92adf1b12
Add explicit clippy deny all, and forbid unsafe code (where possible) (#38) 2019-11-06 21:16:25 -08:00
Thom Chiovoloni e0225c145d Add a conways game of life example (#37)
* Add a conways game of life example

* Rustfmt conway example

* Respond to review feedback (p_width/p_height)

* Use line_drawing instead of manual bresenham

* Optimize count_neibs

* Remove inline(never) leftover from when profiling

* Bring back wrapping behavior (without regressing perf)

* Fix missing bounds check
2019-11-05 23:15:58 -08:00
Jay Oster 28f927e153
Switch from rand_core to randomize (#31)
- For #7
2019-11-02 15:29:09 -07:00
Jay Oster 7844c15a77
Add gamepad support (#28)
* Add gamepad support

* Try to fix the build
2019-10-28 01:03:03 -07:00
Jay Oster 6392ff9481
Fix syntax in the example (#27)
- This works because `wgpu` is a dependency for `pixels`
- But this example should be demonstrating how to ony depend on `pixels` ... And whatever windowing system and event-loop you might want.
2019-10-27 20:27:42 -07:00
Jay Oster 8bebb29a06
Fix screen scaling when window is resized (#25)
* Refactor window creation and size handling

* Require pixel aspect ratio to be > 0

* Fix screen scaling when window is resized

- Ensure the screen retains its correct pixel aspect ratio
- Updated public API on `RenderPass` ... this will continue to be unstable until the initial release
- Add build instructions for the internal shaders
2019-10-27 16:35:22 -07:00
Jay Oster cc04f14a3d
Controls should not be mutable (#24) 2019-10-26 22:03:12 -07:00
Jay Oster 31225385c7
Improve syntax slightly when handling RedrawRequested (#23) 2019-10-23 19:31:42 -07:00
Jay Oster 8801bad58a
Update public API to provide &mut [u8] instead of accepting &[u8] from the app (#22)
- Closes #19
2019-10-21 23:17:58 -07:00
Jay Oster b18690f19f
Clean up event handling with winit_input_helper (#21)
* Clean up event handling with winit_input_helper

- Closes #20

* QoL improvements
2019-10-21 22:34:12 -07:00
Jay Oster ea4e2aafc1
Track hidpi_factor, and properly round the physical pixel size (#15) 2019-10-15 01:09:33 -07:00
Jay Oster 6f0b1e0102
Support resize (#12)
- `Pixels` now takes ownership of the `Surface`. Deal with it. CBF to mess around with weird static lifetime requirements that don't make sense.
2019-10-14 22:17:42 -07:00
Jay Oster 076e4e519e
Implement collision detection (#8)
* Implement collision detection

* Minor cleanups.

* Add laser/player collisions

* Add laser collision with bullets and fix fire button repeating

* Add basic shield collisions

* Refactor collision and debug

* Simplify collision and debug by not tracking laser indices

- We don't care about which laser collided, because they get destroyed immediately.

* Don't track laser indicies against bullets either

* DRY and docs

* Adjust the fleet bounding box as invaders are shot
2019-10-13 19:48:20 -07:00
Jay Oster a793787292 Update README 2019-10-13 18:35:47 -07:00
Jay Oster b6fcf803e7
Invader AI (#6)
* WIP: Invader AI

- Adds debug mode for visualizing bounding boxes
- Adds rectangle and line drawing (for debug mode)
- Invaders move as a close approximation to the original game
- TODO: Demonstrates that the blit function needs to ignore black pixels (or "transparency")
- TODO: The invader movement code is really bad

* clippy and fmt

* Refactor Invader movement

* Support "transparency" in blit function

* Scale player movement to 60 pixels per second, regardless of frame rate.

* Add assertions in blit to prevent drawing out of bounds

* Add bullets, shoot with space

* Add lasers, and improve the bullet animation a little bit

* fmt
2019-10-12 14:26:47 -07:00
Jay Oster d0a16f9a71
Add player controls and shields (#4) 2019-10-08 00:35:53 -07:00
Jay Oster 348533ee9a Add delta time steps and a placeholder for control inputs 2019-10-07 01:00:33 -07:00
Jay Oster d815bb464b Refactor simple-invaders 2019-10-06 13:53:08 -07:00
Jay Oster 3b7638a012 Initial simple-invaders WIP
- Currently animates two flavors of invader in their usual formation
- Lots left to do, but this is a good start
2019-10-06 02:24:07 -07:00
Jay Oster 64cd487c37 Merge Pixels::update() with Pixels::render()
- Adds `PixelsBuilder::texture_format()` to configure the format for the pixel buffer
2019-10-03 23:16:23 -07:00
Jay Oster d0391be62a Initial pass with texture rendering
- The example app generates a scaled version of pixel Ferris as a test.
- TODO:
  - Pixel aspect ratio is still unsupported
  - The `RenderPass` trait is incomplete
2019-10-02 20:22:20 -07:00
Jay Oster 2ec43fccd1 Cleanly separate the two texture dimensions
- The pixel buffer dimensions
- The surface texture dimensions
2019-10-01 22:00:37 -07:00
Jay Oster 5519aafd18 Use RedrawRequested
- THis will likely change after https://github.com/rust-windowing/winit/issues/1082 lands
2019-09-29 18:42:31 -07:00
Jay Oster c4d762d5f5 Rename the Error type and add docs for the variants. 2019-09-25 23:47:04 -07:00
Jay Oster f0d7c84a3f Minor code hygiene. 2019-09-25 23:11:36 -07:00
Jay Oster cc4976079b Initial commit.
- Just a copy of the wgpu `hello-triangle` example for now... more to come!
2019-09-25 23:07:30 -07:00