From 17323dd5a348ef81d0e0189590c7a6bdfdf42115 Mon Sep 17 00:00:00 2001 From: Able Date: Sun, 4 Dec 2022 05:19:23 -0600 Subject: [PATCH] updates + Addition of AGL --- Cargo.lock | 72 +++++++++++++++++++ Cargo.toml | 14 ++-- libraries/able_graphics_library/Cargo.toml | 9 +++ libraries/able_graphics_library/readme.md | 2 + libraries/able_graphics_library/src/buffer.rs | 3 + libraries/able_graphics_library/src/color.rs | 21 ++++++ .../able_graphics_library/src/commands.rs | 14 ++++ libraries/able_graphics_library/src/lib.rs | 11 +++ libraries/able_graphics_library/src/types.rs | 11 +++ libraries/able_graphics_library/src/vertex.rs | 16 +++++ {programs => libraries}/table/Cargo.toml | 0 {programs => libraries}/table/README.md | 0 {programs => libraries}/table/src/lib.rs | 0 programs/delete/Cargo.toml | 4 +- programs/list/Cargo.toml | 4 +- programs/shell/Cargo.toml | 2 +- programs/table_view/Cargo.toml | 2 +- programs/undelete/Cargo.toml | 6 +- 18 files changed, 175 insertions(+), 16 deletions(-) create mode 100644 libraries/able_graphics_library/Cargo.toml create mode 100644 libraries/able_graphics_library/readme.md create mode 100644 libraries/able_graphics_library/src/buffer.rs create mode 100644 libraries/able_graphics_library/src/color.rs create mode 100644 libraries/able_graphics_library/src/commands.rs create mode 100644 libraries/able_graphics_library/src/lib.rs create mode 100644 libraries/able_graphics_library/src/types.rs create mode 100644 libraries/able_graphics_library/src/vertex.rs rename {programs => libraries}/table/Cargo.toml (100%) rename {programs => libraries}/table/README.md (100%) rename {programs => libraries}/table/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 52323c3..96a51b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,13 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "able_graphics_library" +version = "0.1.0" +dependencies = [ + "versioning", +] + [[package]] name = "ahash" version = "0.7.6" @@ -24,6 +31,12 @@ dependencies = [ "version_check", ] +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + [[package]] name = "base64" version = "0.13.1" @@ -55,10 +68,26 @@ dependencies = [ "toml 0.5.9 (git+https://git.ablecorp.us/theoddgarlic/toml-rs)", ] +[[package]] +name = "delete" +version = "0.1.0" +dependencies = [ + "anyhow", + "clparse", + "fs_extra", + "trash_manifest", +] + [[package]] name = "derelict_microarchitecture" version = "0.1.0" +[[package]] +name = "fs_extra" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394" + [[package]] name = "getrandom" version = "0.2.8" @@ -98,6 +127,15 @@ version = "0.2.138" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8" +[[package]] +name = "list" +version = "0.1.0" +dependencies = [ + "clparse", + "number_prefix", + "table", +] + [[package]] name = "log" version = "0.4.17" @@ -111,6 +149,12 @@ dependencies = [ name = "no_video" version = "0.1.0" +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "once_cell" version = "1.16.0" @@ -166,6 +210,13 @@ dependencies = [ "syn", ] +[[package]] +name = "shell" +version = "0.1.0" +dependencies = [ + "clparse", +] + [[package]] name = "syn" version = "1.0.105" @@ -177,6 +228,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "table" +version = "0.1.0" + +[[package]] +name = "table_view" +version = "0.1.0" +dependencies = [ + "table", +] + [[package]] name = "tar" version = "0.1.0" @@ -232,6 +294,16 @@ dependencies = [ "toml 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "undelete" +version = "0.1.0" +dependencies = [ + "anyhow", + "clparse", + "fs_extra", + "trash_manifest", +] + [[package]] name = "unicode-ident" version = "1.0.5" diff --git a/Cargo.toml b/Cargo.toml index fb4d00b..04df00c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,22 +1,22 @@ [workspace] members = [ - "drivers/basic_driver", "drivers/graphics/derelict_microarchitecture", "drivers/graphics/ground", "drivers/graphics/novideo", "drivers/graphics/vgable", + "libraries/able_graphics_library", "libraries/clparse", "libraries/tar", "libraries/trash_manifest", "libraries/versioning", + "libraries/table", - # "programs/delete", - # "programs/list", - # "programs/shell", - # "programs/table", - # "programs/table_view", - # "programs/undelete", + "programs/delete", + "programs/list", + "programs/shell", + "programs/table_view", + "programs/undelete", ] diff --git a/libraries/able_graphics_library/Cargo.toml b/libraries/able_graphics_library/Cargo.toml new file mode 100644 index 0000000..3859e06 --- /dev/null +++ b/libraries/able_graphics_library/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "able_graphics_library" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +versioning = { path = "../versioning" } diff --git a/libraries/able_graphics_library/readme.md b/libraries/able_graphics_library/readme.md new file mode 100644 index 0000000..06cc2bc --- /dev/null +++ b/libraries/able_graphics_library/readme.md @@ -0,0 +1,2 @@ +# AGL +A simple (As of version 0.1.0) 3d graphics library based around vertex buffers and drawing triangles \ No newline at end of file diff --git a/libraries/able_graphics_library/src/buffer.rs b/libraries/able_graphics_library/src/buffer.rs new file mode 100644 index 0000000..781b5af --- /dev/null +++ b/libraries/able_graphics_library/src/buffer.rs @@ -0,0 +1,3 @@ +pub enum BufferUsage { + Vertex, +} diff --git a/libraries/able_graphics_library/src/color.rs b/libraries/able_graphics_library/src/color.rs new file mode 100644 index 0000000..c2ec0d6 --- /dev/null +++ b/libraries/able_graphics_library/src/color.rs @@ -0,0 +1,21 @@ +pub struct Color3 { + pub r: u8, + pub g: u8, + pub b: u8, +} + +impl Color3 { + /// Usage + /// The alpha value is a number between 0.0 and 1.0, which represents the transparency + /// or translucency of the other color. + pub fn blend(&self, other: &Self, alpha: f32) -> Self { + let r = (1.0 - alpha) * f32::from(self.r) + alpha * f32::from(other.r); + let g = (1.0 - alpha) * f32::from(self.g) + alpha * f32::from(other.g); + let b = (1.0 - alpha) * f32::from(self.b) + alpha * f32::from(other.b); + Self { + r: r as u8, + g: g as u8, + b: b as u8, + } + } +} diff --git a/libraries/able_graphics_library/src/commands.rs b/libraries/able_graphics_library/src/commands.rs new file mode 100644 index 0000000..607e738 --- /dev/null +++ b/libraries/able_graphics_library/src/commands.rs @@ -0,0 +1,14 @@ +use crate::{buffer::BufferUsage, color::Color3, types::BufferID, vertex::Vertex}; + +pub enum DrawCommand { + UpdateFrame, + Clear(Color3), + ClearBuffer(BufferID), + + AppendVertex(BufferID, Vertex), + + MakeBuffer { + num_vertices: usize, + usage: BufferUsage, + }, +} diff --git a/libraries/able_graphics_library/src/lib.rs b/libraries/able_graphics_library/src/lib.rs new file mode 100644 index 0000000..c999ccc --- /dev/null +++ b/libraries/able_graphics_library/src/lib.rs @@ -0,0 +1,11 @@ +pub mod buffer; +pub mod color; +pub mod commands; +pub mod types; +pub mod vertex; + +pub const VERSION: versioning::Version = versioning::Version { + major: 0, + minor: 1, + patch: 0, +}; diff --git a/libraries/able_graphics_library/src/types.rs b/libraries/able_graphics_library/src/types.rs new file mode 100644 index 0000000..926fbf8 --- /dev/null +++ b/libraries/able_graphics_library/src/types.rs @@ -0,0 +1,11 @@ +pub type BufferID = u16; + +pub struct Float3Array { + pub inner: [f32; 3], +} + +pub struct Float2Array { + pub inner: [f32; 2], +} + +pub type Position3 = Float3Array; diff --git a/libraries/able_graphics_library/src/vertex.rs b/libraries/able_graphics_library/src/vertex.rs new file mode 100644 index 0000000..873fd80 --- /dev/null +++ b/libraries/able_graphics_library/src/vertex.rs @@ -0,0 +1,16 @@ +use crate::{ + color::Color3, + types::{Float2Array, Float3Array, Position3}, +}; + +pub struct Vertex { + pub position: Position3, + pub normal: Float3Array, + pub color: Color3, + + pub tex_coords: Float2Array, +} + +pub struct VertexBuffer { + pub vertex_buffer: Vec, +} diff --git a/programs/table/Cargo.toml b/libraries/table/Cargo.toml similarity index 100% rename from programs/table/Cargo.toml rename to libraries/table/Cargo.toml diff --git a/programs/table/README.md b/libraries/table/README.md similarity index 100% rename from programs/table/README.md rename to libraries/table/README.md diff --git a/programs/table/src/lib.rs b/libraries/table/src/lib.rs similarity index 100% rename from programs/table/src/lib.rs rename to libraries/table/src/lib.rs diff --git a/programs/delete/Cargo.toml b/programs/delete/Cargo.toml index a194246..945e937 100644 --- a/programs/delete/Cargo.toml +++ b/programs/delete/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clparse = { path = "../clparse", features = ["std"] } -trash_manifest = { path = "../trash_manifest" } +clparse = { path = "../../libraries/clparse", features = ["std"] } +trash_manifest = { path = "../../libraries/trash_manifest" } anyhow = "1.0" fs_extra = "1.2" diff --git a/programs/list/Cargo.toml b/programs/list/Cargo.toml index df88960..4035053 100644 --- a/programs/list/Cargo.toml +++ b/programs/list/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clparse = { path = "../clparse" } +clparse = { path = "../../libraries/clparse" } number_prefix = "*" -table = { path = "../table" } +table = { path = "../../libraries/table" } diff --git a/programs/shell/Cargo.toml b/programs/shell/Cargo.toml index 4227dfe..b033ed0 100644 --- a/programs/shell/Cargo.toml +++ b/programs/shell/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clparse = { path = "../clparse" } +clparse = { path = "../../libraries/clparse" } diff --git a/programs/table_view/Cargo.toml b/programs/table_view/Cargo.toml index f4e0a91..c67ce80 100644 --- a/programs/table_view/Cargo.toml +++ b/programs/table_view/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -table = { path = "../table" } +table = { path = "../../libraries/table" } diff --git a/programs/undelete/Cargo.toml b/programs/undelete/Cargo.toml index 49b3898..9517500 100644 --- a/programs/undelete/Cargo.toml +++ b/programs/undelete/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clparse = { path = "../clparse" } -trash_manifest = { path = "../trash_manifest" } +clparse = { path = "../../libraries/clparse" } +trash_manifest = { path = "../../libraries/trash_manifest" } anyhow = "1.0" -fs_extra = "1.2" \ No newline at end of file +fs_extra = "1.2"