]> git.tdb.fi Git - libs/gl.git/commitdiff
Use set_manager instead of passing the manager to the constructor
authorMikko Rasa <tdb@tdb.fi>
Thu, 7 Oct 2021 08:23:57 +0000 (11:23 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 7 Oct 2021 12:43:22 +0000 (15:43 +0300)
This allows always using the parameterless constructor, making some
things easier.

source/backends/opengl/texture2d_backend.cpp
source/backends/opengl/texture2d_backend.h
source/core/mesh.cpp
source/core/mesh.h
source/core/texture.cpp
source/core/texture.h
source/core/texture2d.cpp
source/core/texture2d.h
source/resources/resources.cpp

index c47600cf9402f99a0a41f41df9c43f753ccbfcde..2f7e503b7d42a9aec7e8055a38fa2446e5805a0a 100644 (file)
@@ -31,8 +31,8 @@ public:
 };
 
 
-OpenGLTexture2D::OpenGLTexture2D(ResourceManager *m):
-       Texture(GL_TEXTURE_2D, m)
+OpenGLTexture2D::OpenGLTexture2D():
+       Texture(GL_TEXTURE_2D)
 { }
 
 void OpenGLTexture2D::allocate()
index 8f2fec594f65733840dc8ede27fdd5d48a615ef7..595c51f51ea38e76233f1617f37ea4398095a190 100644 (file)
@@ -13,7 +13,7 @@ class OpenGLTexture2D: public Texture
 protected:
        class AsyncLoader;
 
-       OpenGLTexture2D(ResourceManager *);
+       OpenGLTexture2D();
 
        void allocate();
        void sub_image(unsigned, int, int, unsigned, unsigned, const void *);
index 981a59e8002c46585f498887da1c32f00429b7ce..1e811b5b2b135725db55ebb54f7bd2e9909afb5b 100644 (file)
@@ -9,19 +9,16 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Mesh::Mesh(ResourceManager *rm):
+Mesh::Mesh():
        vbuf(0),
        ibuf(0),
        dirty(0),
        disallow_rendering(false),
        face_winding(NON_MANIFOLD)
-{
-       if(rm)
-               set_manager(rm);
-}
+{ }
 
-Mesh::Mesh(const VertexFormat &f, ResourceManager *rm):
-       Mesh(rm)
+Mesh::Mesh(const VertexFormat &f):
+       Mesh()
 {
        storage(f);
 }
index 39bf55b22d5129f0725f11a44233f48be28556d9..89f51fdd9e3493aa97bddd3e40409bffeb34f991 100644 (file)
@@ -75,8 +75,8 @@ private:
        std::string debug_name;
 
 public:
-       Mesh(ResourceManager * = 0);
-       Mesh(const VertexFormat &, ResourceManager * = 0);
+       Mesh();
+       Mesh(const VertexFormat &);
        ~Mesh();
 
        void storage(const VertexFormat &);
index be825e7ff231f118356897dcc6036365c178be32..568479a6d7fd9d187b3a9805af63591283bc9239 100644 (file)
@@ -8,17 +8,14 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Texture::Texture(unsigned t, ResourceManager *m):
+Texture::Texture(unsigned t):
        TextureBackend(t),
        format(NO_PIXELFORMAT),
        storage_fmt(format),
        swizzle(NO_SWIZZLE),
        use_srgb_format(false),
        auto_gen_mipmap(false)
-{
-       if(m)
-               set_manager(m);
-}
+{ }
 
 void Texture::set_format(PixelFormat fmt)
 {
index 2f647b90cae721837f441a59c4c67e5c5f3f31fd..33e0769d65431ac8c6a25152b486ea589337fed4 100644 (file)
@@ -63,7 +63,7 @@ protected:
        bool use_srgb_format;
        bool auto_gen_mipmap;
 
-       Texture(unsigned, ResourceManager * = 0);
+       Texture(unsigned);
 
        void set_format(PixelFormat);
 
index 8dc15b1c38aaf3a6364c3eccf80249ef25d2f301..01612d7325a8bf21c875e6e5a7de4f3de461657d 100644 (file)
@@ -6,8 +6,7 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
-Texture2D::Texture2D(ResourceManager *m):
-       Texture2DBackend(m),
+Texture2D::Texture2D():
        width(0),
        height(0)
 { }
index a2454b76b3e613dd552599a2e545d7aef4716d0a..4f0bde26960c0db5f4dee5c9a0edd381f86e285e 100644 (file)
@@ -37,7 +37,7 @@ private:
        unsigned levels;
 
 public:
-       Texture2D(ResourceManager * = 0);
+       Texture2D();
        virtual ~Texture2D();
 
        /** Defines storage structure for the texture.  If lv is zero, the number
index fa20a0bf2e38d5cc072908480ce0bf3a62008257..ec5f431ddba048cf441b2024de70fc84737b92f3 100644 (file)
@@ -167,7 +167,8 @@ Mesh *Resources::create_mesh(const string &name)
 
        if(RefPtr<IO::Seekable> io = open_raw(name))
        {
-               RefPtr<Mesh> mesh = new Mesh(resource_manager);
+               RefPtr<Mesh> mesh = new Mesh;
+               mesh->set_manager(resource_manager);
                resource_manager->set_resource_location(*mesh, *this, name);
                return mesh.release();
        }
@@ -187,7 +188,8 @@ Texture2D *Resources::create_texture2d(const string &name)
 
                if(ext==".tex2d")
                {
-                       tex = new Texture2D(resource_manager);
+                       tex = new Texture2D;
+                       tex->set_manager(resource_manager);
                        DataFile::Parser parser(*io, name);
                        Texture2D::Loader ldr(*tex, *this);
                        ldr.load(parser);