diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-25 23:19:03 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-01-25 23:19:03 +0000 |
commit | e98fdea344f173c59b11549432b20114081a58b1 (patch) | |
tree | 5bd05eb297bb90f5cdd38a77e05ebf86106ec93a /gfx | |
parent | Replace static_asserts with concepts (diff) | |
download | ilt-e98fdea344f173c59b11549432b20114081a58b1.tar.bz2 ilt-e98fdea344f173c59b11549432b20114081a58b1.tar.xz ilt-e98fdea344f173c59b11549432b20114081a58b1.zip |
Add traits helpers for glTexParameter functions
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gl/sceneRenderer.cpp | 4 | ||||
-rw-r--r-- | gfx/gl/shadowMapper.cpp | 10 | ||||
-rw-r--r-- | gfx/models/texture.cpp | 17 |
3 files changed, 16 insertions, 15 deletions
diff --git a/gfx/gl/sceneRenderer.cpp b/gfx/gl/sceneRenderer.cpp index 4ae4297..4c96902 100644 --- a/gfx/gl/sceneRenderer.cpp +++ b/gfx/gl/sceneRenderer.cpp @@ -24,8 +24,8 @@ SceneRenderer::SceneRenderer(ScreenAbsCoord s, GLuint o) : const auto configuregdata = [this](const GLuint data, const std::initializer_list<GLint> iformats, const GLenum format, const GLenum attachment) { glBindTexture(GL_TEXTURE_2D, data); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_2D, 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 ae374fe..ab4ac50 100644 --- a/gfx/gl/shadowMapper.cpp +++ b/gfx/gl/shadowMapper.cpp @@ -21,12 +21,12 @@ ShadowMapper::ShadowMapper(const TextureAbsCoord & s) : { glBindTexture(GL_TEXTURE_2D, depthMap); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, size.x, size.y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); static constexpr RGBA border {std::numeric_limits<RGBA::value_type>::infinity()}; - glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, glm::value_ptr(border)); + glTexParameter(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border); glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0); diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index 35f8d35..0ebba08 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -6,6 +6,7 @@ #include <fcntl.h> #include <filesystem.h> #include <gfx/image.h> +#include <gl_traits.h> #include <glad/gl.h> #include <glm/geometric.hpp> #include <resource.h> @@ -46,11 +47,11 @@ Texture::Texture(GLsizei width, GLsizei height, const void * data, TextureOption glBindTexture(type, m_texture); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glTexParameteri(type, GL_TEXTURE_WRAP_S, TextureOptions::glMapMode(to.wrapU)); - glTexParameteri(type, GL_TEXTURE_WRAP_T, TextureOptions::glMapMode(to.wrapV)); + glTexParameter(type, GL_TEXTURE_WRAP_S, TextureOptions::glMapMode(to.wrapU)); + glTexParameter(type, GL_TEXTURE_WRAP_T, TextureOptions::glMapMode(to.wrapV)); - glTexParameteri(type, GL_TEXTURE_MIN_FILTER, to.minFilter); - glTexParameteri(type, GL_TEXTURE_MAG_FILTER, to.magFilter); + glTexParameter(type, GL_TEXTURE_MIN_FILTER, to.minFilter); + glTexParameter(type, GL_TEXTURE_MAG_FILTER, to.magFilter); glTexImage2D(type, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); } @@ -125,11 +126,11 @@ TextureAtlas::TextureAtlas(GLsizei width, GLsizei height, GLuint count) : Textur { glBindTexture(GL_TEXTURE_RECTANGLE, m_atlas); - glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameter(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameter(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameter(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA16UI, 2, static_cast<GLsizei>(count), 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, nullptr); } |