Move texture defaults behind renderer gl
This commit is contained in:
@@ -192,6 +192,10 @@ Known local toolchain state:
|
||||
`NodeStrokePreview` brush preview rendering also consumes backend-owned
|
||||
depth/scissor/blend state, viewport/clear-color queries, active texture
|
||||
units, 2D texture targets, copy targets, and sampler filters/wraps.
|
||||
Legacy `Texture2D`, `TextureManager`, `Sampler`, and `RTT` public headers no
|
||||
longer expose raw OpenGL enum defaults; default texture formats, sampler
|
||||
filters/wraps, and render-target formats resolve through backend-owned
|
||||
overloads.
|
||||
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
||||
for the current headless component matrix; see DEBT-0007 for remaining app
|
||||
and platform triplet migration.
|
||||
|
||||
@@ -459,6 +459,10 @@ active texture units to `pp_renderer_gl`.
|
||||
`NodeStrokePreview` brush preview rendering now delegates depth/scissor/blend
|
||||
state, viewport/clear-color queries, active texture units, 2D texture targets,
|
||||
copy targets, and sampler filters/wraps to `pp_renderer_gl`.
|
||||
Legacy `Texture2D`, `TextureManager`, `Sampler`, and `RTT` public headers no
|
||||
longer expose raw OpenGL enum defaults; default texture formats, sampler
|
||||
filters/wraps, and render-target formats are resolved through backend-owned
|
||||
overloads.
|
||||
The existing renderer classes are not yet fully
|
||||
behind the renderer interfaces.
|
||||
|
||||
|
||||
@@ -647,6 +647,11 @@ std::uint32_t repeat_texture_wrap() noexcept
|
||||
return gl_repeat;
|
||||
}
|
||||
|
||||
std::uint32_t clamp_to_edge_texture_wrap() noexcept
|
||||
{
|
||||
return gl_clamp_to_edge;
|
||||
}
|
||||
|
||||
std::uint32_t active_texture_unit(std::uint32_t unit_index) noexcept
|
||||
{
|
||||
return gl_texture0 + unit_index;
|
||||
|
||||
@@ -126,6 +126,7 @@ struct OpenGlReadbackFormat {
|
||||
[[nodiscard]] std::uint32_t linear_mipmap_linear_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t nearest_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t repeat_texture_wrap() noexcept;
|
||||
[[nodiscard]] std::uint32_t clamp_to_edge_texture_wrap() noexcept;
|
||||
[[nodiscard]] std::uint32_t active_texture_unit(std::uint32_t unit_index) noexcept;
|
||||
[[nodiscard]] std::uint32_t texture_cube_map_target() noexcept;
|
||||
[[nodiscard]] std::uint32_t cube_map_allocation_face_texture_target(std::uint32_t face_index) noexcept;
|
||||
|
||||
18
src/rtt.cpp
18
src/rtt.cpp
@@ -236,6 +236,24 @@ RTT RTT::clone() const noexcept
|
||||
return dup;
|
||||
}
|
||||
|
||||
bool RTT::create(int width, int height)
|
||||
{
|
||||
return create(
|
||||
width,
|
||||
height,
|
||||
-1,
|
||||
static_cast<GLint>(pp::renderer::gl::rgba8_internal_format()));
|
||||
}
|
||||
|
||||
bool RTT::create(int width, int height, int tex)
|
||||
{
|
||||
return create(
|
||||
width,
|
||||
height,
|
||||
tex,
|
||||
static_cast<GLint>(pp::renderer::gl::rgba8_internal_format()));
|
||||
}
|
||||
|
||||
bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format, bool depth_buffer /*= false*/)
|
||||
{
|
||||
GLenum status = 0;
|
||||
|
||||
@@ -61,7 +61,9 @@ public:
|
||||
void copy(const RTT& source, const glm::vec4& rect);
|
||||
RTT clone() const noexcept;
|
||||
bool resize(int width, int height);
|
||||
bool create(int width, int height, int tex = -1, GLint internal_format = GL_RGBA8, bool depth_buffer = false);
|
||||
bool create(int width, int height);
|
||||
bool create(int width, int height, int tex);
|
||||
bool create(int width, int height, int tex, GLint internal_format, bool depth_buffer = false);
|
||||
bool recreate() { return create(w, h); }
|
||||
void clear(glm::vec4 color = glm::vec4(0));
|
||||
void clear_mask(glm::bool4 mask, glm::vec4 color = glm::vec4(0));
|
||||
|
||||
@@ -126,11 +126,22 @@ bool TextureManager::load(const char* path, bool generate_mipmaps)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextureManager::assign(uint16_t id, GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint internal_format/* = GL_RGBA8*/, GLuint format/* = GL_RGBA*/)
|
||||
void TextureManager::assign(uint16_t id, GLuint tex, int w, int h, GLuint internal_format, GLuint format)
|
||||
{
|
||||
m_textures[id].assign(tex, w, h, internal_format, format);
|
||||
}
|
||||
|
||||
void TextureManager::assign(uint16_t id, GLuint tex, int w, int h)
|
||||
{
|
||||
assign(
|
||||
id,
|
||||
tex,
|
||||
w,
|
||||
h,
|
||||
pp::renderer::gl::rgba8_internal_format(),
|
||||
pp::renderer::gl::rgba_pixel_format());
|
||||
}
|
||||
|
||||
Texture2D& TextureManager::get(uint16_t id)
|
||||
{
|
||||
return m_textures[id];
|
||||
@@ -215,6 +226,24 @@ void Texture2D::operator=(Texture2D&& other) noexcept
|
||||
other.m_tex = false;
|
||||
}
|
||||
|
||||
bool Texture2D::create(int width, int height)
|
||||
{
|
||||
return create(
|
||||
width,
|
||||
height,
|
||||
static_cast<GLint>(pp::renderer::gl::rgba8_internal_format()),
|
||||
static_cast<GLint>(pp::renderer::gl::rgba_pixel_format()));
|
||||
}
|
||||
|
||||
bool Texture2D::create(int width, int height, GLint internal_format)
|
||||
{
|
||||
return create(
|
||||
width,
|
||||
height,
|
||||
internal_format,
|
||||
static_cast<GLint>(pp::renderer::gl::rgba_pixel_format()));
|
||||
}
|
||||
|
||||
bool Texture2D::create(int width, int height, GLint internal_format, GLint format, const uint8_t* data)
|
||||
{
|
||||
App::I->render_task([=]
|
||||
@@ -259,7 +288,7 @@ void Texture2D::create_mipmaps()
|
||||
});
|
||||
}
|
||||
|
||||
void Texture2D::assign(GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint internal_format/* = GL_RGBA8*/, GLuint format/* = GL_RGBA*/)
|
||||
void Texture2D::assign(GLuint tex, int w, int h, GLuint internal_format, GLuint format)
|
||||
{
|
||||
m_tex = tex;
|
||||
m_width = w;
|
||||
@@ -268,6 +297,16 @@ void Texture2D::assign(GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint intern
|
||||
m_iformat = internal_format;
|
||||
}
|
||||
|
||||
void Texture2D::assign(GLuint tex, int w, int h)
|
||||
{
|
||||
assign(
|
||||
tex,
|
||||
w,
|
||||
h,
|
||||
pp::renderer::gl::rgba8_internal_format(),
|
||||
pp::renderer::gl::rgba_pixel_format());
|
||||
}
|
||||
|
||||
bool Texture2D::load(std::string filename)
|
||||
{
|
||||
LOG("load texture %s", filename.c_str());
|
||||
@@ -338,7 +377,7 @@ Texture2D::~Texture2D()
|
||||
destroy();
|
||||
}
|
||||
|
||||
bool Sampler::create(GLint filter /*= GL_LINEAR*/, GLint wrap /*= GL_CLAMP_TO_EDGE*/)
|
||||
bool Sampler::create(GLint filter, GLint wrap)
|
||||
{
|
||||
bool ret = false;
|
||||
App::I->render_task([this, &ret, filter, wrap]
|
||||
@@ -356,7 +395,20 @@ bool Sampler::create(GLint filter /*= GL_LINEAR*/, GLint wrap /*= GL_CLAMP_TO_ED
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
void Sampler::set(GLint filter /*= GL_LINEAR*/, GLint wrap /*= GL_CLAMP_TO_EDGE*/)
|
||||
|
||||
bool Sampler::create()
|
||||
{
|
||||
return create(
|
||||
static_cast<GLint>(pp::renderer::gl::linear_texture_filter()),
|
||||
static_cast<GLint>(pp::renderer::gl::clamp_to_edge_texture_wrap()));
|
||||
}
|
||||
|
||||
bool Sampler::create(GLint filter)
|
||||
{
|
||||
return create(filter, static_cast<GLint>(pp::renderer::gl::clamp_to_edge_texture_wrap()));
|
||||
}
|
||||
|
||||
void Sampler::set(GLint filter, GLint wrap)
|
||||
{
|
||||
App::I->render_task([=]
|
||||
{
|
||||
@@ -370,6 +422,19 @@ void Sampler::set(GLint filter /*= GL_LINEAR*/, GLint wrap /*= GL_CLAMP_TO_EDGE*
|
||||
#endif // USE_SAMPLER
|
||||
});
|
||||
}
|
||||
|
||||
void Sampler::set()
|
||||
{
|
||||
set(
|
||||
static_cast<GLint>(pp::renderer::gl::linear_texture_filter()),
|
||||
static_cast<GLint>(pp::renderer::gl::clamp_to_edge_texture_wrap()));
|
||||
}
|
||||
|
||||
void Sampler::set(GLint filter)
|
||||
{
|
||||
set(filter, static_cast<GLint>(pp::renderer::gl::clamp_to_edge_texture_wrap()));
|
||||
}
|
||||
|
||||
void Sampler::set_filter(GLint filter_min, GLint filter_mag)
|
||||
{
|
||||
App::I->render_task([=]
|
||||
|
||||
@@ -17,9 +17,12 @@ public:
|
||||
~Texture2D();
|
||||
|
||||
bool has_mips = false;
|
||||
bool create(int width, int height, GLint internal_format = GL_RGBA8, GLint format = GL_RGBA, const uint8_t* data = nullptr);
|
||||
bool create(int width, int height);
|
||||
bool create(int width, int height, GLint internal_format);
|
||||
bool create(int width, int height, GLint internal_format, GLint format, const uint8_t* data = nullptr);
|
||||
bool create(const Image& img);
|
||||
void assign(GLuint tex, int w = -1, int h = -1, GLuint internal_format = GL_RGBA8, GLuint format = GL_RGBA);
|
||||
void assign(GLuint tex, int w = -1, int h = -1);
|
||||
void assign(GLuint tex, int w, int h, GLuint internal_format, GLuint format);
|
||||
bool load(std::string filename);
|
||||
bool load_file(std::string filename);
|
||||
void destroy();
|
||||
@@ -57,8 +60,12 @@ class Sampler
|
||||
GLuint id = 0;
|
||||
mutable GLint current_unit = 0;
|
||||
public:
|
||||
bool create(GLint filter = GL_LINEAR, GLint wrap = GL_CLAMP_TO_EDGE);
|
||||
void set(GLint filter = GL_LINEAR, GLint wrap = GL_CLAMP_TO_EDGE);
|
||||
bool create();
|
||||
bool create(GLint filter);
|
||||
bool create(GLint filter, GLint wrap);
|
||||
void set();
|
||||
void set(GLint filter);
|
||||
void set(GLint filter, GLint wrap);
|
||||
void set_filter(GLint filter_min, GLint filter_mag);
|
||||
void set_border(glm::vec4 rgba);
|
||||
void bind(int unit) const;
|
||||
@@ -71,7 +78,8 @@ class TextureManager
|
||||
public:
|
||||
static std::map<uint16_t, Texture2D> m_textures;
|
||||
static bool load(const char* path, bool generate_mipmpas = false);
|
||||
static void assign(uint16_t id, GLuint tex, int w = -1, int h = -1, GLuint internal_format = GL_RGBA8, GLuint format = GL_RGBA);
|
||||
static void assign(uint16_t id, GLuint tex, int w = -1, int h = -1);
|
||||
static void assign(uint16_t id, GLuint tex, int w, int h, GLuint internal_format, GLuint format);
|
||||
static Texture2D& get(uint16_t id);
|
||||
static void invalidate();
|
||||
};
|
||||
|
||||
@@ -358,6 +358,7 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, pp::renderer::gl::linear_mipmap_linear_texture_filter() == 0x2703U);
|
||||
PP_EXPECT(h, pp::renderer::gl::nearest_texture_filter() == 0x2600U);
|
||||
PP_EXPECT(h, pp::renderer::gl::repeat_texture_wrap() == 0x2901U);
|
||||
PP_EXPECT(h, pp::renderer::gl::clamp_to_edge_texture_wrap() == 0x812FU);
|
||||
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(0U) == 0x84C0U);
|
||||
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(4U) == 0x84C4U);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user