From b877c737bc5f759e6da25f886ad965e4a274cf2a Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 26 Sep 2021 14:22:26 +0300 Subject: [PATCH] Remove the misc.h header It was mostly unused already. --- source/core/clipplane.cpp | 1 - source/core/framebuffer.cpp | 1 - source/core/misc.cpp | 47 ----------------------------------- source/core/misc.h | 20 --------------- source/core/program.cpp | 25 ++++++++++++------- source/core/vertexsetup.cpp | 1 - source/effects/bloom.cpp | 1 - source/glsl/features.cpp | 7 +++--- source/materials/light.cpp | 1 - source/materials/lighting.cpp | 1 - 10 files changed, 20 insertions(+), 85 deletions(-) delete mode 100644 source/core/misc.cpp delete mode 100644 source/core/misc.h diff --git a/source/core/clipplane.cpp b/source/core/clipplane.cpp index b27464ca..3e0d5f66 100644 --- a/source/core/clipplane.cpp +++ b/source/core/clipplane.cpp @@ -2,7 +2,6 @@ #include "clipplane.h" #include "gl.h" #include "matrix.h" -#include "misc.h" #include "programdata.h" namespace Msp { diff --git a/source/core/framebuffer.cpp b/source/core/framebuffer.cpp index 01a41074..57655205 100644 --- a/source/core/framebuffer.cpp +++ b/source/core/framebuffer.cpp @@ -10,7 +10,6 @@ #include #include "error.h" #include "framebuffer.h" -#include "misc.h" #include "texture2d.h" #include "texture2dmultisample.h" #include "texture3d.h" diff --git a/source/core/misc.cpp b/source/core/misc.cpp deleted file mode 100644 index 39810be3..00000000 --- a/source/core/misc.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include "misc.h" - -namespace Msp { -namespace GL { - -void enable(GLenum state) -{ - glEnable(state); -} - -void disable(GLenum state) -{ - glDisable(state); -} - -void set(GLenum state, bool value) -{ - if(value) - enable(state); - else - disable(state); -} - -int get_i(GLenum state) -{ - int data; - glGetIntegerv(state, &data); - return data; -} - -int get_shader_i(unsigned id, GLenum state) -{ - int data; - glGetShaderiv(id, state, &data); - return data; -} - -int get_program_i(unsigned id, GLenum state) -{ - int data; - glGetProgramiv(id, state, &data); - return data; -} - -} // namespace GL -} // namespace Msp diff --git a/source/core/misc.h b/source/core/misc.h deleted file mode 100644 index 32adc9bf..00000000 --- a/source/core/misc.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef MSP_GL_MISC_H_ -#define MSP_GL_MISC_H_ - -#include "gl.h" - -namespace Msp { -namespace GL { - -void enable(GLenum); -void disable(GLenum); -void set(GLenum, bool); - -int get_i(GLenum); -int get_shader_i(unsigned, GLenum); -int get_program_i(unsigned, GLenum); - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/core/program.cpp b/source/core/program.cpp index 9ed1e634..8bec2f6f 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -19,7 +19,6 @@ #include #include "buffer.h" #include "error.h" -#include "misc.h" #include "program.h" #include "resources.h" #include "glsl/compiler.h" @@ -162,16 +161,18 @@ void Program::add_glsl_stages(const GlslModule &mod, const map &spe void Program::compile_glsl_stage(unsigned stage_id) { glCompileShader(stage_id); - bool compiled = get_shader_i(stage_id, GL_COMPILE_STATUS); + int status = 0; + glGetShaderiv(stage_id, GL_COMPILE_STATUS, &status); - GLsizei info_log_len = get_shader_i(stage_id, GL_INFO_LOG_LENGTH); + int info_log_len = 0; + glGetShaderiv(stage_id, GL_INFO_LOG_LENGTH, &info_log_len); string info_log(info_log_len+1, 0); glGetShaderInfoLog(stage_id, info_log_len+1, &info_log_len, &info_log[0]); info_log.erase(info_log_len); if(module && module->get_format()==Module::GLSL) info_log = static_cast(module)->get_source_map().translate_errors(info_log); - if(!compiled) + if(!status) throw compile_error(info_log); #ifdef DEBUG if(!info_log.empty()) @@ -240,9 +241,12 @@ void Program::link() attributes.clear(); glLinkProgram(id); - linked = get_program_i(id, GL_LINK_STATUS); + int status = 0; + glGetProgramiv(id, GL_LINK_STATUS, &status); + linked = status; - GLsizei info_log_len = get_program_i(id, GL_INFO_LOG_LENGTH); + int info_log_len = 0; + glGetProgramiv(id, GL_INFO_LOG_LENGTH, &info_log_len); string info_log(info_log_len+1, 0); glGetProgramInfoLog(id, info_log_len+1, &info_log_len, &info_log[0]); info_log.erase(info_log_len); @@ -304,7 +308,8 @@ void Program::link() void Program::query_uniforms() { - unsigned count = get_program_i(id, GL_ACTIVE_UNIFORMS); + unsigned count = 0; + glGetProgramiv(id, GL_ACTIVE_UNIFORMS, reinterpret_cast(&count)); uniforms.reserve(count); vector uniform_names(count); for(unsigned i=0; i &uniforms_by_index) { - unsigned count = get_program_i(id, GL_ACTIVE_UNIFORM_BLOCKS); + unsigned count = 0; + glGetProgramiv(id, GL_ACTIVE_UNIFORM_BLOCKS, reinterpret_cast(&count)); // Reserve an extra index for the default block uniform_blocks.reserve(count+1); for(unsigned i=0; i &uniforms_by_inde void Program::query_attributes() { - unsigned count = get_program_i(id, GL_ACTIVE_ATTRIBUTES); + unsigned count = 0; + glGetProgramiv(id, GL_ACTIVE_ATTRIBUTES, reinterpret_cast(&count)); attributes.reserve(count); for(unsigned i=0; i #include "blend.h" #include "bloom.h" -#include "misc.h" #include "renderer.h" #include "resources.h" diff --git a/source/glsl/features.cpp b/source/glsl/features.cpp index 0b5b438b..db213e83 100644 --- a/source/glsl/features.cpp +++ b/source/glsl/features.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -6,7 +7,6 @@ #include #include #include -#include #include "features.h" namespace Msp { @@ -41,8 +41,9 @@ Features Features::from_context() features.arb_uniform_buffer_object = ARB_uniform_buffer_object; features.ext_gpu_shader4 = EXT_gpu_shader4; features.ext_texture_array = EXT_texture_array; - features.uniform_binding_range = get_i(GL_MAX_UNIFORM_BUFFER_BINDINGS); - features.texture_binding_range = get_i(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS); + const Limits &limits = Limits::get_global(); + features.uniform_binding_range = limits.max_uniform_bindings; + features.texture_binding_range = limits.max_texture_bindings; return features; } diff --git a/source/materials/light.cpp b/source/materials/light.cpp index 3d3cba0a..e8cbbaac 100644 --- a/source/materials/light.cpp +++ b/source/materials/light.cpp @@ -2,7 +2,6 @@ #include #include "light.h" #include "matrix.h" -#include "misc.h" #include "programdata.h" using namespace std; diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 91bc4d06..721d5cdc 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -6,7 +6,6 @@ #include "light.h" #include "lighting.h" #include "matrix.h" -#include "misc.h" using namespace std; -- 2.43.0