Added docs + renamed

This commit is contained in:
Silas Bartha 2024-06-03 22:00:19 -04:00
parent ef6c295415
commit 5560d5d092
Signed by: soaos
GPG Key ID: 9BD3DCC0D56A09B2
6 changed files with 103 additions and 13 deletions

50
.github/workflows/docs.yml vendored Normal file
View File

@ -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

24
.github/workflows/rust.yml vendored Normal file
View File

@ -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

View File

@ -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(),
},

View File

@ -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,
}

View File

@ -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 {

View File

@ -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>);