diff --git a/sfw/render_core/texture.cpp b/sfw/render_core/texture.cpp index f72f983..4f8651e 100644 --- a/sfw/render_core/texture.cpp +++ b/sfw/render_core/texture.cpp @@ -5,16 +5,6 @@ #include "window.h" -void Texture::set_as_render_target() { - glBindFramebuffer(GL_FRAMEBUFFER, _fbo); - glViewport(0, 0, _fbo_width, _fbo_height); -} - -void Texture::unset_render_target() { - glBindFramebuffer(GL_FRAMEBUFFER, 0); - glViewport(0, 0, AppWindow::get_singleton()->get_width(), AppWindow::get_singleton()->get_height()); -} - void Texture::create_from_image(const Ref &img) { if (_image == img) { return; @@ -269,10 +259,6 @@ Texture::Texture() { _flags = 0; _texture_format = Image::FORMAT_RGBA8; - - _fbo_width = 0; - _fbo_height = 0; - _fbo = 0; } Texture::~Texture() { @@ -280,3 +266,25 @@ Texture::~Texture() { glDeleteTextures(1, &_texture); } } + +//RenderTexture + +void RenderTexture::set_as_render_target() { + glBindFramebuffer(GL_FRAMEBUFFER, _fbo); + glViewport(0, 0, _fbo_width, _fbo_height); +} + +void RenderTexture::unset_render_target() { + glBindFramebuffer(GL_FRAMEBUFFER, 0); + glViewport(0, 0, AppWindow::get_singleton()->get_width(), AppWindow::get_singleton()->get_height()); +} + +RenderTexture::RenderTexture() : + Texture() { + _fbo_width = 0; + _fbo_height = 0; + _fbo = 0; +} + +RenderTexture::~RenderTexture() { +} diff --git a/sfw/render_core/texture.h b/sfw/render_core/texture.h index 01db7db..1d9c024 100644 --- a/sfw/render_core/texture.h +++ b/sfw/render_core/texture.h @@ -17,9 +17,6 @@ public: return _texture; } - void set_as_render_target(); - void unset_render_target(); - void create_from_image(const Ref &img); Ref get_data(); @@ -44,7 +41,18 @@ protected: int _mipmaps; GLuint _texture; +}; +//TODO +class RenderTexture : public Texture { +public: + void set_as_render_target(); + void unset_render_target(); + + RenderTexture(); + virtual ~RenderTexture(); + +protected: int _fbo_width; int _fbo_height; GLuint _fbo;