17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-02 23:16:22 +01:00

refactor(sonar): declare non-mutating member functions const (cpp:S5817)

Virtual functions are left untouched so overrides keep matching.
This commit is contained in:
jerrrrycho
2026-10-10 15:26:48 +02:00
parent 01d2b9bf82
commit 8042953b95
82 changed files with 221 additions and 221 deletions

View File

@@ -22,7 +22,7 @@ GLenum gl::buffer::glenum_target(gl::buffer::targets target)
return mapping[target];
}
void gl::buffer::bind(targets target)
void gl::buffer::bind(targets target) const
{
if (binding_points[target] == *this)
return;
@@ -31,7 +31,7 @@ void gl::buffer::bind(targets target)
binding_points[target] = *this;
}
void gl::buffer::bind_base(targets target, GLuint index)
void gl::buffer::bind_base(targets target, GLuint index) const
{
glBindBufferBase(glenum_target(target), index, *this);
binding_points[target] = *this;

View File

@@ -34,8 +34,8 @@ namespace gl
buffer();
~buffer();
void bind(targets target);
void bind_base(targets target, GLuint index);
void bind(targets target) const;
void bind_base(targets target, GLuint index) const;
static void unbind(targets target);
static void unbind();

View File

@@ -15,7 +15,7 @@ gl::cubemap::~cubemap()
glDeleteTextures(1, *this);
}
void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type)
void gl::cubemap::alloc(GLint format, int width, int height, GLenum components, GLenum type) const
{
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
for (GLuint tgt = GL_TEXTURE_CUBE_MAP_POSITIVE_X; tgt <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; tgt++)
@@ -29,13 +29,13 @@ void gl::cubemap::alloc(GLint format, int width, int height, GLenum components,
glBindTexture(GL_TEXTURE_CUBE_MAP, 0);
}
void gl::cubemap::bind(int unit)
void gl::cubemap::bind(int unit) const
{
glActiveTexture(unit);
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
}
void gl::cubemap::generate_mipmaps()
void gl::cubemap::generate_mipmaps() const
{
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
glGenerateMipmap(GL_TEXTURE_CUBE_MAP);

View File

@@ -12,8 +12,8 @@ namespace gl
cubemap();
~cubemap();
void alloc(GLint format, int width, int height, GLenum components, GLenum type);
void bind(int unit);
void generate_mipmaps();
void alloc(GLint format, int width, int height, GLenum components, GLenum type) const;
void bind(int unit) const;
void generate_mipmaps() const;
};
}

View File

@@ -49,7 +49,7 @@ std::optional<int64_t> gl::query::result()
return std::nullopt;
}
GLenum gl::query::glenum_target(targets target)
GLenum gl::query::glenum_target(targets target) const
{
static GLenum mapping[6] =
{

View File

@@ -22,7 +22,7 @@ private:
thread_local static query* active_queries[6];
protected:
GLenum glenum_target(targets target);
GLenum glenum_target(targets target) const;
public:
query(targets target);

View File

@@ -52,7 +52,7 @@ bool has_gl_extension(char const *name) {
} // anonymous namespace
std::string gl::shader::read_file(const std::string &filename)
std::string gl::shader::read_file(const std::string &filename) const
{
std::stringstream stream;
std::ifstream f;
@@ -299,7 +299,7 @@ void gl::shader::parse_param_entries(std::string &str)
}
}
void gl::shader::log_error(const std::string &str)
void gl::shader::log_error(const std::string &str) const
{
ErrorLog("bad shader: " + name + ": " + str, logtype::shader);
}

View File

@@ -73,12 +73,12 @@ namespace gl
void parse_texture_entries(std::string &str);
void parse_param_entries(std::string &str);
std::string read_file(const std::string &filename);
std::string read_file(const std::string &filename) const;
static std::unordered_map<std::string, components_e> components_mapping;
static std::unordered_map<std::string, defaultparam_e> defaultparams_mapping;
void log_error(const std::string &str);
void log_error(const std::string &str) const;
};
class program : public object, public bindable<program>