50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#pragma once
|
|
#include "image.h"
|
|
|
|
class RTT
|
|
{
|
|
bool bound = false;
|
|
GLint oldRFboID = 0;
|
|
GLint oldDFboID = 0;
|
|
GLuint fboID = 0;
|
|
GLuint rboID = 0;
|
|
GLuint texID = 0;
|
|
GLint int_fmt = 0;
|
|
int w = 0;
|
|
int h = 0;
|
|
|
|
public:
|
|
RTT(const RTT&) = delete;
|
|
RTT(RTT&& other);
|
|
RTT();
|
|
~RTT();
|
|
|
|
void destroy();
|
|
// copy with interpolation
|
|
void copy(const RTT& source);
|
|
// copy a region
|
|
void copy(const RTT& source, const glm::vec4& rect);
|
|
void 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;
|
|
};
|