gamma correction in post when there's no sRGB framebuffer and simple shader compositi...
[vrfileman] / src / rtarg.h
diff --git a/src/rtarg.h b/src/rtarg.h
new file mode 100644 (file)
index 0000000..ed15ac3
--- /dev/null
@@ -0,0 +1,56 @@
+#ifndef RTARG_H_
+#define RTARG_H_
+
+#include "gmath/gmath.h"
+#include "opengl.h"
+
+class Texture;
+
+class RenderTarget {
+private:
+       int width, height;
+
+       unsigned int fbo;
+       Texture *color_tex;
+       unsigned int tex_targ;
+       int tex_face;
+       unsigned int rbuf_zstencil;
+
+       Mat4 tex_matrix;
+
+       void bind() const;
+
+public:
+       static unsigned int default_fbo;        // 0 on most platforms, GLKit fbo on iOS.
+
+       RenderTarget();
+       ~RenderTarget();
+
+       bool create(unsigned int fmt = GL_RGBA);
+       bool create(int width, int height, unsigned int fmt = GL_RGBA);
+       bool create(Texture *tex, int face = 0);
+
+       void cleanup();
+
+       bool resize(int width, int height);
+
+       int get_width() const;
+       int get_height() const;
+
+       Texture *get_texture() const;
+
+       /** calculates a texture matrix to map the full texture space
+        * onto the part of the texture occupied by the render target
+        */
+       const Mat4 &get_texture_matrix() const;
+
+       bool check() const;
+
+       friend void set_render_target(const RenderTarget *rtarg);
+};
+
+void set_render_target(const RenderTarget *rtarg);
+
+int next_pow2(int x);
+
+#endif // RTARG_H_