Skip to content

Commit

Permalink
chore: fix: #68 - updated dependencies to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
ElhamAryanpur committed Aug 12, 2024
1 parent 3cc6886 commit f13bcf8
Show file tree
Hide file tree
Showing 12 changed files with 1,633 additions and 913 deletions.
1,349 changes: 678 additions & 671 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "blue_engine"
version = "0.5.14"
version = "0.5.16"
authors = ["Elham Aryanpur <elhamaryanpur5@gmail.com>"]
edition = "2021"
description = "General-Purpose, Easy-to-use, Fast, and Portable graphics engine"
Expand All @@ -21,11 +21,10 @@ android_native_activity = ["winit/android-native-activity"]
android_game_activity = ["winit/android-game-activity"]

[dependencies]
image = { version = "0.25.1" }
futures = "0.3"
winit = { version = "0.29.8", features = ["rwh_05"] }
winit_input_helper = "0.16"
wgpu = { version = "0.20.1" }
image = { version = "0.25.2" }
pollster = "0.3"
winit = { version = "0.30", features = ["rwh_06"] }
wgpu = { version = "22.1.0" }
bytemuck = { version = "1.16", features = ["derive"] }
eyre = "0.6"
downcast = "0.11"
Expand All @@ -37,7 +36,7 @@ log = { version = "0.4", optional = true }
android_logger = { version = "0.14", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wgpu = { version = "0.20.1", features = ["webgl"] }
wgpu = { version = "22.1.0", features = ["webgl"] }

# Smallest possible release build
#
Expand Down
27 changes: 14 additions & 13 deletions examples/dev/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let mut engine = Engine::new_config(blue_engine::WindowDescriptor {
power_preference: blue_engine::PowerPreference::None,
present_mode: blue_engine::wgpu::PresentMode::Fifo,
limits: blue_engine::wgpu::Limits::downlevel_defaults(),
limits: blue_engine::wgpu::Limits::downlevel_webgl2_defaults(),
features: blue_engine::wgpu::Features::empty(),
backends: blue_engine::Backends::GL,
..Default::default()
Expand Down Expand Up @@ -92,18 +92,19 @@ fn main() {
.unwrap()
.set_position(-0.2f32, 0f32, 0.001f32);

let video_mode = engine
.event_loop
.available_monitors()
.next()
.unwrap()
.video_modes()
.next()
.unwrap();

engine
.window
.set_fullscreen(Some(blue_engine::Fullscreen::Exclusive(video_mode)));
// ! REMEMBER
// let video_mode = engine
// .event_loop
// .available_monitors()
// .next()
// .unwrap()
// .video_modes()
// .next()
// .unwrap();

// engine
// .window
// .set_fullscreen(Some(blue_engine::Fullscreen::Exclusive(video_mode)));

let speed = -0.05;

Expand Down
1 change: 1 addition & 0 deletions src/definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ impl crate::header::Renderer {
alpha_to_coverage_enabled: settings.alpha_to_coverage_enabled,
},
multiview: None,
cache: None,
});

Ok(render_pipeline)
Expand Down
118 changes: 93 additions & 25 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,14 @@ impl Default for ObjectSettings {
unsafe impl Send for ObjectSettings {}
unsafe impl Sync for ObjectSettings {}

/// The engine is the main starting point of using the Blue Engine. Everything that runs on Blue Engine will be under this struct.
/// The engine is the main starting point of using the Blue Engine.
/// Everything that runs on Blue Engine will be under this struct.
/// The structure of engine is monolithic, but the underlying data and the way it works is not.
/// It gives a set of default data to work with, but also allow you to go beyond that and work as low level as you wish to.
/// It gives a set of default data to work with,
/// but also allow you to go beyond that and work as low level as you wish to.
///
/// You can also use the Engine to build you own custom structure the way you wish for it to be. Possibilities are endless!
/// You can also use the Engine to build you own custom structure the way you wish for it to be.
/// Possibilities are endless!
///
/// To start using the Blue Engine, you can start by creating a new Engine like follows:
/// ```
Expand All @@ -176,38 +179,77 @@ unsafe impl Sync for ObjectSettings {}
/// let engine = Engine::new().expect("Couldn't create the engine");
/// }
/// ```
/// The WindowDescriptor simply holds what features you would like for your window. If you are reading this on later version of
/// the engine, you might be able to even run the engine in headless mode meaning there would not be a need for a window and the
/// The WindowDescriptor simply holds what features you would like for your window.
/// If you are reading this on later version of
/// the engine, you might be able to even run the engine in headless mode
/// meaning there would not be a need for a window and the
/// renders would come as image files.
///
/// If you so wish to have a window, you would need to start a window update loop. The update loop of window runs a frame every few millisecond,
/// and gives you details of what is happening during this time, like input events. You can also modify existing parts of the engine during
/// this update loop, such as changing camera to look differently, or creating a new object on the scene, or even changing window details!
/// If you so wish to have a window, you would need to start a window update loop.
/// The update loop of window runs a frame every few millisecond,
/// and gives you details of what is happening during this time, like input events.
/// You can also modify existing parts of the engine during
/// this update loop, such as changing camera to look differently,
/// or creating a new object on the scene, or even changing window details!
///
/// The update loop is just a method of the Engine struct that have one argument which is a callback function.
/// The update loop is just a method of the Engine struct
/// that have one argument which is a callback function.
/// ```
///
/// ```
/// [THE DATA HERE IS WORK IN PROGRESS!]
pub struct Engine {
/// The renderer does exactly what it is called. It works with the GPU to render frames according to the data you gave it.
/// The renderer does exactly what it is called.
/// It works with the GPU to render frames according to the data you gave it.
pub renderer: Renderer,
/// The event_loop handles the events of the window and inputs, so it's used internally
pub event_loop: winit::event_loop::EventLoop<()>,
/// The window handles everything about window and inputs. This includes ability to modify window and listen to input devices for changes.
/// The event_loop handles the events of the window and inputs.
///
/// #### USED INTERNALLY
pub event_loop_control_flow: crate::winit::event_loop::ControlFlow,
/// The window handles everything about window and inputs.
/// This includes ability to modify window and listen toinput devices for changes.
///
/// ### The window is not available before update_loop.
pub window: Window,
/// The object system is a way to make it easier to work with the engine. Obviously you can work without it, but it's for those who
/// The object system is a way to make it easier to work with the engine.
/// Obviously you can work without it, but it's for those who
/// do not have the know-how, or wish to handle all the work of rendering data manually.
pub objects: ObjectStorage,
/// The camera handles the way the scene looks when rendered. You can modify everything there is to camera through this.
/// The camera handles the way the scene looks when rendered.
/// You can modify everything there is to camera through this.
pub camera: CameraContainer,
/// Handles all engine plugins
pub signals: SignalStorage,

/// holds the update_loop function
///
/// #### USED INTERNALLY
#[allow(clippy::type_complexity)]
pub update_loop: Option<
Box<
dyn 'static
+ FnMut(
// Core
&mut Renderer,
&mut Window,
&mut ObjectStorage,
&crate::utils::winit_input_helper::WinitInputHelper,
&mut CameraContainer,
&mut crate::SignalStorage,
),
>,
>,

/// input events
///
/// #### USED INTERNALLY
pub input_events: crate::utils::winit_input_helper::WinitInputHelper,
}
unsafe impl Send for Engine {}
unsafe impl Sync for Engine {}

/// Container for pipeline values. Each pipeline takes only 1 vertex shader, 1 fragment shader, 1 texture data, and optionally a vector of uniform data.
/// Container for pipeline values. Each pipeline takes only 1 vertex shader,
/// 1 fragment shader, 1 texture data, and optionally a vector of uniform data.
#[derive(Debug)]
pub struct Pipeline {
/// the shader buffer that's sent to the gpu
Expand All @@ -234,9 +276,11 @@ pub enum PipelineData<T> {
/// Container for vertex and index buffer
#[derive(Debug)]
pub struct VertexBuffers {
/// An array of vertices. A vertex is a point in 3D space containing an X, Y, and a Z coordinate between -1 and +1
/// An array of vertices. A vertex is a point in 3D space containing
/// an X, Y, and a Z coordinate between -1 and +1
pub vertex_buffer: wgpu::Buffer,
/// An array of indices. Indices are a way to reuse vertices, this in turn helps greatly in reduction of amount of vertices needed to be sent to the GPU
/// An array of indices. Indices are a way to reuse vertices,
/// this in turn helps greatly in reduction of amount of vertices needed to be sent to the GPU
pub index_buffer: wgpu::Buffer,
/// The length of the vertex buffer
pub length: u32,
Expand All @@ -247,7 +291,8 @@ unsafe impl Sync for VertexBuffers {}
/// Main renderer class. this will contain all methods and data related to the renderer
#[derive(Debug)]
pub struct Renderer {
/// A [`wgpu::Surface`] represents a platform-specific surface (e.g. a window) onto which rendered images may be presented.
/// A [`wgpu::Surface`] represents a platform-specific surface
/// (e.g. a window) onto which rendered images may be presented.
pub surface: Option<wgpu::Surface<'static>>,
/// Context for all of the gpu objects
pub instance: wgpu::Instance,
Expand Down Expand Up @@ -299,17 +344,32 @@ pub struct WindowDescriptor {
/// The backend to use for the draw
pub backends: crate::Backends,
/// The features to be enabled on a backend
///
/// read more at [wgpu::Features]
pub features: crate::wgpu::Features,
/// Controls how the events are processed
///
/// read more at [winit::event_loop::ControlFlow]
pub control_flow: crate::winit::event_loop::ControlFlow,
/// The presentation mode of renderer for things like VSync
///
/// read more at [wgpu::PresentMode]
pub present_mode: crate::wgpu::PresentMode,
/// Limits to be required based on the generation of the GPU and the API
/// Limits to be required based on the generation of the GPU and the API.
///
/// read more at [wgpu::Limits]
pub limits: crate::wgpu::Limits,
/// The alpha mode which specifies how the alpha channel of the textures should be handled during compositing.
/// The alpha mode which specifies how the alpha channel of
/// the textures should be handled during compositing.
pub alpha_mode: crate::wgpu::CompositeAlphaMode,
/// The desired frame latency, check [wgpu::SurfaceConfiguration::desired_maximum_frame_latency]
/// The desired frame latency.
///
/// read more at [wgpu::SurfaceConfiguration::desired_maximum_frame_latency]
pub desired_maximum_frame_latency: u32,
/// How the memory should be utilized
///
/// read more at [wgpu::MemoryHints]
pub memory_hints: crate::wgpu::MemoryHints,
}
impl std::default::Default for WindowDescriptor {
/// Will quickly create a window with default settings
Expand Down Expand Up @@ -337,6 +397,7 @@ impl std::default::Default for WindowDescriptor {
limits: crate::wgpu::Limits::default(),
alpha_mode: crate::wgpu::CompositeAlphaMode::Auto,
desired_maximum_frame_latency: 2,
memory_hints: crate::MemoryHints::Performance,
}
}
}
Expand Down Expand Up @@ -527,7 +588,8 @@ pub trait Signal: Any {
) {
}
}
// The engine needs to know the functions of Signal to do things internally, so we use downcast and not the std::any::Any
// The engine needs to know the functions of Signal to do things internally,
// so we use downcast and not the std::any::Any
downcast!(dyn Signal);

/// Defines how the rotation axis is
Expand Down Expand Up @@ -662,8 +724,14 @@ pub enum ExecuteOrder {
#[derive(Debug)]
pub struct Window {
/// The winit window itself.
pub window: std::sync::Arc<crate::winit::window::Window>,
pub window: Option<std::sync::Arc<crate::winit::window::Window>>,
/// Default attributes of the window\
pub default_attributes: winit::window::WindowAttributes,
/// Whether the engine should close.
pub should_close: bool,
}
impl_deref_field!(Window, std::sync::Arc<crate::winit::window::Window>, window);
impl_deref_field!(
Window,
Option<std::sync::Arc<crate::winit::window::Window>>,
window
);
6 changes: 4 additions & 2 deletions src/header/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ pub use wgpu::Backends;
/// Encoder from wgpu
pub use wgpu::CommandEncoder;
pub use wgpu::LoadOp;
/// Memory hints
pub use wgpu::MemoryHints;
pub use wgpu::Operations;
pub use wgpu::RenderPassColorAttachment;
pub use wgpu::RenderPassDescriptor;
/// Surface Texture
pub use wgpu::TextureView;

/// Input helper
pub use crate::utils::winit_input_helper::WinitInputHelper as InputHelper;
/// all of downcast
pub use downcast;
/// all of image
Expand Down Expand Up @@ -64,5 +68,3 @@ pub use winit::keyboard::Key;
pub use winit::keyboard::KeyCode;
/// Fullscreen enum
pub use winit::window::Fullscreen;
/// Input helper
pub use winit_input_helper::WinitInputHelper as InputHelper;
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
//!
//! 1) set a backend that targets your older hardware, such as GL using the backends field: `backend: blue_engine::wgpu::Backends::GL`
//! 2) experiement with the limits field, which describes what features you need. `limits: blue_engine::wgpu::Limits::default()`. there
//! are three options for limits: `default` for normal hardware, `downlevel_defaults` which are compatible with GLES-3 and D3D-11, or
//! `downlevel_webgl2_defaults` which is also compatible with WebGL2, and the lowest level for limits and can support very old hardware.
//! are three options for limits: `default` for normal hardware, `downlevel_defaults` which are compatible with GLES-3 and D3D-11, or
//! `downlevel_webgl2_defaults` which is also compatible with WebGL2, and the lowest level for limits and can support very old hardware.
//!
//! with these two changes, hopefully you can get Blue Engine to run on older hardware. If not, please let me know so I can help you further.
Expand Down
Loading

0 comments on commit f13bcf8

Please sign in to comment.