aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/docs.yml50
-rw-r--r--.github/workflows/rust.yml24
-rw-r--r--README.md12
-rw-r--r--src/components.rs4
-rw-r--r--src/lib.rs11
-rw-r--r--src/render_assets.rs15
6 files changed, 103 insertions, 13 deletions
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..86035e8
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,50 @@
+name: Docs
+on:
+ push:
+ branches: [master]
+permissions:
+ contents: read
+ pages: write
+ id-token: write
+concurrency:
+ group: deploy
+ cancel-in-progress: false
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Install Dependencies
+ run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
+ - name: Setup Rust
+ uses: dtolnay/rust-toolchain@stable
+ - name: Configure cache
+ uses: Swatinem/rust-cache@v2
+ - name: Setup pages
+ id: pages
+ uses: actions/configure-pages@v4
+ - name: Clean docs folder
+ run: cargo clean --doc
+ - name: Build docs
+ run: cargo doc --no-deps
+ - name: Add redirect
+ run: echo '<meta http-equiv="refresh" content="0;url=framebuffer_extract/index.html">' > target/doc/index.html
+ - name: Remove lock file
+ run: rm target/doc/.lock
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v3
+ with:
+ path: target/doc
+ deploy:
+ name: Deploy
+ environment:
+ name: github-pages
+ url: ${{ steps.deployment.outputs.page_url }}
+ runs-on: ubuntu-latest
+ needs: build
+ steps:
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v4
diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml
new file mode 100644
index 0000000..e38739d
--- /dev/null
+++ b/.github/workflows/rust.yml
@@ -0,0 +1,24 @@
+name: Rust
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Install Dependencies
+ run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
+ - name: Build
+ run: cargo build --verbose
+ - name: Run tests
+ run: cargo test --verbose
diff --git a/README.md b/README.md
index 4f0bf79..84a918a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# grex_framebuffer_extract
+# bevy_framebuffer_extract
A plugin for the [Bevy](https://bevyengine.org) engine which allows for exporting framebuffer data from a camera.
@@ -15,8 +15,8 @@ Currently it only supports cameras which render to a render texture.
### Using git URL in Cargo.toml
```toml
-[dependencies.grex_framebuffer_extract]
-git = "https://github.com/exvacuum/grex_framebuffer_extract.git"
+[dependencies.bevy_framebuffer_extract]
+git = "https://github.com/exvacuum/bevy_framebuffer_extract.git"
```
## Usage
@@ -24,13 +24,13 @@ git = "https://github.com/exvacuum/grex_framebuffer_extract.git"
In `main.rs`:
```rs
use bevy::prelude::*;
-use grex_framebuffer_extract;
+use bevy_framebuffer_extract;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
- grex_framebuffer_extract::FramebufferExtractPlugin,
+ bevy_framebuffer_extract::FramebufferExtractPlugin,
))
.run();
}
@@ -72,7 +72,7 @@ commands.spawn((
},
..Default::default()
},
- grex_framebuffer_extract::ExtractFramebufferBundle {
+ bevy_framebuffer_extract::ExtractFramebufferBundle {
source: framebuffer_extract_sources.add(FramebufferExtractSource(image_handle.clone())), // ResMut<Assets<FramebufferExtractSource>>
destination: FramebufferExtractDestination::default(),
},
diff --git a/src/components.rs b/src/components.rs
index c1122d0..f9fe912 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -4,6 +4,7 @@ use bevy::{ecs::query::QueryItem, prelude::*, render::extract_component::Extract
use crate::render_assets::FramebufferExtractSource;
+/// Framebuffer extraction destination. Contains the image which the framebuffer is extracted to.
#[derive(Component, Default, Clone)]
pub struct FramebufferExtractDestination(pub Arc<Mutex<Image>>);
@@ -21,8 +22,11 @@ impl ExtractComponent for FramebufferExtractDestination {
}
}
+/// Bundle containing both a source and destination for framebuffer extraction.
#[derive(Bundle)]
pub struct ExtractFramebufferBundle {
+ /// Source
pub source: Handle<FramebufferExtractSource>,
+ /// Destination
pub dest: FramebufferExtractDestination,
}
diff --git a/src/lib.rs b/src/lib.rs
index 05f387d..29a5896 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,8 @@
+#![warn(missing_docs)]
+
+//! Plugin for the Bevy game engine which provides the ability to extract the frambuffer image after rendering
+//! to use for whatever you want.
+
use bevy::{
prelude::*,
render::{
@@ -9,11 +14,15 @@ use components::FramebufferExtractDestination;
use nodes::{FramebufferExtractLabel, FramebufferExtractNode};
use render_assets::FramebufferExtractSource;
+/// Components used by this plugin.
pub mod components;
-mod nodes;
+/// Render assets used by this plugin.
pub mod render_assets;
+
+mod nodes;
mod systems;
+/// Plugin which handles framebuffer extraction.
pub struct FramebufferExtractPlugin;
impl Plugin for FramebufferExtractPlugin {
diff --git a/src/render_assets.rs b/src/render_assets.rs
index 0e2cd4d..e5277d7 100644
--- a/src/render_assets.rs
+++ b/src/render_assets.rs
@@ -8,15 +8,18 @@ use bevy::{
},
};
+/// Render-world version of FramebufferExtractSource
pub struct GpuFramebufferExtractSource {
- pub buffer: Buffer,
- pub source_handle: Handle<Image>,
- pub source_size: Extent3d,
- pub bytes_per_row: u32,
- pub padded_bytes_per_row: u32,
- pub format: TextureFormat,
+ pub(crate) buffer: Buffer,
+ pub(crate) source_handle: Handle<Image>,
+ pub(crate) source_size: Extent3d,
+ pub(crate) bytes_per_row: u32,
+ pub(crate) padded_bytes_per_row: u32,
+ pub(crate) format: TextureFormat,
}
+/// Framebuffer extraction source. Contains a handle to the render texture which will be extracted
+/// from.
#[derive(Asset, Reflect, Clone, Default)]
pub struct FramebufferExtractSource(pub Handle<Image>);