use crate::{
core::sstorage::ImmutableString,
renderer::framework::{
error::FrameworkError,
gpu_program::{GpuProgram, UniformLocation},
server::GraphicsServer,
},
};
pub struct SkyboxShader {
pub program: Box<dyn GpuProgram>,
pub uniform_buffer_binding: usize,
pub cubemap_texture: UniformLocation,
}
impl SkyboxShader {
pub fn new(server: &dyn GraphicsServer) -> Result<Self, FrameworkError> {
let fragment_source = include_str!("shaders/skybox_fs.glsl");
let vertex_source = include_str!("shaders/skybox_vs.glsl");
let program = server.create_program("SkyboxShader", vertex_source, fragment_source)?;
Ok(Self {
uniform_buffer_binding: program
.uniform_block_index(&ImmutableString::new("Uniforms"))?,
cubemap_texture: program.uniform_location(&ImmutableString::new("cubemapTexture"))?,
program,
})
}
}