Route retained draw state through GL dispatch

This commit is contained in:
2026-06-04 23:50:50 +02:00
parent 111cc8c892
commit 3cd1d46025
6 changed files with 92 additions and 29 deletions

View File

@@ -32,6 +32,11 @@ void set_opengl_active_texture(std::uint32_t texture_unit) noexcept
glActiveTexture(static_cast<GLenum>(texture_unit));
}
void bind_opengl_texture(std::uint32_t target, std::uint32_t texture) noexcept
{
glBindTexture(static_cast<GLenum>(target), static_cast<GLuint>(texture));
}
void set_opengl_clear_color(float r, float g, float b, float a) noexcept
{
glClearColor(r, g, b, a);
@@ -108,6 +113,17 @@ void set_layer_active_texture_unit(std::uint32_t unit_index)
LOG("Layer active texture dispatch failed because: %s", status.message);
}
void bind_layer_texture_cube(std::uint32_t texture_id)
{
const auto status = pp::renderer::gl::bind_opengl_texture_cube(
texture_id,
pp::renderer::gl::OpenGlTexture2DBindDispatch {
.bind_texture = bind_opengl_texture,
});
if (!status.ok())
LOG("Layer cube texture bind dispatch failed because: %s", status.message);
}
void copy_layer_framebuffer_to_texture(
std::uint32_t texture_target,
std::int32_t destination_x,
@@ -248,7 +264,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/)
apply_layer_viewport(0, 0, latlong.getWidth(), latlong.getHeight());
set_layer_active_texture_unit(0U);
glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id);
bind_layer_texture_cube(cube.m_cubetex_id);
ShaderManager::use(kShader::Equirect);
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
@@ -290,7 +306,7 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/)
apply_layer_viewport(0, 0, latlong.getWidth(), latlong.getHeight());
set_layer_active_texture_unit(0U);
glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id);
bind_layer_texture_cube(cube.m_cubetex_id);
ShaderManager::use(kShader::Equirect);
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));