From: Mikko Rasa Date: Sat, 18 Sep 2021 09:07:54 +0000 (+0300) Subject: Remove remaining deprecated things from the core classes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6065f6622cc275dc0b20baaf7c267e71169d18f3;p=libs%2Fgl.git Remove remaining deprecated things from the core classes --- diff --git a/source/core/batch.h b/source/core/batch.h index 51cc573b..6f7e43d6 100644 --- a/source/core/batch.h +++ b/source/core/batch.h @@ -49,9 +49,6 @@ public: DataType get_index_type() const { return index_type; } GLenum get_gl_index_type() const { return gl_index_type; } - DEPRECATED void set_data_type(DataType t) { set_index_type(t); } - DEPRECATED DataType get_data_type() const { return index_type; } - Batch &append(unsigned); Batch &append(const std::vector &); bool can_append(PrimitiveType); diff --git a/source/core/buffer.cpp b/source/core/buffer.cpp index 78e85af0..71ab6e23 100644 --- a/source/core/buffer.cpp +++ b/source/core/buffer.cpp @@ -2,13 +2,12 @@ #include #include #include +#include #include +#include #include #include "buffer.h" -#include "deviceinfo.h" #include "error.h" -#include "misc.h" -#include "vertexsetup.h" using namespace std; @@ -74,10 +73,6 @@ void Buffer::allocate() data(0); } -void Buffer::set_usage(BufferUsage) -{ -} - void Buffer::data(const void *d) { if(size==0) @@ -87,26 +82,16 @@ void Buffer::data(const void *d) return sub_data(0, size, d); if(ARB_direct_state_access) - glNamedBufferData(id, size, d, STATIC_DRAW); + glNamedBufferData(id, size, d, GL_STATIC_DRAW); else { bind_scratch(); - glBufferData(GL_ARRAY_BUFFER, size, d, STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, size, d, GL_STATIC_DRAW); } allocated = true; } -void Buffer::data(unsigned sz, const void *d) -{ - if(size==0) - storage(sz); - else if(sz!=size) - throw incompatible_data("Buffer::data"); - - data(d); -} - void Buffer::sub_data(unsigned off, unsigned sz, const void *d) { if(size==0) diff --git a/source/core/buffer.h b/source/core/buffer.h index ca9a5955..0d656131 100644 --- a/source/core/buffer.h +++ b/source/core/buffer.h @@ -4,12 +4,7 @@ #include #include #include -#include #include "gl.h" -#include -#include -#include -#include namespace Msp { namespace GL { @@ -21,26 +16,6 @@ public: virtual ~buffer_too_small() throw() { } }; -enum BufferUsage -{ - STREAM_DRAW = GL_STREAM_DRAW, - STREAM_READ = GL_STREAM_READ, - STREAM_COPY = GL_STREAM_COPY, - STATIC_DRAW = GL_STATIC_DRAW, - STATIC_READ = GL_STATIC_READ, - STATIC_COPY = GL_STATIC_COPY, - DYNAMIC_DRAW = GL_DYNAMIC_DRAW, - DYNAMIC_READ = GL_DYNAMIC_READ, - DYNAMIC_COPY = GL_DYNAMIC_COPY -}; - -enum BufferAccess -{ - READ_ONLY = GL_READ_ONLY, - WRITE_ONLY = GL_WRITE_ONLY, - READ_WRITE = GL_READ_WRITE -}; - class BufferRange; /** @@ -50,8 +25,6 @@ UniformBlock classes contain built-in support for buffers. */ class Buffer { - friend class BufferRange; - private: unsigned id; unsigned size; @@ -74,17 +47,11 @@ public: If storage has already been allocated, does nothing. */ void allocate(); - /** Sets the usage hint of the buffer. It will take effect the next time - the buffer's contents are defined. */ - DEPRECATED void set_usage(BufferUsage); - /** Uploads data into the buffer, completely replacing any previous contents. Storage must be defined beforehand. The data must have size matching the defined storage. */ void data(const void *); - DEPRECATED void data(unsigned, const void *); - /** Overwrites part of the buffer data with new data. Storage must be defined beforehand. */ void sub_data(unsigned, unsigned, const void *); @@ -94,7 +61,6 @@ public: void require_size(unsigned) const; void *map(); - DEPRECATED void *map(BufferAccess) { return map(); } bool unmap(); void set_debug_name(const std::string &); diff --git a/source/core/clipping.cpp b/source/core/clipping.cpp index d23ecffc..c2789423 100644 --- a/source/core/clipping.cpp +++ b/source/core/clipping.cpp @@ -9,11 +9,6 @@ using namespace std; namespace Msp { namespace GL { -unsigned Clipping::get_n_attach_points() -{ - return Limits::get_global().max_clip_planes; -} - void Clipping::attach(const ClipPlane &p) { if(find_member(planes, &p, &AttachedPlane::plane)!=planes.end()) @@ -31,12 +26,6 @@ void Clipping::detach(const ClipPlane &p) planes.erase(i); } -void Clipping::detach(unsigned i) -{ - if(i -#include #include "programdata.h" namespace Msp { @@ -25,16 +24,11 @@ private: mutable ProgramData shdata; public: - DEPRECATED static unsigned get_n_attach_points(); - void attach(const ClipPlane &); void detach(const ClipPlane &); unsigned get_n_planes() const { return planes.size(); } - DEPRECATED void attach(unsigned, const ClipPlane &p) { attach(p); } - DEPRECATED void detach(unsigned); - const ProgramData &get_shader_data() const; }; diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 30d2ab1c..c781b6a6 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -14,6 +14,7 @@ #include "pipelinestate.h" #include "program.h" #include "rect.h" +#include "sampler.h" #include "stenciltest.h" #include "texture.h" #include "uniformblock.h" diff --git a/source/core/pixelformat.cpp b/source/core/pixelformat.cpp index cfbf8112..270f27f7 100644 --- a/source/core/pixelformat.cpp +++ b/source/core/pixelformat.cpp @@ -1,4 +1,10 @@ +#include +#include #include +#include +#include +#include +#include #include #include #include "pixelformat.h" @@ -81,19 +87,7 @@ void operator>>(const LexicalConverter &conv, PixelFormat &fmt) else if(conv.get()=="DEPTH_COMPONENT32F") fmt = DEPTH_COMPONENT32F; else - { - if(conv.get()=="SRGB") - fmt = SRGB8; - else if(conv.get()=="SRGB_ALPHA") - fmt = SRGB8_ALPHA8; - else - { - PixelComponents comp; - conv >> comp; - fmt = make_pixelformat(comp, (comp==DEPTH_COMPONENT ? FLOAT : UNSIGNED_BYTE)); - } - IO::print(IO::cerr, "Warning: deprecated conversion of '%s' to PixelFormat\n", conv.get()); - } + throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get())); } PixelComponents components_from_graphics(Graphics::PixelFormat pf) diff --git a/source/core/pixelformat.h b/source/core/pixelformat.h index dde8594e..5a5302cd 100644 --- a/source/core/pixelformat.h +++ b/source/core/pixelformat.h @@ -1,19 +1,9 @@ #ifndef MSP_GL_PIXELFORMAT_H_ #define MSP_GL_PIXELFORMAT_H_ -#include #include #include #include "gl.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "datatype.h" namespace Msp { diff --git a/source/core/program.cpp b/source/core/program.cpp index 473d8a0b..9ed1e634 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -22,7 +22,6 @@ #include "misc.h" #include "program.h" #include "resources.h" -#include "shader.h" #include "glsl/compiler.h" using namespace std; @@ -35,30 +34,6 @@ Program::Program() init(); } -Program::Program(const string &source) -{ - init(); - - GlslModule mod; - mod.set_source(source); - add_stages(mod); - - link(); - module = 0; -} - -Program::Program(const string &vert, const string &frag) -{ - init(); - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" - attach_shader_owned(new VertexShader(vert)); - attach_shader_owned(new FragmentShader(frag)); -#pragma GCC diagnostic pop - link(); -} - Program::Program(const Module &mod, const map &spec_values) { init(); @@ -255,61 +230,6 @@ void Program::add_spirv_stages(const SpirVModule &mod, const map &s glSpecializeShader(stage_ids[i], j->name.c_str(), spec_id_array.size(), &spec_id_array[0], &spec_value_array[0]); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Program::attach_shader(Shader &shader) -{ - unsigned shader_id = shader.steal_id(); - if(!shader_id) - throw invalid_argument("Program::attach_shader"); - - int type; - glGetShaderiv(shader_id, GL_SHADER_TYPE, &type); - switch(type) - { - case GL_VERTEX_SHADER: stage_ids[VERTEX] = shader_id; break; - case GL_GEOMETRY_SHADER: stage_ids[GEOMETRY] = shader_id; break; - case GL_FRAGMENT_SHADER: stage_ids[FRAGMENT] = shader_id; break; - } - - glAttachShader(id, shader_id); - compile_glsl_stage(shader_id); -} - -void Program::attach_shader_owned(Shader *shader) -{ - attach_shader(*shader); - delete shader; -} - -void Program::detach_shader(Shader &) -{ -} - -const vector &Program::get_attached_shaders() const -{ - static vector dummy; - return dummy; -} - -void Program::bind_attribute(unsigned index, const string &name) -{ - static Require _req(ARB_vertex_shader); - glBindAttribLocation(id, index, name.c_str()); -} - -void Program::bind_attribute(VertexAttribute attr, const string &name) -{ - bind_attribute(get_attribute_semantic(attr), name); -} - -void Program::bind_fragment_data(unsigned index, const string &name) -{ - static Require _req(EXT_gpu_shader4); - glBindFragDataLocation(id, index, name.c_str()); -} -#pragma GCC diagnostic pop - void Program::link() { if(!has_stages()) @@ -678,15 +598,6 @@ bool Program::uniform_location_compare(const UniformInfo *uni1, const UniformInf return uni1->locationlocation; } -string Program::get_info_log() const -{ - GLsizei len = get_program_i(id, GL_INFO_LOG_LENGTH); - string log(len+1, 0); - glGetProgramInfoLog(id, len+1, &len, &log[0]); - log.erase(len); - return log; -} - const Program::UniformBlockInfo &Program::get_uniform_block_info(const string &name) const { auto i = find_member(uniform_blocks, name, &UniformBlockInfo::name); @@ -806,12 +717,6 @@ Program::Loader::Loader(Program &p, Collection &c): DataFile::CollectionObjectLoader(p, &c) { add("module", &Loader::module); - - // Deprecated - add("attribute", &Loader::attribute); - add("fragment_shader", &Loader::fragment_shader); - add("geometry_shader", &Loader::geometry_shader); - add("vertex_shader", &Loader::vertex_shader); } void Program::Loader::finish() @@ -827,29 +732,6 @@ void Program::Loader::module(const string &n) obj.add_stages(get_collection().get(n), spec_values); } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Program::Loader::attribute(unsigned i, const string &n) -{ - obj.bind_attribute(i, n); -} - -void Program::Loader::fragment_shader(const string &src) -{ - obj.attach_shader_owned(new FragmentShader(src)); -} - -void Program::Loader::geometry_shader(const string &src) -{ - obj.attach_shader_owned(new GeometryShader(src)); -} - -void Program::Loader::vertex_shader(const string &src) -{ - obj.attach_shader_owned(new VertexShader(src)); -} -#pragma GCC diagnostic pop - DataFile::Loader::ActionMap Program::SpecializationLoader::shared_actions; diff --git a/source/core/program.h b/source/core/program.h index f2d7d076..ecfe1a19 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -13,8 +13,6 @@ namespace Msp { namespace GL { -class Shader; - /** A complete shader program. Programs can be assembled of individual Shaders or generated with a set of standard features. @@ -30,11 +28,7 @@ public: private: virtual void finish(); - void attribute(unsigned, const std::string &); - void fragment_shader(const std::string &); - void geometry_shader(const std::string &); void module(const std::string &); - void vertex_shader(const std::string &); }; private: @@ -130,12 +124,6 @@ public: /// Constructs an empty Program with no shader stages attached. Program(); - /// Constructs a Program from unified source code using ProgramCompiler. - DEPRECATED Program(const std::string &); - - /// Constructs a Program from vertex and fragment shader source code. - DEPRECATED Program(const std::string &, const std::string &); - /// Constructs a Program from a Module, with specialization constants. Program(const Module &, const std::map & = std::map()); @@ -153,15 +141,6 @@ private: void add_spirv_stages(const SpirVModule &, const std::map &); public: - DEPRECATED void attach_shader(Shader &shader); - DEPRECATED void attach_shader_owned(Shader *shader); - DEPRECATED void detach_shader(Shader &shader); - DEPRECATED const std::vector &get_attached_shaders() const; - - DEPRECATED void bind_attribute(unsigned, const std::string &); - DEPRECATED void bind_attribute(VertexAttribute, const std::string &); - DEPRECATED void bind_fragment_data(unsigned, const std::string &); - void link(); private: void query_uniforms(); @@ -175,7 +154,6 @@ private: static bool uniform_location_compare(const UniformInfo *, const UniformInfo *); public: bool is_linked() const { return linked; } - DEPRECATED std::string get_info_log() const; LayoutHash get_uniform_layout_hash() const { return uniform_layout_hash; } const std::vector &get_uniform_blocks() const { return uniform_blocks; } diff --git a/source/core/sampler.h b/source/core/sampler.h index ff920186..43d1e541 100644 --- a/source/core/sampler.h +++ b/source/core/sampler.h @@ -46,8 +46,6 @@ enum TextureWrap MIRRORED_REPEAT = GL_MIRRORED_REPEAT }; -class Texture; - /** Samplers are used to access texture data in shaders. To use a sampler with a @@ -115,9 +113,6 @@ public: private: void update() const; - void set_parameter_i(unsigned, int) const; - void set_parameter_f(unsigned, float) const; - void set_parameter_fv(unsigned, const float *) const; public: void set_min_filter(TextureFilter); diff --git a/source/core/shader.cpp b/source/core/shader.cpp deleted file mode 100644 index 9950e497..00000000 --- a/source/core/shader.cpp +++ /dev/null @@ -1,122 +0,0 @@ -#include -#include -#include -#include -#include -#include "error.h" -#include "misc.h" -#include "shader.h" - -using namespace std; - -namespace Msp { -namespace GL { - -Shader::Shader(GLenum t) -{ - init(t); -} - -Shader::Shader(GLenum t, const string &src) -{ - init(t); - - source(src); - compile(); -} - -void Shader::init(GLenum t) -{ - static Require _req_base(ARB_shader_objects); - compiled = false; - - if(t==GL_FRAGMENT_SHADER) - static Require _req(ARB_fragment_shader); - else if(t==GL_VERTEX_SHADER) - static Require _req(ARB_vertex_shader); - else if(t==GL_GEOMETRY_SHADER) - static Require _req(ARB_geometry_shader4); - - id = glCreateShader(t); -} - -Shader::~Shader() -{ - if(id) - glDeleteShader(id); -} - -void Shader::source(unsigned count, const char **str, const int *len) -{ - glShaderSource(id, count, str, len); -} - -void Shader::source(const string &str) -{ - source(str.data(), str.size()); -} - -void Shader::source(const char *str, int len) -{ - source(1, &str, &len); -} - -void Shader::compile() -{ - glCompileShader(id); - compiled = get_shader_i(id, GL_COMPILE_STATUS); - if(!compiled) - throw compile_error(get_info_log()); - -#ifdef DEBUG - string info_log = get_info_log(); - if(!info_log.empty()) - IO::print("Shader compile info log:\n%s", info_log); -#endif -} - -unsigned Shader::steal_id() -{ - unsigned result = id; - id = 0; - return result; -} - -string Shader::get_info_log() const -{ - GLsizei len = get_shader_i(id, GL_INFO_LOG_LENGTH); - string log(len+1, 0); - glGetShaderInfoLog(id, len+1, &len, &log[0]); - log.erase(len); - return log; -} - - -VertexShader::VertexShader(): - Shader(GL_VERTEX_SHADER) -{ } - -VertexShader::VertexShader(const string &src): - Shader(GL_VERTEX_SHADER, src) -{ } - - -FragmentShader::FragmentShader(): - Shader(GL_FRAGMENT_SHADER) -{ } - -FragmentShader::FragmentShader(const string &src): - Shader(GL_FRAGMENT_SHADER, src) -{ } - - -GeometryShader::GeometryShader(): - Shader(GL_GEOMETRY_SHADER) -{ } - -GeometryShader::GeometryShader(const string &src): - Shader(GL_GEOMETRY_SHADER, src) -{ } - -} // namespace GL -} // namespace Msp diff --git a/source/core/shader.h b/source/core/shader.h deleted file mode 100644 index e02aa84a..00000000 --- a/source/core/shader.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MSP_GL_SHADER_H_ -#define MSP_GL_SHADER_H_ - -#include -#include -#include "gl.h" - -namespace Msp { -namespace GL { - -/** -A single shader stage. Shaders must be attached to a Program to be used. - -This class can't be instantiated directly. Use one of the VertexShader and -FragmentShader classes to create Shaders. -*/ -class Shader -{ -private: - unsigned id; - bool compiled; - -protected: - Shader(GLenum t); - Shader(GLenum t, const std::string &); -private: - void init(GLenum); -public: - virtual ~Shader(); - - void source(unsigned count, const char **str, const int *len); - void source(const std::string &str); - void source(const char *str, int len); - void compile(); - unsigned get_id() const { return id; } - unsigned steal_id(); - bool is_compiled() const { return compiled; } - std::string get_info_log() const; -} DEPRECATED; - - -class VertexShader: public Shader -{ -public: - VertexShader(); - VertexShader(const std::string &); -}; - - -class FragmentShader: public Shader -{ -public: - FragmentShader(); - FragmentShader(const std::string &); -}; - - -class GeometryShader: public Shader -{ -public: - GeometryShader(); - GeometryShader(const std::string &); -}; - -} // namespace GL -} // namespace Msp - -#endif diff --git a/source/core/texture.cpp b/source/core/texture.cpp index 5c82dbe5..bbda89b6 100644 --- a/source/core/texture.cpp +++ b/source/core/texture.cpp @@ -147,11 +147,6 @@ void Texture::generate_mipmap() } } -void Texture::load_image(const string &fn, bool) -{ - load_image(fn, 0U); -} - void Texture::load_image(const string &fn, unsigned lv) { Graphics::Image img; @@ -160,11 +155,6 @@ void Texture::load_image(const string &fn, unsigned lv) image(img, lv); } -void Texture::image(const Graphics::Image &img, bool) -{ - image(img, 0U); -} - void Texture::set_debug_name(const string &name) { #ifdef DEBUG diff --git a/source/core/texture.h b/source/core/texture.h index 555d19ff..80012f46 100644 --- a/source/core/texture.h +++ b/source/core/texture.h @@ -1,14 +1,10 @@ #ifndef MSP_GL_TEXTURE_H_ #define MSP_GL_TEXTURE_H_ -#include #include #include -#include "datatype.h" #include "gl.h" #include "pixelformat.h" -#include "predicate.h" -#include "sampler.h" #include "resource.h" namespace Msp { @@ -91,15 +87,11 @@ public: /// Loads a Graphics::Image from a file and uploads it to the texture. virtual void load_image(const std::string &, unsigned = 0); - DEPRECATED void load_image(const std::string &, bool srgb); - /** Uploads an image to the texture. If storage has not been defined, it will be set to match the image. Otherwise the image must be compatible with the defined storage. Semantics depend on the type of texture. */ virtual void image(const Graphics::Image &, unsigned = 0) = 0; - DEPRECATED void image(const Graphics::Image &, bool srgb); - GLenum get_target() const { return target; } unsigned get_id() const { return id; } diff --git a/source/core/texture1d.cpp b/source/core/texture1d.cpp index df8dd06c..7c3f02ab 100644 --- a/source/core/texture1d.cpp +++ b/source/core/texture1d.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -88,13 +87,6 @@ void Texture1D::image(unsigned level, const void *data) allocated |= 1< #include #include +#include #include #include "buffer.h" #include "error.h" @@ -118,13 +118,6 @@ void Texture2D::image(unsigned level, const void *data) allocated |= 1< -#include #include #include #include @@ -105,13 +104,6 @@ void Texture3D::image(unsigned level, const void *data) allocated |= 1<