Files
panopainter/engine/rtt.h
2018-05-09 12:04:29 +02:00

35 lines
835 B
C++

#pragma once
class RTT
{
bool bound = false;
GLint oldRFboID = 0;
GLint oldDFboID = 0;
GLuint fboID = 0;
GLuint rboID = 0;
GLuint texID = 0;
int w = 0;
int h = 0;
public:
RTT();
~RTT();
void destroy();
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));
void readTextureData(uint8_t* buffer);
uint8_t* createBuffer();
void bindFramebuffer();
void unbindFramebuffer();
void bindTexture();
void unbindTexture();
GLuint getTextureID() { return texID; }
int getWidth() { return w; }
int getHeight() { return h; }
int bytes() { return w * h * 4; }
int stride() { return w * 4; }
GLuint getFBO() { return fboID; }
};