Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Nazariglez/notan into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazariglez committed Dec 10, 2022
2 parents d690337 + d910a60 commit 3cbec57
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 24 deletions.
23 changes: 12 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.

## UNRELEASED

- Fix alpha blending mode issue with text rendering using the Draw2D API.
- Fix `Draw` structure is clonable again.
- Change `SetupHandler` and `AppBuilder::initialize` to `FnOnce` allowing to embed notan easily.

Expand All @@ -18,22 +19,22 @@ All notable changes to this project will be documented in this file.
- Added `shaderc` feature to compile shaders using `shaderc` instead of `glsl_to_spirv`.
- Fix `RenderTexture` orientation when drawing using the Draw2d API.
- Added `IndexBufferBuilder::with_data_u16` to create index buffers using u16 slices.
- Added `Text::last_bounds` to get the bounding box of the latest text drawn.
- Added `Text::last_bounds` to get the bounding box of the latest text drawn.
- Added `Text::bounds` to get the bounding box of all the text elements combined.
- Added `Draw::last_text_bounds` to get the bounding box of the latest text drawn using the Draw2d API.
- New examples `text_bounds.rs` and `draw_text_bounds.rs` to show how to measure the text size with real use cases.
- Added a CI action to check if the code meets a minimal quality conditions.
- Added `WindowBackend::set_mouse_passthrough` to change the passthrough condition at runtime.
- Added `WindowBackend::set_mouse_passthrough` to change the passthrough condition at runtime.
- Fix custom pipelines for the Draw2d APIs. They were working only for images, now they work all (shapes, patterns, etc..)
- Added example `draw_shapes_shader.rs` to show how to set a custom pipeline drawing shapes.
- Renamed `draw_shader.rs` to `draw_image_shader.rs`
- Added `Graphics::stats() -> GpuStats` to get more info about what the GPU did the last frame.
- Added new texture formats. `TextureFormat::R16Uint`, `R32Uint`, `R32Float`.
- Added `Graphics::stats() -> GpuStats` to get more info about what the GPU did the last frame.
- Added new texture formats. `TextureFormat::R16Uint`, `R32Uint`, `R32Float`.
- New example `renderer_texture_r32.rs` to show how to use new texture types.
- The method `Renderer::bind_texture` will set the slot automatically to the next one if using in a row.
- Replaced `copypasta` dependency by `arboard` and moved clipboard features to app level.
- Added clipboard support for web browsers using `wasm`.
- Added `.flip_x` and `.flip_y` to `Image`, `Animation` and `Pattern` object from the Draw2d API.
- Added `.flip_x` and `.flip_y` to `Image`, `Animation` and `Pattern` object from the Draw2d API.
- Changed `Draw::set_blend_mode` needs an `Option<BlendMode>` now, and passing None the blending mode can be canceled.
- Added `Draw::set_alpha_mode` and `DrawBuilder::alpha_mode` to set the blend mode for the alpha composition.

Expand All @@ -52,9 +53,9 @@ All notable changes to this project will be documented in this file.
- Added `WindowConfig::always_on_top` and `WindowBackend::set_always_on_top/is_always_on_top` to force the window to the foreground. Has no effect on the web.
- Added `notan_random` and feature `random` to allow users to disable the default random features and use their own.
- In EguiPlugin, handle `CMD` key on web.
- Fix, inverted the direction of the horizontal mouse wheel on web.
- Added `TextureBuilder::from_source(raw)` to create textures that are backend dependant.
- Added `TextureUpdater::with_source(raw)` to update textures that are backend dependant.
- Fix, inverted the direction of the horizontal mouse wheel on web.
- Added `TextureBuilder::from_source(raw)` to create textures that are backend dependent.
- Added `TextureUpdater::with_source(raw)` to update textures that are backend dependent.
- Added support to load and update `web_sys::HtmlImageElement` using the default backend.

## v0.6.0 - 27/08/2022
Expand All @@ -70,7 +71,7 @@ All notable changes to this project will be documented in this file.
- Fix 15 Puzzle game bug.
- Change `WindowConfig` to take values instead of set the `!default` value.
- Fix `wasm32` warnings due a leaked reference.
- Add `WindoConfig::canvas_id` to use or create a custom canvas.
- Add `WindowConfig::canvas_id` to use or create a custom canvas.
- Remove the deprecated `notan::math::DEG_TO_RAD` and `notan::math::RAD_TO_DEG`.
- Fix using `lazy_mode` an empty buffer after the first swap buffers.
- Add `draw_projection.rs` example.
Expand All @@ -80,13 +81,13 @@ All notable changes to this project will be documented in this file.

## v0.5.1 04/07/2022

- Fixed window shader compilation.
- Fixed window shader compilation.
- Egui will call RequestRedraw when there is some animation, no need to call it manually anymore.

## v0.5.0 - 26/06/2022

- Removed chrono due to a security issue.
- Fixed viewport issues where the Y axis was inverted and wasn't using DPI to calculate min positon.
- Fixed viewport issues where the Y axis was inverted and wasn't using DPI to calculate min position.
- Fixed EGUI 0.18.1. Paint callback feature.
- Added `Window::set_capture_cursor` and `Window::capture_cursor` to confine the cursor into the window's app.
- Added `app.mouse.wheel_delta` to read the delta without checking the event loop.
Expand Down
13 changes: 11 additions & 2 deletions crates/notan_draw/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,16 @@ impl Draw {
BatchType::Text { .. } => &self.text_pipeline,
};

