Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ members = [
"pomme-protocol",
"tools/blockgen",
"tools/protogen"
]
, "pomme-gui"]

[workspace.dependencies]
serde = { version = "1", features = ["derive"] }
Expand All @@ -29,6 +29,8 @@ glam = "0.33"
pyronyx = "=0.3.2"
tracing = "0.1"
tracing-subscriber = "0.3"
winit = "0.30"
pomme-gui = { path = "./pomme-gui" }

# azalea lags crates.io releases; track the 26.2 branch from git.
# azalea-block is replaced by the pomme-block shim (pomme owns block data);
Expand Down
3 changes: 2 additions & 1 deletion pomme-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ reqwest = { workspace = true, features = ["blocking"] }
pyronyx = { workspace = true, features = ["rwh_06"] }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter"] }
pomme-gui.workspace = true

tracing-appender = "0.2"
# Per-thread-heap allocator: the chunk-mesh worker pool churns vertex/index Vecs
Expand All @@ -29,7 +30,7 @@ tracing-appender = "0.2"
mimalloc = "0.1"
pomme-gpu-allocator = { path = "../pomme-gpu-allocator" }
pomme-protocol = { path = "../pomme-protocol" }
winit = { version = "0.30", features = ["rwh_06"] }
winit = { workspace = true, features = ["rwh_06"] }
raw-window-handle = "0.6"
glam = { workspace = true }
clap = { version = "4", features = ["derive"] }
Expand Down
2 changes: 2 additions & 0 deletions pomme-client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ fn main() {
("particle.frag", shaderc::ShaderKind::Fragment),
("clouds.vert", shaderc::ShaderKind::Vertex),
("clouds.frag", shaderc::ShaderKind::Fragment),
("gui_rect.vert", shaderc::ShaderKind::Vertex),
("gui_rect.frag", shaderc::ShaderKind::Fragment),
];

for (file, kind) in &shaders {
Expand Down
37 changes: 19 additions & 18 deletions pomme-client/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::time::{Duration, Instant};

use pomme_gui::Gui;
use thiserror::Error;
use winit::application::ApplicationHandler;
use winit::event::{DeviceEvent, DeviceId, WindowEvent};
Expand Down Expand Up @@ -208,6 +209,19 @@ impl ApplicationHandler for App {

self.core.apply_cursor_grab(&window, None);

let init_gfx = |renderer| {
let gui =
Gui::new(window.inner_size(), self.core.menu.gui_scale_setting, false);

Gfx {
renderer: ManuallyDrop::new(renderer),
window,
gui,
last_frame: Instant::now(),
fps_counter: FpsCounter::new(),
}
};

if let Some(server_ip) = quick_access_multiplayer {
let connection = spawn_connection(
&self.core.tokio_rt,
Expand All @@ -229,30 +243,16 @@ impl ApplicationHandler for App {
self.core.menu.render_distance,
);

let gfx = Gfx {
renderer: ManuallyDrop::new(renderer),
window,
last_frame: Instant::now(),
fps_counter: FpsCounter::new(),
};

AppPhase::Connecting {
gfx,
gfx: init_gfx(renderer),
panorama: Panorama::new(),
connect_phase: ConnectionPhase::Connecting,
connection,
game,
}
} else {
let gfx = Gfx {
renderer: ManuallyDrop::new(renderer),
window,
last_frame: Instant::now(),
fps_counter: FpsCounter::new(),
};

AppPhase::InMenu {
gfx,
gfx: init_gfx(renderer),
panorama: Panorama::new(),
}
}
Expand All @@ -272,8 +272,9 @@ impl ApplicationHandler for App {
event_loop.exit();
}
WindowEvent::Resized(new_size) => {
if let Some(app_rt) = self.phase.gfx_mut() {
app_rt.renderer.resize(new_size);
if let Some(gfx) = self.phase.gfx_mut() {
gfx.renderer.resize(new_size);
gfx.gui.resize(new_size);
}
}
WindowEvent::ModifiersChanged(mods) => {
Expand Down
5 changes: 5 additions & 0 deletions pomme-client/src/app/phases/connecting.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use azalea_protocol::packets::game::ServerboundGamePacket;
use pomme_gui::types::Position;

use crate::app::core::AppCore;
use crate::app::phases::in_game::GameState;
Expand Down Expand Up @@ -119,6 +120,10 @@ pub fn update_connecting(
elements,
core.input.cursor_pos(),
false,
gfx.gui.extract_render_state(Position::new(
core.input.cursor_pos().0 as i32,
core.input.cursor_pos().1 as i32,
)),
) {
tracing::error!("Render error: {e}");
}
Expand Down
5 changes: 5 additions & 0 deletions pomme-client/src/app/phases/in_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2454,6 +2454,11 @@ pub fn update_game(
player_preview,
book_preview,
game.player.eyes_in_water,
gfx.gui
.extract_render_state(pomme_gui::types::Position::new(
core.input.cursor_pos().0 as i32,
core.input.cursor_pos().1 as i32,
)),
) {
tracing::error!("Render error: {e}");
}
Expand Down
5 changes: 5 additions & 0 deletions pomme-client/src/app/phases/in_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ pub fn update_menu(
result.elements,
core.input.cursor_pos(),
core.menu.is_main_screen(),
gfx.gui
.extract_render_state(pomme_gui::types::Position::new(
core.input.cursor_pos().0 as i32,
core.input.cursor_pos().1 as i32,
)),
) {
tracing::error!("Render error: {e}");
}
Expand Down
2 changes: 2 additions & 0 deletions pomme-client/src/app/phases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::time::Instant;

use pomme_gui::Gui;
use winit::window::Window;

use crate::app::phases::in_game::GameState;
Expand All @@ -21,6 +22,7 @@ pub struct Gfx {
// Window does not require `ManuallyDrop` because it is dropped normally after the renderer by
// the compiler.
pub window: Arc<Window>,
pub gui: Gui,
pub last_frame: Instant,
pub fps_counter: FpsCounter,
}
Expand Down
Loading
Loading