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;
}

View File

@@ -9,12 +9,12 @@
std::map<uint16_t, Texture2D> TextureManager::m_textures;
std::array<int, 6> TextureCube::m_faces_map {
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
static_cast<int>(pp::renderer::gl::cube_face_texture_target(0U)),
static_cast<int>(pp::renderer::gl::cube_face_texture_target(1U)),
static_cast<int>(pp::renderer::gl::cube_face_texture_target(2U)),
static_cast<int>(pp::renderer::gl::cube_face_texture_target(3U)),
static_cast<int>(pp::renderer::gl::cube_face_texture_target(4U)),
static_cast<int>(pp::renderer::gl::cube_face_texture_target(5U)),
};
TextureCube::TextureCube(TextureCube&& other) noexcept