]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/framebuffer.cpp
Use friend declarations to access OpenGL IDs of objects
[libs/gl.git] / source / core / framebuffer.cpp
index a60b437eff6fbe9e4c9a1eec8e2b6012b35395af..97b5c8b1394e428bcc640339af98d58a68607462 100644 (file)
@@ -139,24 +139,23 @@ void Framebuffer::update() const
                        const Attachment &attch = attachments[i];
                        if(attch.tex)
                        {
-                               GLenum type = attch.tex->get_target();
                                if(ARB_direct_state_access)
                                {
-                                       if(type==GL_TEXTURE_2D || type==GL_TEXTURE_2D_MULTISAMPLE || attch.layer<0)
-                                               glNamedFramebufferTexture(id, gl_attach_point, attch.tex->get_id(), attch.level);
+                                       if(attch.tex->target==GL_TEXTURE_2D || attch.tex->target==GL_TEXTURE_2D_MULTISAMPLE || attch.layer<0)
+                                               glNamedFramebufferTexture(id, gl_attach_point, attch.tex->id, attch.level);
                                        else
-                                               glNamedFramebufferTextureLayer(id, gl_attach_point, attch.tex->get_id(), attch.level, attch.layer);
+                                               glNamedFramebufferTextureLayer(id, gl_attach_point, attch.tex->id, attch.level, attch.layer);
                                }
-                               else if(type==GL_TEXTURE_2D || type==GL_TEXTURE_2D_MULTISAMPLE)
-                                       glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, type, attch.tex->get_id(), attch.level);
+                               else if(attch.tex->target==GL_TEXTURE_2D || attch.tex->target==GL_TEXTURE_2D_MULTISAMPLE)
+                                       glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, attch.tex->target, attch.tex->id, attch.level);
                                else if(attch.layer<0)
-                                       glFramebufferTexture(GL_FRAMEBUFFER, gl_attach_point, attch.tex->get_id(), attch.level);
-                               else if(type==GL_TEXTURE_2D_ARRAY)
-                                       glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attach_point, attch.tex->get_id(), attch.level, attch.layer);
-                               else if(type==GL_TEXTURE_3D)
-                                       glFramebufferTexture3D(GL_FRAMEBUFFER, gl_attach_point, type, attch.tex->get_id(), attch.level, attch.layer);
-                               else if(type==GL_TEXTURE_CUBE_MAP)
-                                       glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, get_gl_cube_face(static_cast<TextureCubeFace>(attch.layer)), attch.tex->get_id(), attch.level);
+                                       glFramebufferTexture(GL_FRAMEBUFFER, gl_attach_point, attch.tex->id, attch.level);
+                               else if(attch.tex->target==GL_TEXTURE_2D_ARRAY)
+                                       glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_attach_point, attch.tex->id, attch.level, attch.layer);
+                               else if(attch.tex->target==GL_TEXTURE_3D)
+                                       glFramebufferTexture3D(GL_FRAMEBUFFER, gl_attach_point, attch.tex->target, attch.tex->id, attch.level, attch.layer);
+                               else if(attch.tex->target==GL_TEXTURE_CUBE_MAP)
+                                       glFramebufferTexture2D(GL_FRAMEBUFFER, gl_attach_point, get_gl_cube_face(static_cast<TextureCubeFace>(attch.layer)), attch.tex->id, attch.level);
                        }
                        else if(ARB_direct_state_access)
                                glNamedFramebufferTexture(id, gl_attach_point, 0, 0);
@@ -206,28 +205,27 @@ void Framebuffer::check_size()
        for(Attachment &a: attachments)
                if(a.tex)
                {
-                       GLenum type = a.tex->get_target();
                        unsigned w = 0;
                        unsigned h = 0;
-                       if(type==GL_TEXTURE_2D)
+                       if(a.tex->target==GL_TEXTURE_2D)
                        {
                                Texture2D *tex = static_cast<Texture2D *>(a.tex);
                                w = max(tex->get_width()>>a.level, 1U);
                                h = max(tex->get_height()>>a.level, 1U);
                        }
-                       else if(type==GL_TEXTURE_2D_MULTISAMPLE)
+                       else if(a.tex->target==GL_TEXTURE_2D_MULTISAMPLE)
                        {
                                Texture2DMultisample *tex = static_cast<Texture2DMultisample *>(a.tex);
                                w = tex->get_width();
                                h = tex->get_height();
                        }
-                       else if(type==GL_TEXTURE_3D || type==GL_TEXTURE_2D_ARRAY)
+                       else if(a.tex->target==GL_TEXTURE_3D || a.tex->target==GL_TEXTURE_2D_ARRAY)
                        {
                                Texture3D *tex = static_cast<Texture3D *>(a.tex);
                                w = max(tex->get_width()>>a.level, 1U);
                                h = max(tex->get_height()>>a.level, 1U);
                        }
-                       else if(type==GL_TEXTURE_CUBE_MAP)
+                       else if(a.tex->target==GL_TEXTURE_CUBE_MAP)
                        {
                                w = max(static_cast<TextureCube *>(a.tex)->get_size()>>a.level, 1U);
                                h = w;