fixed reflections in VR
[laserbrain_demo] / src / rtarg.h
index f77682d..22abc4f 100644 (file)
@@ -12,6 +12,14 @@ enum {
        RT_STENCIL = 4
 };
 
+// flags for push_render_target/pop_render_target and RenderTarget::bind
+enum {
+       RT_NO_VPORT     = 1,
+       RT_NO_BIND      = 2,
+
+       RT_FAKE         = RT_NO_VPORT | RT_NO_BIND
+};
+
 class RenderTarget {
 private:
        int width, height;
@@ -22,9 +30,10 @@ private:
        int rtcount;
        // either the depth texture or a dummy depth render target is used
        Texture *depth;
-       unsigned int rbdepth;
+       unsigned int rbdepth, rbdepth_fmt;
        Mat4 texmat; // texture matrix to map tex coords from [0,1] to the useful area
 
+       bool own_fbo;
        bool own_texture[4];
        bool auto_vport;
 
@@ -36,8 +45,17 @@ public:
                        unsigned int flags = RT_COLOR | RT_DEPTH);
        bool create_mrt(int xsz, int ysz, int num, unsigned int fmt = GL_RGB16F,
                        unsigned int flags = RT_COLOR | RT_DEPTH);
+       /* create a RenderTarget wrapping an existing FBO.
+        * At this point this is just a hack with limited functionality.
+        * Calls which return textures might return 0. get_width/get_height
+        * will return whatever is passed here as xsz/ysz. resize will not do
+        * anything.
+        */
+       bool create_wrap_fbo(unsigned int fbo, int xsz, int ysz);
        void destroy();
 
+       bool resize(int xsz, int ysz);
+
        int get_width() const;
        int get_height() const;
 
@@ -50,14 +68,14 @@ public:
        void set_auto_viewport(bool enable);
        bool auto_viewport() const;
 
-       void bind() const;
+       void bind(unsigned int flags = 0) const;
        const Mat4 &texture_matrix() const;
 };
 
 void set_render_target(RenderTarget *rt);
 RenderTarget *current_render_target();
 
-bool push_render_target(RenderTarget *rt);
-bool pop_render_target();
+bool push_render_target(RenderTarget *rt, unsigned int flags = 0);
+bool pop_render_target(unsigned int flags = 0);
 
 #endif // RTARG_H_