summaryrefslogtreecommitdiffstats
path: root/game/client/texture_gui.cc
diff options
context:
space:
mode:
authoruntodesu <kirill@untode.su>2025-06-25 00:44:36 +0500
committeruntodesu <kirill@untode.su>2025-06-25 00:44:36 +0500
commit88c01588aa0830e219eaa62588839e4d1e2883ce (patch)
tree602bb27dd3399aab4aae8c19630e3b7a8dac824b /game/client/texture_gui.cc
parent99cf6cca8dbbc1e563c10cf0167432d3d8af9783 (diff)
downloadvoxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.tar.bz2
voxelius-88c01588aa0830e219eaa62588839e4d1e2883ce.zip
Clang-format the entire source code
Diffstat (limited to 'game/client/texture_gui.cc')
-rw-r--r--game/client/texture_gui.cc48
1 files changed, 32 insertions, 16 deletions
diff --git a/game/client/texture_gui.cc b/game/client/texture_gui.cc
index 9253986..265f6c2 100644
--- a/game/client/texture_gui.cc
+++ b/game/client/texture_gui.cc
@@ -1,4 +1,5 @@
#include "client/pch.hh"
+
#include "client/texture_gui.hh"
#include "core/image.hh"
@@ -7,7 +8,7 @@
static emhash8::HashMap<std::string, resource_ptr<TextureGUI>> resource_map;
template<>
-resource_ptr<TextureGUI> resource::load<TextureGUI>(const char *name, unsigned int flags)
+resource_ptr<TextureGUI> resource::load<TextureGUI>(const char* name, unsigned int flags)
{
auto it = resource_map.find(name);
@@ -16,10 +17,15 @@ resource_ptr<TextureGUI> resource::load<TextureGUI>(const char *name, unsigned i
return it->second;
}
-
unsigned int image_load_flags = 0U;
- if(flags & TEXTURE_GUI_LOAD_VFLIP) image_load_flags |= IMAGE_LOAD_FLIP;
- if(flags & TEXTURE_GUI_LOAD_GRAYSCALE) image_load_flags |= IMAGE_LOAD_GRAY;
+
+ if(flags & TEXTURE_GUI_LOAD_VFLIP) {
+ image_load_flags |= IMAGE_LOAD_FLIP;
+ }
+
+ if(flags & TEXTURE_GUI_LOAD_GRAYSCALE) {
+ image_load_flags |= IMAGE_LOAD_GRAY;
+ }
if(auto image = resource::load<Image>(name, image_load_flags)) {
GLuint gl_texture;
@@ -28,27 +34,35 @@ resource_ptr<TextureGUI> resource::load<TextureGUI>(const char *name, unsigned i
glBindTexture(GL_TEXTURE_2D, gl_texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image->size.x, image->size.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels);
- if(flags & TEXTURE_GUI_LOAD_CLAMP_S)
+ if(flags & TEXTURE_GUI_LOAD_CLAMP_S) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ }
- if(flags & TEXTURE_GUI_LOAD_CLAMP_T)
+ if(flags & TEXTURE_GUI_LOAD_CLAMP_T) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ }
- if(flags & TEXTURE_GUI_LOAD_LINEAR_MAG)
+ if(flags & TEXTURE_GUI_LOAD_LINEAR_MAG) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ }
- if(flags & TEXTURE_GUI_LOAD_LINEAR_MIN)
+ if(flags & TEXTURE_GUI_LOAD_LINEAR_MIN) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- else glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ } else {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
auto new_resource = std::make_shared<TextureGUI>();
new_resource->handle = static_cast<ImTextureID>(gl_texture);
new_resource->size.x = image->size.x;
new_resource->size.y = image->size.y;
-
+
return resource_map.insert_or_assign(name, new_resource).first->second;
}
@@ -58,10 +72,12 @@ resource_ptr<TextureGUI> resource::load<TextureGUI>(const char *name, unsigned i
template<>
void resource::hard_cleanup<TextureGUI>(void)
{
- for(const auto &it : resource_map) {
- if(it.second.use_count() > 1L)
+ for(const auto& it : resource_map) {
+ if(it.second.use_count() > 1L) {
spdlog::warn("resource: zombie resource [TextureGUI] {} [use_count={}]", it.first, it.second.use_count());
- else spdlog::debug("resource: releasing [TextureGUI] {}", it.first);
+ } else {
+ spdlog::debug("resource: releasing [TextureGUI] {}", it.first);
+ }
auto gl_texture = static_cast<GLuint>(it.second->handle);