fixed reflections in VR
[laserbrain_demo] / src / rtarg.h
index 2cead11..22abc4f 100644 (file)
@@ -12,6 +12,14 @@ enum {
        RT_STENCIL = 4
 };
 
        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;
 class RenderTarget {
 private:
        int width, height;
@@ -25,6 +33,7 @@ private:
        unsigned int rbdepth, rbdepth_fmt;
        Mat4 texmat; // texture matrix to map tex coords from [0,1] to the useful area
 
        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;
 
        bool own_texture[4];
        bool auto_vport;
 
@@ -36,6 +45,13 @@ 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);
                        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);
        void destroy();
 
        bool resize(int xsz, int ysz);
@@ -52,14 +68,14 @@ public:
        void set_auto_viewport(bool enable);
        bool auto_viewport() const;
 
        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();
 
        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_
 
 #endif // RTARG_H_