41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
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();
|
|
~RTT();
|
|
|
|
void destroy();
|
|
void copy(const RTT& source);
|
|
void resize(int width, int height);
|
|
bool create(int width, int height, int tex = -1, GLint internal_format = GL_RGBA8);
|
|
bool recreate() { return create(w, h); }
|
|
void clear(glm::vec4 color = glm::vec4(0));
|
|
glm::ivec4 calc_bounds();
|
|
uint8_t* readTextureData(uint8_t* buffer = nullptr);
|
|
float* readTextureDataFloat(float* buffer = nullptr);
|
|
uint8_t* createBuffer();
|
|
float* createBufferFloat();
|
|
void bindFramebuffer();
|
|
void unbindFramebuffer();
|
|
void bindTexture();
|
|
void unbindTexture();
|
|
GLuint getTextureID() const { return texID; }
|
|
int getWidth() const { return w; }
|
|
int getHeight() const { return h; }
|
|
int bytes() const { return w * h * 4; }
|
|
int stride() const { return w * 4; }
|
|
GLuint getFBO() const { return fboID; }
|
|
};
|