diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-08 16:02:56 +0000 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-08 16:02:56 +0000 |
| commit | 00fc3cb9b2c06026fab0e4760609fe02e027b6df (patch) | |
| tree | b84b527824ac1d5c999fc4a974fcf2c356b422ab /ui | |
| parent | Replace gl_traits glTexParameter with glTexture::parameter DSA wrapper (diff) | |
| download | ilt-00fc3cb9b2c06026fab0e4760609fe02e027b6df.tar.bz2 ilt-00fc3cb9b2c06026fab0e4760609fe02e027b6df.tar.xz ilt-00fc3cb9b2c06026fab0e4760609fe02e027b6df.zip | |
Move all low level texture operations to DSA helpers in glTexture
Diffstat (limited to 'ui')
| -rw-r--r-- | ui/editNetwork.cpp | 2 | ||||
| -rw-r--r-- | ui/font.cpp | 8 | ||||
| -rw-r--r-- | ui/font.h | 2 | ||||
| -rw-r--r-- | ui/icon.cpp | 6 | ||||
| -rw-r--r-- | ui/icon.h | 2 | ||||
| -rw-r--r-- | ui/svgIcon.cpp | 7 | ||||
| -rw-r--r-- | ui/svgIcon.h | 2 |
7 files changed, 11 insertions, 18 deletions
diff --git a/ui/editNetwork.cpp b/ui/editNetwork.cpp index 6ee0210..0215468 100644 --- a/ui/editNetwork.cpp +++ b/ui/editNetwork.cpp @@ -41,7 +41,7 @@ void EditNetwork::render(const SceneShader & shader, const Frustum & frustum) const { if (builder) { - blue.bind(); + blue.bind(0); shader.absolute.use(); builder->render(shader, frustum); } diff --git a/ui/font.cpp b/ui/font.cpp index b028c52..9c3d770 100644 --- a/ui/font.cpp +++ b/ui/font.cpp @@ -92,8 +92,7 @@ Font::generateChars(const utf8_string_view chars) const const auto textureIdx = getTextureWithSpace(glyph->bitmap.width); auto & texture = fontTextures[textureIdx]; - glTexSubImage2D(GL_TEXTURE_2D, 0, static_cast<GLint>(texture.used), 0, - static_cast<GLsizei>(glyph->bitmap.width), static_cast<GLsizei>(glyph->bitmap.rows), GL_RED, + texture.texture.subImage({texture.used, 0}, {glyph->bitmap.width, glyph->bitmap.rows}, GL_RED, GL_UNSIGNED_BYTE, glyph->bitmap.buffer); const auto & cd = charsData @@ -115,14 +114,11 @@ Font::getTextureWithSpace(unsigned int adv) const return (ft.used + adv) < size.x; }); itr != fontTextures.end()) { - itr->texture.bind(); return static_cast<std::size_t>(itr - fontTextures.begin()); } auto & texture = fontTextures.emplace_back(); - texture.texture.bind(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, static_cast<GLsizei>(size.x), static_cast<GLsizei>(size.y), 0, GL_RED, - GL_UNSIGNED_BYTE, nullptr); + texture.texture.storage(1, GL_R8, size); texture.texture.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); texture.texture.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); texture.texture.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); @@ -28,7 +28,7 @@ public: }; struct FontTexture { - glTexture texture; + glTexture<GL_TEXTURE_2D> texture; unsigned int used; }; diff --git a/ui/icon.cpp b/ui/icon.cpp index 5ab9c64..e0399e5 100644 --- a/ui/icon.cpp +++ b/ui/icon.cpp @@ -10,14 +10,12 @@ Icon::Icon(const std::filesystem::path & fileName) : Icon {Image {Resource::mapP Icon::Icon(const Image & tex) : size {tex.width, tex.height} { - m_texture.bind(); - + m_texture.storage(1, GL_RGBA8, size); m_texture.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); m_texture.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); m_texture.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); m_texture.parameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(tex.width), static_cast<GLsizei>(tex.height), 0, - GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data()); + m_texture.image(size, GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data()); } ImTextureID @@ -16,5 +16,5 @@ public: ImTextureID operator*() const; private: - glTexture m_texture; + glTexture<GL_TEXTURE_2D> m_texture; }; diff --git a/ui/svgIcon.cpp b/ui/svgIcon.cpp index 82ef69d..2c73b5d 100644 --- a/ui/svgIcon.cpp +++ b/ui/svgIcon.cpp @@ -14,19 +14,18 @@ SvgIcon::SvgIcon(ImageDimensions dim, const std::filesystem::path & path) } bitmap.convertToRGBA(); - texture.bind(); - + texture.storage(1, GL_RGBA8, dim); texture.parameter(GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); texture.parameter(GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); texture.parameter(GL_TEXTURE_MIN_FILTER, GL_LINEAR); texture.parameter(GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, dim.x, dim.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, bitmap.data()); + texture.image(dim, GL_RGBA, GL_UNSIGNED_BYTE, bitmap.data()); } ImTextureID SvgIcon::operator*() const { - static_assert(sizeof(glTexture) <= sizeof(ImTextureID)); + static_assert(sizeof(glTexture<GL_TEXTURE_2D>) <= sizeof(ImTextureID)); // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast,performance-no-int-to-ptr) This is how ImGui works return reinterpret_cast<ImTextureID>(*texture); } diff --git a/ui/svgIcon.h b/ui/svgIcon.h index be01446..8009891 100644 --- a/ui/svgIcon.h +++ b/ui/svgIcon.h @@ -14,5 +14,5 @@ public: private: friend class LoadFromFile; // Test case verifying size/content - glTexture texture; + glTexture<GL_TEXTURE_2D> texture; }; |
