mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-24 04:48:21 -06:00
kubiui integration update
This commit is contained in:
parent
ba406d812e
commit
d21104decc
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -988,7 +988,7 @@ checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
|
|||
[[package]]
|
||||
name = "hui"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=b6dc8f370b6#b6dc8f370b6dac971394e8cb82fdb505b529e964"
|
||||
dependencies = [
|
||||
"derive_more",
|
||||
"derive_setters",
|
||||
|
@ -1008,16 +1008,28 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hui-derive"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=b6dc8f370b6#b6dc8f370b6dac971394e8cb82fdb505b529e964"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.60",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hui-wgpu"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=b6dc8f370b6#b6dc8f370b6dac971394e8cb82fdb505b529e964"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"glam",
|
||||
"hui",
|
||||
"log",
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hui-winit"
|
||||
version = "0.1.0-alpha.5"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=3a50d2d0dde#3a50d2d0dde7044d02860dac9ab059bd353657a2"
|
||||
source = "git+https://github.com/griffi-gh/hui?rev=b6dc8f370b6#b6dc8f370b6dac971394e8cb82fdb505b529e964"
|
||||
dependencies = [
|
||||
"glam",
|
||||
"hui",
|
||||
|
@ -1211,6 +1223,7 @@ dependencies = [
|
|||
"glam",
|
||||
"hashbrown 0.14.5",
|
||||
"hui",
|
||||
"hui-wgpu",
|
||||
"hui-winit",
|
||||
"image",
|
||||
"kubi-logging",
|
||||
|
|
|
@ -11,8 +11,9 @@ crate-type = ["lib", "cdylib"]
|
|||
[dependencies]
|
||||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-logging = { path = "../kubi-logging" }
|
||||
hui = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde" }
|
||||
hui-winit = { git = "https://github.com/griffi-gh/hui", rev = "3a50d2d0dde", features = ["winit_30"] }
|
||||
hui = { git = "https://github.com/griffi-gh/hui", rev = "b6dc8f370b6" }
|
||||
hui-wgpu = { git = "https://github.com/griffi-gh/hui", rev = "b6dc8f370b6" }
|
||||
hui-winit = { git = "https://github.com/griffi-gh/hui", rev = "b6dc8f370b6", features = ["winit_30"] }
|
||||
log = "0.4"
|
||||
wgpu = { version = "0.20", features = ["webgl"] }
|
||||
pollster = "0.3"
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use hui::UiInstance;
|
||||
use hui_wgpu::WgpuUiRenderer;
|
||||
//use hui_glium::GliumUiRenderer;
|
||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||
use crate::rendering::Renderer;
|
||||
use crate::rendering::{RenderCtx, Renderer};
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct UiState {
|
||||
pub hui: UiInstance,
|
||||
//pub renderer: GliumUiRenderer
|
||||
pub renderer: WgpuUiRenderer,
|
||||
}
|
||||
|
||||
pub fn kubi_ui_init(
|
||||
|
@ -15,7 +16,7 @@ pub fn kubi_ui_init(
|
|||
let renderer = storages.borrow::<NonSendSync<UniqueView<Renderer>>>().unwrap();
|
||||
storages.add_unique_non_send_sync(UiState {
|
||||
hui: UiInstance::new(),
|
||||
//renderer: GliumUiRenderer::new(&renderer.display),
|
||||
renderer: WgpuUiRenderer::new(renderer.device(), renderer.surface_config().format),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -26,21 +27,21 @@ pub fn kubi_ui_begin(
|
|||
}
|
||||
|
||||
pub fn kubi_ui_end(
|
||||
mut ui: NonSendSync<UniqueViewMut<UiState>>
|
||||
mut ui: NonSendSync<UniqueViewMut<UiState>>,
|
||||
renderer: UniqueView<Renderer>,
|
||||
) {
|
||||
let ui: &mut UiState = &mut ui;
|
||||
let UiState { hui, /*renderer,*/ .. } = ui;
|
||||
let UiState { hui, renderer: ui_renderer } = ui;
|
||||
hui.end();
|
||||
//renderer.update(hui);
|
||||
ui_renderer.update(hui, renderer.queue(), renderer.device(), renderer.size_vec2());
|
||||
}
|
||||
|
||||
// pub fn kubi_ui_draw(
|
||||
// ui: NonSendSync<UniqueView<UiState>>,
|
||||
// mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
// size: UniqueView<WindowSize>
|
||||
// ) {
|
||||
// ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
// }
|
||||
pub fn kubi_ui_draw(
|
||||
ctx: &mut RenderCtx,
|
||||
ui: NonSendSync<UniqueView<UiState>>,
|
||||
) {
|
||||
ui.renderer.draw(ctx.encoder, ctx.surface_view);
|
||||
}
|
||||
|
||||
pub fn hui_process_winit_events(
|
||||
event: &winit::event::Event<()>,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use shipyard::{AllStoragesViewMut, IntoIter, IntoWorkload, SystemModificator, Unique, UniqueView, UniqueViewMut, View, Workload, WorkloadModificator};
|
||||
use shipyard::{AllStoragesViewMut, IntoIter, IntoWorkload, SystemModificator, Unique, UniqueView, UniqueViewMut, View, Workload};
|
||||
use winit::dpi::PhysicalSize;
|
||||
use glam::Vec3;
|
||||
use crate::{events::WindowResizedEvent, state::is_ingame};
|
||||
use crate::{events::WindowResizedEvent, hui_integration::kubi_ui_draw, state::is_ingame};
|
||||
|
||||
mod renderer;
|
||||
mod primitives;
|
||||
|
@ -24,7 +24,7 @@ pub struct BufferPair {
|
|||
pub struct BackgroundColor(pub Vec3);
|
||||
|
||||
pub struct RenderCtx<'a> {
|
||||
pub renderer: &'a Renderer,
|
||||
//pub renderer: &'a Renderer,
|
||||
pub encoder: &'a mut wgpu::CommandEncoder,
|
||||
pub surface_view: &'a wgpu::TextureView,
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ pub fn render_master(storages: AllStoragesViewMut) {
|
|||
let surface_view = surface_texture.texture.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
||||
let mut data = RenderCtx {
|
||||
renderer: &renderer,
|
||||
//renderer: &renderer,
|
||||
encoder: &mut encoder,
|
||||
surface_view: &surface_view,
|
||||
};
|
||||
|
@ -76,6 +76,8 @@ pub fn render_master(storages: AllStoragesViewMut) {
|
|||
storages.run_with_data(selection_box::draw_selection_box, &mut data);
|
||||
}
|
||||
|
||||
storages.run_with_data(kubi_ui_draw, &mut data);
|
||||
|
||||
renderer.queue().submit([encoder.finish()]);
|
||||
surface_texture.present();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue