From fb16b42096b45f02a9b02bee38d5d3ead6d430b0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 7 Mar 2026 14:21:21 +0000 Subject: Replace gl_traits glTexParameter with glTexture::parameter DSA wrapper --- gfx/gl/billboardPainter.cpp | 11 +++++------ gfx/gl/glTexture.h | 15 +++++++++++++++ gfx/gl/sceneRenderer.cpp | 6 +++--- gfx/gl/shadowMapper.cpp | 10 +++++----- gfx/gl/shadowStenciller.cpp | 8 ++++---- 5 files changed, 32 insertions(+), 18 deletions(-) (limited to 'gfx/gl') diff --git a/gfx/gl/billboardPainter.cpp b/gfx/gl/billboardPainter.cpp index d021efb..3b03c87 100644 --- a/gfx/gl/billboardPainter.cpp +++ b/gfx/gl/billboardPainter.cpp @@ -1,5 +1,4 @@ #include "billboardPainter.h" -#include "gl_traits.h" #include "gldebug.h" #include "maths.h" #include @@ -44,12 +43,12 @@ BillboardPainter::configureBillBoardTextures(glTextures<3> & textures, GLsizei w glDebugScope _ {0}; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - const auto configuregdata = [width, height](const auto & texture, const GLint iformat, const GLenum format) { + const auto configuregdata = [width, height](Impl::glTexture & texture, const GLint iformat, const GLenum format) { texture.bind(GL_TEXTURE_2D_ARRAY); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + texture.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); + texture.parameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); + texture.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + texture.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, iformat, width, height, VIEW_ANGLES, 0, format, GL_BYTE, nullptr); }; configuregdata(textures[0], GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT); diff --git a/gfx/gl/glTexture.h b/gfx/gl/glTexture.h index c482198..5e5c838 100644 --- a/gfx/gl/glTexture.h +++ b/gfx/gl/glTexture.h @@ -2,12 +2,27 @@ #include "config/types.h" #include "glArrays.h" +#include "gl_traits.h" namespace Impl { // NOLINTNEXTLINE(readability-identifier-naming) struct glTexture : Detail::glNamed { [[nodiscard]] TextureDimensions getSize() const; void bind(GLenum type = GL_TEXTURE_2D, GLenum unit = GL_TEXTURE0) const; + + template + void + parameter(GLenum pname, T param) + { + (*gl_traits::glTextureParameterFunc)(name, pname, param); + } + + template + void + parameter(GLenum pname, const glm::vec & param) + { + (*gl_traits::glTextureParametervFunc)(name, pname, glm::value_ptr(param)); + } }; } diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index e67711b..d4812df 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -23,11 +23,11 @@ SceneRenderer::SceneRenderer(ScreenAbsCoord s, GLuint o, glDebugScope) : shader.setViewPort({0, 0, size.x, size.y}); displayVAO.configure().addAttribs(0, displayVBO, displayVAOdata); - const auto configuregdata = [this](const auto & data, const std::initializer_list iformats, + const auto configuregdata = [this](glTexture & data, const std::initializer_list iformats, const GLenum format, const GLenum attachment) { data.bind(); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + data.parameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST); + data.parameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST); for (const auto iformat : iformats) { glTexImage2D(GL_TEXTURE_2D, 0, iformat, size.x, size.y, 0, format, GL_BYTE, nullptr); diff --git a/gfx/gl/shadowMapper.cpp b/gfx/gl/shadowMapper.cpp index 03851f5..fb57668 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -35,12 +35,12 @@ ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : depthMap.bind(GL_TEXTURE_2D_ARRAY); glTexImage3D( GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT, size.x, size.y, 4, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + depthMap.parameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST); + depthMap.parameter(GL_TEXTURE_MAG_FILTER, GL_NEAREST); + depthMap.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + depthMap.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); static constexpr RGBA border {std::numeric_limits::infinity()}; - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, border); + depthMap.parameter(GL_TEXTURE_BORDER_COLOR, border); glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depthMap, 0); diff --git a/gfx/gl/shadowStenciller.cpp b/gfx/gl/shadowStenciller.cpp index 3625524..a5f9d68 100644 --- a/gfx/gl/shadowStenciller.cpp +++ b/gfx/gl/shadowStenciller.cpp @@ -42,10 +42,10 @@ ShadowStenciller::configureStencilTexture(glTexture & stencil, GLsizei width, GL stencil.bind(GL_TEXTURE_2D_ARRAY); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameter(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + stencil.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); + stencil.parameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); + stencil.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + stencil.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_DEPTH_COMPONENT, width, height, STENCIL_ANGLES, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, nullptr); -- cgit v1.3