nuclear@0: #ifndef RTARG_H_ nuclear@0: #define RTARG_H_ nuclear@0: nuclear@0: #include "vmath/vmath.h" nuclear@0: #include "opengl.h" nuclear@0: nuclear@0: class Texture; nuclear@0: nuclear@0: class RenderTarget { nuclear@0: private: nuclear@0: int width, height; nuclear@0: nuclear@0: unsigned int fbo; nuclear@0: Texture *color_tex; nuclear@0: unsigned int tex_targ; nuclear@0: int tex_face; nuclear@0: unsigned int rbuf_zstencil; nuclear@0: nuclear@0: public: nuclear@0: RenderTarget(); nuclear@0: ~RenderTarget(); nuclear@0: nuclear@0: bool create(unsigned int fmt = GL_RGBA); nuclear@0: bool create(int width, int height, unsigned int fmt = GL_RGBA); nuclear@0: bool create(Texture *tex, int face = 0); nuclear@0: nuclear@0: void cleanup(); nuclear@0: nuclear@0: bool resize(int width, int height); nuclear@0: nuclear@0: int get_width() const; nuclear@0: int get_height() const; nuclear@0: nuclear@0: Texture *get_texture() const; nuclear@0: nuclear@0: /** calculates a texture matrix to map the full texture space nuclear@0: * onto the part of the texture occupied by the render target nuclear@0: */ nuclear@0: Matrix4x4 get_texture_matrix() const; nuclear@0: nuclear@0: bool check() const; nuclear@0: void bind() const; nuclear@0: }; nuclear@0: nuclear@0: void set_render_target(const RenderTarget *rtarg); nuclear@0: nuclear@0: int next_pow2(int x); nuclear@0: nuclear@0: #endif // RTARG_H_