#pragma once #include "image.h" class RTT { int w = 0; int h = 0; GLuint fboID = 0; GLuint texID = 0; GLuint rboID = 0; GLint int_fmt = 0; bool bound = false; GLint oldRFboID = 0; GLint oldDFboID = 0; public: // copy RTT(const RTT&) = delete; RTT& operator=(const RTT&) = delete; // move RTT(RTT&& other); RTT& operator=(RTT&&); // default RTT(); ~RTT(); void destroy(); // copy with interpolation void copy(const RTT& source); // copy a region void copy(const RTT& source, const glm::vec4& rect); RTT clone() const noexcept; bool resize(int width, int height); bool create(int width, int height, int tex = -1, GLint internal_format = GL_RGBA8, bool depth_buffer = false); bool recreate() { return create(w, h); } void clear(glm::vec4 color = glm::vec4(0)); void clear_mask(glm::bool4 mask, glm::vec4 color = glm::vec4(0)); glm::ivec4 calc_bounds() const noexcept; uint8_t* readTextureData(uint8_t* buffer = nullptr) const noexcept; float* readTextureDataFloat(float* buffer = nullptr) const noexcept; uint8_t* createBuffer() const noexcept; float* createBufferFloat() const noexcept; void bindFramebuffer(); void unbindFramebuffer(); void bindTexture(); void unbindTexture(); GLuint getTextureID() const noexcept { return texID; } int getWidth() const noexcept { return w; } int getHeight() const noexcept { return h; } glm::ivec2 getSize() const noexcept { return { w, h }; } int bytes() const noexcept { return w * h * 4; } int stride() const noexcept { return w * 4; } GLuint getFBO() const noexcept { return fboID; } Image get_image() const noexcept; bool valid() const noexcept; };