mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 14:49:19 +02:00
reformat: parameters can be made const
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "buffer.h"
|
||||
|
||||
GLenum gl::buffer::glenum_target(targets target)
|
||||
GLenum gl::buffer::glenum_target(const targets target)
|
||||
{
|
||||
static GLenum mapping[13] =
|
||||
{
|
||||
@@ -22,7 +22,7 @@ GLenum gl::buffer::glenum_target(targets target)
|
||||
return mapping[target];
|
||||
}
|
||||
|
||||
void gl::buffer::bind(targets target)
|
||||
void gl::buffer::bind(const targets target)
|
||||
{
|
||||
if (binding_points[target] == *this)
|
||||
return;
|
||||
@@ -31,13 +31,13 @@ void gl::buffer::bind(targets target)
|
||||
binding_points[target] = *this;
|
||||
}
|
||||
|
||||
void gl::buffer::bind_base(targets target, GLuint index)
|
||||
void gl::buffer::bind_base(const targets target, const GLuint index)
|
||||
{
|
||||
glBindBufferBase(glenum_target(target), index, *this);
|
||||
binding_points[target] = *this;
|
||||
}
|
||||
|
||||
void gl::buffer::unbind(targets target)
|
||||
void gl::buffer::unbind(const targets target)
|
||||
{
|
||||
if( binding_points[ target ] == 0 ) { return; }
|
||||
|
||||
@@ -61,19 +61,19 @@ gl::buffer::~buffer()
|
||||
glDeleteBuffers(1, *this);
|
||||
}
|
||||
|
||||
void gl::buffer::allocate(targets target, GLsizeiptr size, GLenum hint)
|
||||
void gl::buffer::allocate(const targets target, const GLsizeiptr size, const GLenum hint)
|
||||
{
|
||||
bind(target);
|
||||
glBufferData(glenum_target(target), size, nullptr, hint);
|
||||
}
|
||||
|
||||
void gl::buffer::upload(targets target, const void *data, int offset, GLsizeiptr size)
|
||||
void gl::buffer::upload(const targets target, const void *data, const int offset, const GLsizeiptr size)
|
||||
{
|
||||
bind(target);
|
||||
glBufferSubData(glenum_target(target), offset, size, data);
|
||||
}
|
||||
|
||||
void gl::buffer::download(targets target, void *data, int offset, GLsizeiptr size)
|
||||
void gl::buffer::download(const targets target, void *data, const int offset, const GLsizeiptr size)
|
||||
{
|
||||
bind(target);
|
||||
if (GLAD_GL_VERSION_3_3)
|
||||
|
||||
@@ -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(const GLint format, const int width, const int height, const GLenum components, const GLenum type)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
|
||||
for (GLuint tgt = GL_TEXTURE_CUBE_MAP_POSITIVE_X; tgt <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z; tgt++)
|
||||
@@ -29,7 +29,7 @@ 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(const int unit)
|
||||
{
|
||||
glActiveTexture(unit);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, *this);
|
||||
|
||||
@@ -14,36 +14,36 @@ gl::framebuffer::~framebuffer()
|
||||
glDeleteFramebuffers(1, *this);
|
||||
}
|
||||
|
||||
void gl::framebuffer::bind(GLuint id)
|
||||
void gl::framebuffer::bind(const GLuint id)
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, id);
|
||||
}
|
||||
|
||||
void gl::framebuffer::attach(const opengl_texture &tex, GLenum location)
|
||||
void gl::framebuffer::attach(const opengl_texture &tex, const GLenum location)
|
||||
{
|
||||
bind();
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, location, tex.target, tex.id, 0);
|
||||
}
|
||||
|
||||
void gl::framebuffer::attach(const opengl_texture &tex, GLenum location, GLint layer)
|
||||
void gl::framebuffer::attach(const opengl_texture &tex, const GLenum location, const GLint layer)
|
||||
{
|
||||
bind();
|
||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, location, tex.id, 0, layer);
|
||||
}
|
||||
|
||||
void gl::framebuffer::attach(const cubemap &tex, int face, GLenum location)
|
||||
void gl::framebuffer::attach(const cubemap &tex, const int face, const GLenum location)
|
||||
{
|
||||
bind();
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, location, GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, *tex, 0);
|
||||
}
|
||||
|
||||
void gl::framebuffer::attach(const renderbuffer &rb, GLenum location)
|
||||
void gl::framebuffer::attach(const renderbuffer &rb, const GLenum location)
|
||||
{
|
||||
bind();
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, location, GL_RENDERBUFFER, *rb);
|
||||
}
|
||||
|
||||
void gl::framebuffer::detach(GLenum location)
|
||||
void gl::framebuffer::detach(const GLenum location)
|
||||
{
|
||||
bind();
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, location, GL_RENDERBUFFER, 0);
|
||||
@@ -62,7 +62,7 @@ bool gl::framebuffer::is_complete()
|
||||
return iscomplete;
|
||||
}
|
||||
|
||||
void gl::framebuffer::clear(GLbitfield mask)
|
||||
void gl::framebuffer::clear(const GLbitfield mask)
|
||||
{
|
||||
bind();
|
||||
if (mask & GL_DEPTH_BUFFER_BIT)
|
||||
@@ -70,17 +70,17 @@ void gl::framebuffer::clear(GLbitfield mask)
|
||||
glClear(mask);
|
||||
}
|
||||
|
||||
void gl::framebuffer::blit_to(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment)
|
||||
void gl::framebuffer::blit_to(framebuffer *other, const int w, const int h, const GLbitfield mask, const GLenum attachment)
|
||||
{
|
||||
blit(this, other, 0, 0, w, h, mask, attachment);
|
||||
}
|
||||
|
||||
void gl::framebuffer::blit_from(framebuffer *other, int w, int h, GLbitfield mask, GLenum attachment)
|
||||
void gl::framebuffer::blit_from(framebuffer *other, const int w, const int h, const GLbitfield mask, const GLenum attachment)
|
||||
{
|
||||
blit(other, this, 0, 0, w, h, mask, attachment);
|
||||
}
|
||||
|
||||
void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, int sx, int sy, int w, int h, GLbitfield mask, GLenum attachment)
|
||||
void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, const int sx, const int sy, const int w, const int h, const GLbitfield mask, const GLenum attachment)
|
||||
{
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, src ? *src : 0);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst ? *dst : 0);
|
||||
@@ -108,7 +108,7 @@ void gl::framebuffer::blit(framebuffer *src, framebuffer *dst, int sx, int sy, i
|
||||
unbind();
|
||||
}
|
||||
|
||||
void gl::framebuffer::setup_drawing(int attachments)
|
||||
void gl::framebuffer::setup_drawing(const int attachments)
|
||||
{
|
||||
bind();
|
||||
const GLenum a[8] =
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "pbo.h"
|
||||
|
||||
void gl::pbo::request_read(int x, int y, int lx, int ly, int pixsize, GLenum format, GLenum type)
|
||||
void gl::pbo::request_read(const int x, const int y, const int lx, const int ly, const int pixsize, const GLenum format, const GLenum type)
|
||||
{
|
||||
const int s = lx * ly * pixsize;
|
||||
if (s != size)
|
||||
@@ -18,7 +18,7 @@ void gl::pbo::request_read(int x, int y, int lx, int ly, int pixsize, GLenum for
|
||||
sync.emplace();
|
||||
}
|
||||
|
||||
bool gl::pbo::read_data(int lx, int ly, void *data, int pixsize)
|
||||
bool gl::pbo::read_data(const int lx, const int ly, void *data, const int pixsize)
|
||||
{
|
||||
is_busy();
|
||||
|
||||
@@ -51,13 +51,13 @@ bool gl::pbo::is_busy()
|
||||
return true;
|
||||
}
|
||||
|
||||
void* gl::pbo::map(GLuint mode, targets target)
|
||||
void* gl::pbo::map(const GLuint mode, const targets target)
|
||||
{
|
||||
bind(target);
|
||||
return glMapBuffer(glenum_target(target), mode);
|
||||
}
|
||||
|
||||
void gl::pbo::unmap(targets target)
|
||||
void gl::pbo::unmap(const targets target)
|
||||
{
|
||||
bind(target);
|
||||
glUnmapBuffer(glenum_target(target));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "query.h"
|
||||
#include "utilities/Globals.h"
|
||||
|
||||
gl::query::query(targets target)
|
||||
gl::query::query(const targets target)
|
||||
: target(target)
|
||||
{
|
||||
glGenQueries(1, *this);
|
||||
@@ -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(const targets target)
|
||||
{
|
||||
static GLenum mapping[6] =
|
||||
{
|
||||
|
||||
@@ -12,12 +12,12 @@ gl::renderbuffer::~renderbuffer()
|
||||
glDeleteRenderbuffers(1, *this);
|
||||
}
|
||||
|
||||
void gl::renderbuffer::bind(GLuint id)
|
||||
void gl::renderbuffer::bind(const GLuint id)
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, id);
|
||||
}
|
||||
|
||||
void gl::renderbuffer::alloc(GLuint format, int width, int height, int samples)
|
||||
void gl::renderbuffer::alloc(const GLuint format, const int width, const int height, const int samples)
|
||||
{
|
||||
bind();
|
||||
if (samples == 1)
|
||||
|
||||
@@ -407,7 +407,7 @@ gl::program::~program()
|
||||
glDeleteProgram(*this);
|
||||
}
|
||||
|
||||
void gl::program::bind(GLuint i)
|
||||
void gl::program::bind(const GLuint i)
|
||||
{
|
||||
glUseProgram(i);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "stdafx.h"
|
||||
#include "ubo.h"
|
||||
|
||||
gl::ubo::ubo(size_t size, int idx, GLenum hint)
|
||||
gl::ubo::ubo(const size_t size, const int idx, const GLenum hint)
|
||||
{
|
||||
allocate(UNIFORM_BUFFER, size, hint);
|
||||
index = idx;
|
||||
@@ -13,7 +13,7 @@ void gl::ubo::bind_uniform()
|
||||
bind_base(UNIFORM_BUFFER, index);
|
||||
}
|
||||
|
||||
void gl::ubo::update(const uint8_t *data, int offset, GLsizeiptr size)
|
||||
void gl::ubo::update(const uint8_t *data, const int offset, const GLsizeiptr size)
|
||||
{
|
||||
upload(UNIFORM_BUFFER, data, offset, size);
|
||||
}
|
||||
|
||||
2
gl/ubo.h
2
gl/ubo.h
@@ -27,7 +27,7 @@ namespace gl
|
||||
void bind_uniform();
|
||||
|
||||
void update(const uint8_t *data, int offset, GLsizeiptr size);
|
||||
template <typename T> void update(const T &data, size_t offset = 0)
|
||||
template <typename T> void update(const T &data, const size_t offset = 0)
|
||||
{
|
||||
update(reinterpret_cast<const uint8_t*>(&data), offset, sizeof(data));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ gl::vao::~vao()
|
||||
glDeleteVertexArrays(1, *this);
|
||||
}
|
||||
|
||||
void gl::vao::setup_attrib(buffer &buffer, int attrib, int size, int type, int stride, int offset)
|
||||
void gl::vao::setup_attrib(buffer &buffer, const int attrib, const int size, const int type, const int stride, const int offset)
|
||||
{
|
||||
if (use_vao) {
|
||||
bind();
|
||||
|
||||
Reference in New Issue
Block a user