mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-09 17:18:41 -06:00
rip out some parts of glium
This commit is contained in:
parent
8f606b77c0
commit
e11ee19597
832
Cargo.lock
generated
832
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -12,14 +12,11 @@ crate-type = ["lib", "cdylib"]
|
|||
kubi-shared = { path = "../kubi-shared" }
|
||||
kubi-logging = { path = "../kubi-logging" }
|
||||
hui = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
hui-glium = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
hui-winit = { version = "0.1.0-alpha.4", git = "https://github.com/griffi-gh/hui", rev = "dd5af8b9e2" }
|
||||
log = "0.4"
|
||||
glium = { git = "https://github.com/glium/glium", rev = "a352c667" }
|
||||
glutin = "0.31"
|
||||
winit = { version = "0.29", features = ["android-native-activity"] }
|
||||
glutin-winit = "0.4"
|
||||
raw-window-handle = "=0.5.*"
|
||||
wgpu = { version = "0.20", features = ["webgl"] }
|
||||
winit = { version = "0.30", features = ["android-native-activity"] }
|
||||
raw-window-handle = "0.6"
|
||||
glam = { version = "0.27", features = ["debug-glam-assert", "fast-math"] }
|
||||
image = { version = "0.25", default_features = false, features = ["png"] }
|
||||
strum = { version = "0.26", features = ["derive"] }
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use hui::UiInstance;
|
||||
use hui_glium::GliumUiRenderer;
|
||||
//use hui_glium::GliumUiRenderer;
|
||||
use shipyard::{AllStoragesView, Unique, UniqueView, NonSendSync, UniqueViewMut};
|
||||
use crate::rendering::{RenderTarget, Renderer, WindowSize};
|
||||
|
||||
#[derive(Unique)]
|
||||
pub struct UiState {
|
||||
pub hui: UiInstance,
|
||||
pub renderer: GliumUiRenderer
|
||||
//pub renderer: GliumUiRenderer
|
||||
}
|
||||
|
||||
pub fn kubi_ui_init(
|
||||
|
@ -15,7 +15,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: GliumUiRenderer::new(&renderer.display),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,9 @@ pub fn kubi_ui_end(
|
|||
mut ui: NonSendSync<UniqueViewMut<UiState>>
|
||||
) {
|
||||
let ui: &mut UiState = &mut ui;
|
||||
let UiState { hui, renderer, .. } = ui;
|
||||
let UiState { hui, /*renderer,*/ .. } = ui;
|
||||
hui.end();
|
||||
renderer.update(hui);
|
||||
//renderer.update(hui);
|
||||
}
|
||||
|
||||
pub fn kubi_ui_draw(
|
||||
|
@ -39,7 +39,7 @@ pub fn kubi_ui_draw(
|
|||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
size: UniqueView<WindowSize>
|
||||
) {
|
||||
ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
//ui.renderer.draw(&mut target.0, size.0.as_vec2());
|
||||
}
|
||||
|
||||
pub fn hui_process_winit_events(
|
||||
|
|
|
@ -43,17 +43,17 @@ impl AssetPaths for BlockTexture {
|
|||
#[repr(transparent)]
|
||||
pub struct BlockTexturesPrefab(pub SrgbTexture2dArray);
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct ChunkShaderPrefab(pub Program);
|
||||
// #[derive(Unique)]
|
||||
// #[repr(transparent)]
|
||||
// pub struct ChunkShaderPrefab(pub Program);
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct ColoredShaderPrefab(pub Program);
|
||||
// #[derive(Unique)]
|
||||
// #[repr(transparent)]
|
||||
// pub struct ColoredShaderPrefab(pub Program);
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct Colored2ShaderPrefab(pub Program);
|
||||
// #[derive(Unique)]
|
||||
// #[repr(transparent)]
|
||||
// pub struct Colored2ShaderPrefab(pub Program);
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
|
@ -113,5 +113,5 @@ pub fn load_prefabs(
|
|||
|
||||
log::info!("releasing shader compiler");
|
||||
|
||||
renderer.display.release_shader_compiler();
|
||||
//renderer.display.release_shader_compiler();
|
||||
}
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
use std::num::NonZeroU32;
|
||||
use raw_window_handle::HasRawWindowHandle;
|
||||
use shipyard::{Unique, NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, AllStoragesView};
|
||||
use winit::{
|
||||
event_loop::EventLoopWindowTarget,
|
||||
window::{WindowBuilder, Fullscreen, Window},
|
||||
event_loop::ActiveEventLoop,
|
||||
window::{WindowAttributes, Fullscreen, Window},
|
||||
dpi::PhysicalSize
|
||||
};
|
||||
use glium::{Display, Surface, Version, Api as GlApiTy};
|
||||
use glutin::{
|
||||
config::{Api, ConfigTemplateBuilder}, context::{ContextAttributesBuilder, GlProfile}, display::GetGlDisplay, prelude::*, surface::{SurfaceAttributesBuilder, WindowSurface}
|
||||
};
|
||||
use glutin_winit::DisplayBuilder;
|
||||
use glam::{Vec3, UVec2};
|
||||
use crate::{events::WindowResizedEvent, settings::{GameSettings, FullscreenMode}};
|
||||
|
||||
|
@ -20,10 +13,6 @@ pub mod selection_box;
|
|||
pub mod entities;
|
||||
pub mod sumberge;
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct RenderTarget(pub glium::Frame);
|
||||
|
||||
#[derive(Unique)]
|
||||
#[repr(transparent)]
|
||||
pub struct BackgroundColor(pub Vec3);
|
||||
|
@ -35,14 +24,13 @@ pub struct WindowSize(pub UVec2);
|
|||
#[derive(Unique)]
|
||||
pub struct Renderer {
|
||||
pub window: Window,
|
||||
pub display: Display<WindowSurface>,
|
||||
}
|
||||
|
||||
impl Renderer {
|
||||
pub fn init(event_loop: &EventLoopWindowTarget<()>, settings: &GameSettings) -> Self {
|
||||
pub fn init(event_loop: &ActiveEventLoop, settings: &GameSettings) -> Self {
|
||||
log::info!("initializing display");
|
||||
|
||||
let wb = WindowBuilder::new()
|
||||
let wb = WindowAttributes::new()
|
||||
.with_title("kubi")
|
||||
.with_maximized(true)
|
||||
.with_min_inner_size(PhysicalSize::new(640, 480))
|
||||
|
@ -88,74 +76,7 @@ impl Renderer {
|
|||
}
|
||||
});
|
||||
|
||||
let display_builder = DisplayBuilder::new()
|
||||
.with_window_builder(Some(wb));
|
||||
|
||||
let config_template_builder = ConfigTemplateBuilder::new()
|
||||
.with_api(Api::GLES3)
|
||||
.prefer_hardware_accelerated(Some(true))
|
||||
.with_depth_size(24)
|
||||
.with_multisampling(settings.msaa.unwrap_or_default());
|
||||
|
||||
let (window, gl_config) = display_builder
|
||||
.build(event_loop, config_template_builder, |mut configs| {
|
||||
configs.next().unwrap()
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
let window = window.expect("no window");
|
||||
|
||||
// Now we get the window size to use as the initial size of the Surface
|
||||
let (width, height): (u32, u32) = window.inner_size().into();
|
||||
let attrs = SurfaceAttributesBuilder::<WindowSurface>::new().build(
|
||||
window.raw_window_handle(),
|
||||
NonZeroU32::new(width).unwrap(),
|
||||
NonZeroU32::new(height).unwrap(),
|
||||
);
|
||||
|
||||
// Finally we can create a Surface, use it to make a PossiblyCurrentContext and create the glium Display
|
||||
let surface = unsafe {
|
||||
gl_config.display().create_window_surface(&gl_config, &attrs).unwrap()
|
||||
};
|
||||
|
||||
let context_attributes = ContextAttributesBuilder::new()
|
||||
.with_debug(cfg!(debug_assertions))
|
||||
.with_context_api(glutin::context::ContextApi::Gles(None))
|
||||
.with_profile(GlProfile::Core)
|
||||
.build(Some(window.raw_window_handle()));
|
||||
|
||||
let current_context = unsafe {
|
||||
gl_config.display()
|
||||
.create_context(&gl_config, &context_attributes)
|
||||
.expect("failed to create context")
|
||||
}.make_current(&surface).unwrap();
|
||||
|
||||
let display = Display::from_context_surface(current_context, surface).unwrap();
|
||||
|
||||
//TODO MIGRATION
|
||||
// let cb = ContextBuilder::new()
|
||||
// //.with_srgb(false)
|
||||
// .with_depth_buffer(24)
|
||||
// .with_multisampling(settings.msaa.unwrap_or_default())
|
||||
// .with_vsync(settings.vsync)
|
||||
// .with_gl_profile(GlProfile::Core)
|
||||
// .with_gl(GlRequest::Latest);
|
||||
|
||||
// let display = Display::new(wb, cb)
|
||||
// .expect("Failed to create a glium Display");
|
||||
|
||||
log::info!("Vendor: {}", display.get_opengl_vendor_string());
|
||||
log::info!("Renderer: {}", display.get_opengl_renderer_string());
|
||||
log::info!("OpenGL: {}", display.get_opengl_version_string());
|
||||
log::info!("Supports GLSL: {:?}", display.get_supported_glsl_version());
|
||||
log::info!("Framebuffer dimensions: {:?}", display.get_framebuffer_dimensions());
|
||||
if display.is_context_loss_possible() { log::warn!("OpenGL context loss possible") }
|
||||
if display.is_robust() { log::warn!("OpenGL implementation is not robust") }
|
||||
if display.is_debug() { log::info!("OpenGL context is in debug mode") }
|
||||
|
||||
assert!(display.is_glsl_version_supported(&Version(GlApiTy::GlEs, 3, 0)), "GLSL ES 3.0 is not supported");
|
||||
|
||||
Self { window, display }
|
||||
Self { window }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
0
kubi/src/rendering/shaders.rs
Normal file
0
kubi/src/rendering/shaders.rs
Normal file
Loading…
Reference in a new issue