Commit graph

42 commits

Author SHA1 Message Date
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