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

@@ -23,11 +23,6 @@ namespace {
return static_cast<GLint>(pp::renderer::gl::texture_format_for_channel_count(1U).pixel_format);
}
[[nodiscard]] GLenum texture_unit(std::uint32_t unit_index) noexcept
{
return static_cast<GLenum>(pp::renderer::gl::active_texture_unit(unit_index));
}
void gen_buffers_adapter(std::uint32_t count, std::uint32_t* ids) noexcept
{
glGenBuffers(static_cast<GLsizei>(count), ids);
@@ -97,6 +92,22 @@ void draw_arrays_adapter(std::uint32_t mode, std::int32_t first, std::int32_t co
glDrawArrays(static_cast<GLenum>(mode), static_cast<GLint>(first), static_cast<GLsizei>(count));
}
void activate_texture_adapter(std::uint32_t texture_unit) noexcept
{
glActiveTexture(static_cast<GLenum>(texture_unit));
}
void activate_text_texture_unit(std::uint32_t unit_index)
{
const auto status = pp::renderer::gl::activate_opengl_texture_unit(
unit_index,
pp::renderer::gl::OpenGlActiveTextureDispatch {
.active_texture = activate_texture_adapter,
});
if (!status.ok())
LOG("Text active texture dispatch failed because: %s", status.message);
}
[[nodiscard]] std::span<const pp::renderer::gl::OpenGlVertexAttribute> text_mesh_vertex_attributes() noexcept
{
static const std::array<pp::renderer::gl::OpenGlVertexAttribute, 2> attributes {
@@ -431,7 +442,7 @@ void TextMesh::draw()
auto& f = FontManager::get(font, size, weight, italic);
if (f.font_tex.ready())
{
glActiveTexture(texture_unit(0U));
activate_text_texture_unit(0U);
f.font_tex.bind();
FontManager::m_sampler.bind(0);