4 #include <gmath/gmath.h>
8 // flags for RenderTarget::create
15 // flags for push_render_target/pop_render_target and RenderTarget::bind
20 RT_FAKE = RT_NO_VPORT | RT_NO_BIND
26 int tex_width, tex_height;
31 // either the depth texture or a dummy depth render target is used
33 unsigned int rbdepth, rbdepth_fmt;
34 Mat4 texmat; // texture matrix to map tex coords from [0,1] to the useful area
44 bool create(int xsz, int ysz, unsigned int fmt = GL_SRGB_ALPHA,
45 unsigned int flags = RT_COLOR | RT_DEPTH);
46 bool create_mrt(int xsz, int ysz, int num, unsigned int fmt = GL_RGB16F,
47 unsigned int flags = RT_COLOR | RT_DEPTH);
48 /* create a RenderTarget wrapping an existing FBO.
49 * At this point this is just a hack with limited functionality.
50 * Calls which return textures might return 0. get_width/get_height
51 * will return whatever is passed here as xsz/ysz. resize will not do
54 bool create_wrap_fbo(unsigned int fbo, int xsz, int ysz);
57 bool resize(int xsz, int ysz);
59 int get_width() const;
60 int get_height() const;
62 void set_texture(Texture *tex, int idx = 0);
63 void set_depth_texture(Texture *tex);
65 Texture *texture(int idx = 0) const;
66 Texture *depth_texture() const;
68 void set_auto_viewport(bool enable);
69 bool auto_viewport() const;
71 void bind(unsigned int flags = 0) const;
72 const Mat4 &texture_matrix() const;
75 void set_render_target(RenderTarget *rt);
76 RenderTarget *current_render_target();
78 bool push_render_target(RenderTarget *rt, unsigned int flags = 0);
79 bool pop_render_target(unsigned int flags = 0);