summaryrefslogtreecommitdiff
path: root/engine/src/rendering.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-08-29 23:01:48 +0200
committerHampusM <hampus@hampusmat.com>2026-08-29 23:01:48 +0200
commit7baf722071707ecee0c61dd1eedc3d348e023930 (patch)
treeaabde179f608c77e3181dfbbc1735f3d2759f170 /engine/src/rendering.rs
parent001559fb4da769ee19ee464a6edaebc8957697a6 (diff)
feat(engine): add framebuffer rendering commands & draw properties
Diffstat (limited to 'engine/src/rendering.rs')
-rw-r--r--engine/src/rendering.rs48
1 files changed, 47 insertions, 1 deletions
diff --git a/engine/src/rendering.rs b/engine/src/rendering.rs
index cb6ec08..ffb5a4f 100644
--- a/engine/src/rendering.rs
+++ b/engine/src/rendering.rs
@@ -235,6 +235,14 @@ pub enum Command
update: TextureUpdate,
},
RemoveTexture(ObjectId),
+ CreateFramebuffer(ObjectId),
+ RemoveFramebuffer(ObjectId),
+ UpdateFramebufferProperties
+ {
+ object_id: ObjectId,
+ properties: FramebufferProperties,
+ update_flags: FramebufferPropertiesUpdateFlags,
+ },
CreateMesh
{
obj_id: ObjectId,
@@ -376,6 +384,12 @@ pub struct DrawProperties
pub scissor_test_enabled: bool,
pub scissor_box: ScissorBox,
pub face_culling_enabled: bool,
+
+ /// `None` for default framebuffer
+ pub draw_framebuffer: Option<ObjectId>,
+
+ /// `None` for default framebuffer
+ pub read_framebuffer: Option<ObjectId>,
}
impl Default for DrawProperties
@@ -391,13 +405,15 @@ impl Default for DrawProperties
scissor_test_enabled: false,
scissor_box: ScissorBox::default(),
face_culling_enabled: false,
+ draw_framebuffer: None,
+ read_framebuffer: None,
}
}
}
bitflags! {
#[derive(Debug, Clone, Copy)]
- pub struct DrawPropertiesUpdateFlags: usize
+ pub struct DrawPropertiesUpdateFlags: u16
{
const POLYGON_MODE_CONFIG = 1 << 0;
const BLENDING_CONFIG = 1 << 1;
@@ -407,6 +423,8 @@ bitflags! {
const SCISSOR_TEST_ENABLED = 1 << 5;
const SCISSOR_BOX = 1 << 6;
const FACE_CULLING_ENABLED = 1 << 7;
+ const DRAW_FRAMEBUFFER = 1 << 8;
+ const READ_FRAMEBUFFER = 1 << 9;
}
}
@@ -645,3 +663,31 @@ impl TexturePixelDataFormat
}
}
}
+
+/// Index of a color texture attached to a framebuffer.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct FramebufferColorTextureIndex(pub u8);
+
+#[derive(Debug, Default, Clone)]
+#[non_exhaustive]
+pub struct FramebufferProperties
+{
+ pub depth_texture: Option<FramebufferTexture>,
+ pub color_draw_buffer: Option<FramebufferColorTextureIndex>,
+}
+
+bitflags! {
+ #[derive(Debug, Default, Clone)]
+ pub struct FramebufferPropertiesUpdateFlags: u8
+ {
+ const DEPTH_TEXTURE = 1 << 0;
+ const COLOR_DRAW_BUFFER = 1 << 1;
+ }
+}
+
+#[derive(Debug, Clone)]
+pub struct FramebufferTexture
+{
+ pub object_id: ObjectId,
+ pub mipmap_level: u16,
+}