From 94f25cea88583054fde5d693acf406dfbc3f7048 Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Wed, 24 Mar 2021 01:07:49 -0700 Subject: [PATCH] removing redundant framebuffer virtual methods --- include/blah/graphics/framebuffer.h | 8 ++++---- src/core/app.cpp | 12 ------------ src/graphics/batch.cpp | 2 +- src/graphics/blend.cpp | 2 +- src/graphics/framebuffer.cpp | 20 ++++++++++++++++++++ src/graphics/mesh.cpp | 2 +- src/graphics/renderpass.cpp | 2 +- src/graphics/shader.cpp | 2 +- src/graphics/spritefont.cpp | 2 +- src/graphics/subtexture.cpp | 2 +- src/graphics/texture.cpp | 2 +- src/internal/graphics_backend_d3d11.cpp | 20 -------------------- src/internal/graphics_backend_dummy.cpp | 20 -------------------- src/internal/graphics_backend_gl.cpp | 20 -------------------- 14 files changed, 32 insertions(+), 84 deletions(-) diff --git a/include/blah/graphics/framebuffer.h b/include/blah/graphics/framebuffer.h index e5656a7..48230a0 100644 --- a/include/blah/graphics/framebuffer.h +++ b/include/blah/graphics/framebuffer.h @@ -54,16 +54,16 @@ namespace Blah virtual const Attachments& attachments() const = 0; // Gets the Attachment at a given index from the FrameBuffer - virtual TextureRef& attachment(int index) = 0; + TextureRef& attachment(int index); // Gets the Attachment at a given index from the FrameBuffer - virtual const TextureRef& attachment(int index) const = 0; + const TextureRef& attachment(int index) const; // Gets the width of the FrameBuffer - virtual int width() const = 0; + virtual int width() const; // Gets the height of the FrameBuffer - virtual int height() const = 0; + virtual int height() const; // Clears the FrameBuffer virtual void clear(Color color = Color::black, float depth = 1.0f, u8 stencil = 0, ClearMask mask = ClearMask::All) = 0; diff --git a/src/core/app.cpp b/src/core/app.cpp index d4c059c..750c263 100644 --- a/src/core/app.cpp +++ b/src/core/app.cpp @@ -278,18 +278,6 @@ namespace return empty_attachments; } - virtual TextureRef& attachment(int index) override - { - BLAH_ASSERT(false, "Backbuffer doesn't have any attachments"); - return empty_texture; - } - - virtual const TextureRef& attachment(int index) const override - { - BLAH_ASSERT(false, "Backbuffer doesn't have any attachments"); - return empty_texture; - } - virtual int width() const override { return App::draw_width(); diff --git a/src/graphics/batch.cpp b/src/graphics/batch.cpp index 95cdf73..33c46f8 100644 --- a/src/graphics/batch.cpp +++ b/src/graphics/batch.cpp @@ -1090,4 +1090,4 @@ void Batch::str(const SpriteFont& font, const String& text, const Vec2& pos, Tex } pop_matrix(); -} \ No newline at end of file +} diff --git a/src/graphics/blend.cpp b/src/graphics/blend.cpp index cdf6d5d..2eeb355 100644 --- a/src/graphics/blend.cpp +++ b/src/graphics/blend.cpp @@ -22,4 +22,4 @@ const BlendMode BlendMode::Subtract = BlendMode( BlendFactor::One, BlendMask::RGBA, 0xffffffff -); \ No newline at end of file +); diff --git a/src/graphics/framebuffer.cpp b/src/graphics/framebuffer.cpp index 6400e92..b61b864 100644 --- a/src/graphics/framebuffer.cpp +++ b/src/graphics/framebuffer.cpp @@ -31,3 +31,23 @@ FrameBufferRef FrameBuffer::create(int width, int height, const AttachmentFormat return GraphicsBackend::create_framebuffer(width, height, attachments.data(), attachments.size()); } + +TextureRef& FrameBuffer::attachment(int index) +{ + return attachments()[index]; +} + +const TextureRef& FrameBuffer::attachment(int index) const +{ + return attachments()[index]; +} + +int FrameBuffer::width() const +{ + return attachments()[0]->width(); +} + +int FrameBuffer::height() const +{ + return attachments()[0]->height(); +} diff --git a/src/graphics/mesh.cpp b/src/graphics/mesh.cpp index 59fe7a1..9c308ea 100644 --- a/src/graphics/mesh.cpp +++ b/src/graphics/mesh.cpp @@ -38,4 +38,4 @@ VertexFormat::VertexFormat(std::initializer_list attributes, in } this->stride = stride; -} \ No newline at end of file +} diff --git a/src/graphics/renderpass.cpp b/src/graphics/renderpass.cpp index cbd6433..83b7cc0 100644 --- a/src/graphics/renderpass.cpp +++ b/src/graphics/renderpass.cpp @@ -91,4 +91,4 @@ void RenderPass::perform() // perform render GraphicsBackend::render(pass); -} \ No newline at end of file +} diff --git a/src/graphics/shader.cpp b/src/graphics/shader.cpp index 5c7ed02..f4b7711 100644 --- a/src/graphics/shader.cpp +++ b/src/graphics/shader.cpp @@ -36,4 +36,4 @@ ShaderRef Shader::create(const ShaderData& data) } return shader; -} \ No newline at end of file +} diff --git a/src/graphics/spritefont.cpp b/src/graphics/spritefont.cpp index 3c75ed9..08c4db4 100644 --- a/src/graphics/spritefont.cpp +++ b/src/graphics/spritefont.cpp @@ -296,4 +296,4 @@ const SpriteFont::Character& SpriteFont::operator[](Codepoint codepoint) const if (it != m_characters.end()) return it->second; return empty; -} \ No newline at end of file +} diff --git a/src/graphics/subtexture.cpp b/src/graphics/subtexture.cpp index e144390..b38f1c2 100644 --- a/src/graphics/subtexture.cpp +++ b/src/graphics/subtexture.cpp @@ -61,4 +61,4 @@ Subtexture Subtexture::crop(const Rect& clip) const crop_info(clip, &dst.source, &dst.frame); dst.update(); return dst; -} \ No newline at end of file +} diff --git a/src/graphics/texture.cpp b/src/graphics/texture.cpp index 7ea7655..12b3b35 100644 --- a/src/graphics/texture.cpp +++ b/src/graphics/texture.cpp @@ -32,4 +32,4 @@ TextureRef Texture::create(Stream& stream) TextureRef Texture::create(const FilePath& file) { return create(Image(file)); -} \ No newline at end of file +} diff --git a/src/internal/graphics_backend_d3d11.cpp b/src/internal/graphics_backend_d3d11.cpp index abeaa71..d346161 100644 --- a/src/internal/graphics_backend_d3d11.cpp +++ b/src/internal/graphics_backend_d3d11.cpp @@ -332,26 +332,6 @@ namespace Blah return m_attachments; } - virtual TextureRef& attachment(int index) override - { - return m_attachments[index]; - } - - virtual const TextureRef& attachment(int index) const override - { - return m_attachments[index]; - } - - virtual int width() const override - { - return m_attachments[0]->width(); - } - - virtual int height() const override - { - return m_attachments[0]->height(); - } - virtual void clear(Color color, float depth, u8 stencil, ClearMask mask) override { float col[4] = { color.r / 255.0f, color.g / 255.0f, color.b / 255.0f, color.a / 255.0f }; diff --git a/src/internal/graphics_backend_dummy.cpp b/src/internal/graphics_backend_dummy.cpp index f3359fc..1f97c83 100644 --- a/src/internal/graphics_backend_dummy.cpp +++ b/src/internal/graphics_backend_dummy.cpp @@ -83,26 +83,6 @@ namespace Blah return m_attachments; } - virtual TextureRef& attachment(int index) override - { - return m_attachments[index]; - } - - virtual const TextureRef& attachment(int index) const override - { - return m_attachments[index]; - } - - virtual int width() const override - { - return m_attachments[0]->width(); - } - - virtual int height() const override - { - return m_attachments[0]->height(); - } - virtual void clear(Color color) override { diff --git a/src/internal/graphics_backend_gl.cpp b/src/internal/graphics_backend_gl.cpp index 530e17d..071d3b3 100644 --- a/src/internal/graphics_backend_gl.cpp +++ b/src/internal/graphics_backend_gl.cpp @@ -729,26 +729,6 @@ namespace Blah return m_attachments; } - virtual TextureRef& attachment(int index) override - { - return m_attachments[index]; - } - - virtual const TextureRef& attachment(int index) const override - { - return m_attachments[index]; - } - - virtual int width() const override - { - return m_width; - } - - virtual int height() const override - { - return m_height; - } - virtual void clear(Color color, float depth, u8 stencil, ClearMask mask) override { int clear = 0;