Move cube face target mapping to renderer gl

This commit is contained in:
2026-06-01 18:09:12 +02:00
parent 4212387b70
commit 7d80afce2f
6 changed files with 71 additions and 17 deletions

View File

@@ -1,5 +1,7 @@
#include "renderer_gl/opengl_capabilities.h"
#include <array>
namespace pp::renderer::gl {
namespace {
@@ -30,6 +32,12 @@ constexpr std::uint32_t gl_framebuffer_incomplete_read_buffer = 0x8CDCU;
constexpr std::uint32_t gl_framebuffer_unsupported = 0x8CDDU;
constexpr std::uint32_t gl_framebuffer_undefined = 0x8219U;
constexpr std::uint32_t gl_framebuffer_incomplete_multisample = 0x8D56U;
constexpr std::uint32_t gl_texture_cube_map_positive_x = 0x8515U;
constexpr std::uint32_t gl_texture_cube_map_negative_x = 0x8516U;
constexpr std::uint32_t gl_texture_cube_map_positive_y = 0x8517U;
constexpr std::uint32_t gl_texture_cube_map_negative_y = 0x8518U;
constexpr std::uint32_t gl_texture_cube_map_positive_z = 0x8519U;
constexpr std::uint32_t gl_texture_cube_map_negative_z = 0x851AU;
[[nodiscard]] bool contains(std::string_view text, std::string_view needle) noexcept
{
@@ -163,4 +171,28 @@ std::uint32_t primitive_mode_for_stroke_count(std::uint32_t vertex_or_index_coun
return gl_lines;
}
std::span<const std::uint32_t> panopainter_cube_face_texture_targets() noexcept
{
static constexpr std::array<std::uint32_t, 6> targets {
gl_texture_cube_map_negative_z, // front
gl_texture_cube_map_negative_x, // right
gl_texture_cube_map_positive_z, // back
gl_texture_cube_map_positive_x, // left
gl_texture_cube_map_negative_y, // top
gl_texture_cube_map_positive_y, // bottom
};
return targets;
}
std::uint32_t cube_face_texture_target(std::uint32_t face_index) noexcept
{
const auto targets = panopainter_cube_face_texture_targets();
if (face_index >= targets.size()) {
return 0U;
}
return targets[face_index];
}
}

View File

@@ -36,5 +36,7 @@ struct OpenGlPixelFormat {
[[nodiscard]] std::uint32_t index_type_for_index_size(std::uint32_t index_size_bytes) noexcept;
[[nodiscard]] std::uint32_t primitive_mode_for_fill_count(std::uint32_t vertex_or_index_count) noexcept;
[[nodiscard]] std::uint32_t primitive_mode_for_stroke_count(std::uint32_t vertex_or_index_count) noexcept;
[[nodiscard]] std::span<const std::uint32_t> panopainter_cube_face_texture_targets() noexcept;
[[nodiscard]] std::uint32_t cube_face_texture_target(std::uint32_t face_index) noexcept;
}