// blending modes, by priority:
// 1. element draw
// 2. global draw blending
// 3. in some cases (like text), default mode
let cbm = info.blend_mode().or(self.blend_mode);
let abm = info.alpha_mode().or(self.alpha_mode);
let abm = info.alpha_mode().or(self.alpha_mode).or(match typ {
// text is drawn from a RT we need to set Over alpha by default
BatchType::Text { .. } => Some(BlendMode::OVER),
_ => None,
});

self.current_batch = Some(Batch {
typ: create_type(info),
Expand Down Expand Up @@ -284,7 +292,8 @@ impl Draw {
self.add_batch(info, is_diff_type, create_type);

if let Some(b) = &mut self.current_batch {
// vertices and indices are calculated before the flush to the gpu, so we need to store the text until that time
// vertices and indices are calculated before the flush to the gpu,
// so we need to store the text until that time
if let BatchType::Text { texts } = &mut b.typ {
let global_matrix = *self.transform.matrix();
let matrix = match *info.transform() {
Expand Down
1 change: 1 addition & 0 deletions crates/notan_draw/src/texts/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ pub fn create_text_pipeline(
.from(&TEXT_VERTEX, fragment)
.with_vertex_info(&vertex_info())
.with_color_blend(BlendMode::NORMAL)
.with_alpha_blend(BlendMode::OVER)
.with_texture_location(0, "u_texture")
.build()
}
3 changes: 1 addition & 2 deletions crates/notan_draw/src/texts/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ impl DrawProcess for TextSection<'_> {
flip,
} = self;

let color = color.with_alpha(alpha);

let color = color.with_alpha(color.a * alpha);
let count = text.chars().filter(|c| !c.is_whitespace()).count();

let g_text = Text::new(text)
Expand Down
4 changes: 2 additions & 2 deletions crates/notan_draw/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ mod test {
);
});

// Using a scaled projection and rotated nd scaled view
// Using a scaled projection and rotated 2nd scaled view
let proj = Mat4::orthographic_rh_gl(
0.0,
screen_size.x * 0.5,
Expand All @@ -354,7 +354,7 @@ mod test {
assert_eq!(
screen.round(),
pos,
"Using a scaled projection and rotated nd scaled view"
"Using a scaled projection and rotated 2nd scaled view"
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/notan_glow/src/render_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ unsafe fn create_fbo(
let status = gl.check_framebuffer_status(glow::FRAMEBUFFER);
if status != glow::FRAMEBUFFER_COMPLETE {
return Err(
"Cannot create a render target because the frambuffer is incomplete...".to_string(),
"Cannot create a render target because the framebuffer is incomplete...".to_string(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/notan_glyph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use notan_graphics::prelude::ClearOptions;
use notan_graphics::{Device, Renderer, Texture};
use notan_math::Mat4;

/// Object allowing glyph drawing, containing cache state. Manages glyph positioning cacheing,
/// Object allowing glyph drawing, containing cache state. Manages glyph positioning caching,
/// glyph draw caching & efficient GPU texture cache updating and re-sizing on demand.
///
/// Build using a [`GlyphBrushBuilder`](struct.GlyphBrushBuilder.html).
Expand Down
2 changes: 1 addition & 1 deletion crates/notan_graphics/src/limits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// check this https://docs.rs/wgpu/0.8.1/wgpu/struct.Limits.html

/// Limit are overrided by the graphic implementation
/// Limit are overridden by the graphic implementation
#[derive(Debug, Clone, Copy)]
pub struct Limits {
pub max_texture_size: u32,
Expand Down
2 changes: 1 addition & 1 deletion examples/draw_animation_grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn draw(app: &mut App, gfx: &mut Graphics, state: &mut State) {
.frames(&[14, 15, 16, 17, 18, 19, 20])
.time(state.time);

// frames in the 4rd row of the image
// frames in the 4th row of the image
draw.animation_grid(&state.texture, cols, rows)
.position(650.0, 440.0)
.frames(&[21, 22, 23, 24, 25, 26, 27])
Expand Down
2 changes: 1 addition & 1 deletion examples/draw_projection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn draw(gfx: &mut Graphics) {
draw.clear(Color::BLACK);

// We set our projection here
// Anything draw bellow will keep the aspect ratio
// Anything draw below will keep the aspect ratio
draw.set_projection(Some(projection));

// Our resolution bounds
Expand Down
2 changes: 1 addition & 1 deletion examples/graphics_update_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn draw(gfx: &mut Graphics, state: &mut State) {
.update()
.unwrap();

// Draw the texture usign the draw 2d API for convenience
// Draw the texture using the draw 2d API for convenience
let mut draw = gfx.create_draw();
draw.clear(Color::BLACK);
draw.image(&state.texture);
Expand Down
2 changes: 1 addition & 1 deletion examples/renderer_instancing_cubes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ fn setup(gfx: &mut Graphics) -> State {
);
let mvp = Mat4::IDENTITY * projection * view;

// Postion buffer, Step mode by default is per Vertex
// Position buffer, Step mode by default is per Vertex
let pos_vbo = gfx
.create_vertex_buffer()
.with_info(&vertex_pos_info)
Expand Down

0 comments on commit 3cbec57

Please sign in to comment.