ability to specify the face of the cube map in frame buffer attachment

This commit is contained in:
Dmitry Stepanov
2025-06-12 09:56:04 +03:00
parent 38db8b9925
commit a2732a7792
2 changed files with 21 additions and 1 deletions
+4 -1
View File
@@ -53,6 +53,7 @@ unsafe fn set_attachment(
gl_attachment_kind: u32,
texture: &GlTexture,
level: i32,
cube_map_face: Option<CubeMapFace>,
) {
match texture.kind() {
GpuTextureKind::Line { .. } => {
@@ -76,7 +77,7 @@ unsafe fn set_attachment(
server.gl.framebuffer_texture_2d(
glow::FRAMEBUFFER,
gl_attachment_kind,
glow::TEXTURE_CUBE_MAP_POSITIVE_X,
cube_map_face.map_or(glow::TEXTURE_CUBE_MAP_POSITIVE_X, |face| face.into_gl()),
Some(texture.id()),
level,
);
@@ -123,6 +124,7 @@ impl GlFrameBuffer {
depth_attachment_kind,
texture,
depth_attachment.level as i32,
depth_attachment.cube_map_face,
);
}
@@ -140,6 +142,7 @@ impl GlFrameBuffer {
color_attachment_kind,
texture,
color_attachment.level as i32,
color_attachment.cube_map_face,
);
color_buffers.push(color_attachment_kind);
}
+17
View File
@@ -58,6 +58,8 @@ pub struct Attachment {
pub texture: GpuTexture,
/// Mip level of the texture. In most cases, it can be zero.
pub level: usize,
/// Face of the cube map, this field is used only if the `texture` is a cube map.
pub cube_map_face: Option<CubeMapFace>,
}
impl Attachment {
@@ -67,6 +69,7 @@ impl Attachment {
kind: AttachmentKind::Color,
texture,
level: 0,
cube_map_face: None,
}
}
@@ -76,6 +79,18 @@ impl Attachment {
kind: AttachmentKind::Color,
texture,
level,
cube_map_face: None,
}
}
/// Creates a new [`AttachmentKind::Color`] attachment with the given texture and the cube map
/// face. The texture must be a cube map.
pub fn color_with_face(texture: GpuTexture, cube_map_face: CubeMapFace) -> Self {
Self {
kind: AttachmentKind::Color,
texture,
level: 0,
cube_map_face: Some(cube_map_face),
}
}
@@ -85,6 +100,7 @@ impl Attachment {
kind: AttachmentKind::Depth,
texture,
level: 0,
cube_map_face: None,
}
}
@@ -94,6 +110,7 @@ impl Attachment {
kind: AttachmentKind::DepthStencil,
texture,
level: 0,
cube_map_face: None,
}
}
}