Skip to content

Commit

Permalink
abstract framebuffer object
Browse files Browse the repository at this point in the history
  • Loading branch information
toloudis committed Dec 20, 2023
1 parent 2c99bc2 commit 1245959
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 8 deletions.
13 changes: 12 additions & 1 deletion renderlib/graphics/IRenderWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ class Scene;

#include <memory>

class IRenderTarget
{
public:
virtual ~IRenderTarget() {}

virtual void bind() = 0;
virtual void release() = 0;
virtual int width() const = 0;
virtual int height() const = 0;
};

class IRenderWindow
{
public:
Expand All @@ -18,7 +29,7 @@ class IRenderWindow

virtual void initialize(uint32_t w, uint32_t h) = 0;
virtual void render(const CCamera& camera) = 0;
virtual void renderTo(const CCamera& camera, GLFramebufferObject* fbo) = 0;
virtual void renderTo(const CCamera& camera, IRenderTarget* fbo) = 0;
virtual void resize(uint32_t w, uint32_t h) = 0;
virtual void getSize(uint32_t& w, uint32_t& h) = 0;
virtual void cleanUpResources() {}
Expand Down
2 changes: 1 addition & 1 deletion renderlib/graphics/RenderGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ RenderGL::doClear()
}

void
RenderGL::renderTo(const CCamera& camera, GLFramebufferObject* fbo)
RenderGL::renderTo(const CCamera& camera, IRenderTarget* fbo)
{
bool haveScene = prepareToRender();

Expand Down
2 changes: 1 addition & 1 deletion renderlib/graphics/RenderGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RenderGL : public IRenderWindow

virtual void initialize(uint32_t w, uint32_t h);
virtual void render(const CCamera& camera);
virtual void renderTo(const CCamera& camera, GLFramebufferObject* fbo);
virtual void renderTo(const CCamera& camera, IRenderTarget* fbo);
virtual void resize(uint32_t w, uint32_t h);
virtual void getSize(uint32_t& w, uint32_t& h)
{
Expand Down
2 changes: 1 addition & 1 deletion renderlib/graphics/RenderGLPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ RenderGLPT::render(const CCamera& camera)
}

void
RenderGLPT::renderTo(const CCamera& camera, GLFramebufferObject* fbo)
RenderGLPT::renderTo(const CCamera& camera, IRenderTarget* fbo)
{
doRender(camera);

Expand Down
2 changes: 1 addition & 1 deletion renderlib/graphics/RenderGLPT.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RenderGLPT : public IRenderWindow

virtual void initialize(uint32_t w, uint32_t h);
virtual void render(const CCamera& camera);
virtual void renderTo(const CCamera& camera, GLFramebufferObject* fbo);
virtual void renderTo(const CCamera& camera, IRenderTarget* fbo);
virtual void resize(uint32_t w, uint32_t h);
virtual void getSize(uint32_t& w, uint32_t& h)
{
Expand Down
3 changes: 2 additions & 1 deletion renderlib/graphics/gl/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "glm.h"

#include "Logging.h"
#include "graphics/IRenderWindow.h"

#include <string>

Expand Down Expand Up @@ -89,7 +90,7 @@ class GLTimer
};

// RAII; must have a current gl context at creation time.
class GLFramebufferObject
class GLFramebufferObject : public IRenderTarget
{
public:
GLFramebufferObject(int width, int height, GLint colorInternalFormat);
Expand Down
2 changes: 1 addition & 1 deletion renderlib_wgpu/RenderWgpuPT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RenderWgpuPT::render(const CCamera& camera)
{
}
void
RenderWgpuPT::renderTo(const CCamera& camera, GLFramebufferObject* fbo)
RenderWgpuPT::renderTo(const CCamera& camera, IRenderTarget* fbo)
{
}
void
Expand Down
2 changes: 1 addition & 1 deletion renderlib_wgpu/RenderWgpuPT.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RenderWgpuPT : public IRenderWindow

virtual void initialize(uint32_t w, uint32_t h);
virtual void render(const CCamera& camera);
virtual void renderTo(const CCamera& camera, GLFramebufferObject* fbo);
virtual void renderTo(const CCamera& camera, IRenderTarget* fbo);
virtual void resize(uint32_t w, uint32_t h);
virtual void getSize(uint32_t& w, uint32_t& h)
{
Expand Down

0 comments on commit 1245959

Please sign in to comment.