goat3dgfx

diff src/rtarg.h @ 0:1873dfd13f2d

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 14 Nov 2013 05:27:09 +0200
parents
children 7d6b667821cf
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/rtarg.h	Thu Nov 14 05:27:09 2013 +0200
     1.3 @@ -0,0 +1,49 @@
     1.4 +#ifndef RTARG_H_
     1.5 +#define RTARG_H_
     1.6 +
     1.7 +#include "vmath/vmath.h"
     1.8 +#include "opengl.h"
     1.9 +
    1.10 +class Texture;
    1.11 +
    1.12 +class RenderTarget {
    1.13 +private:
    1.14 +	int width, height;
    1.15 +
    1.16 +	unsigned int fbo;
    1.17 +	Texture *color_tex;
    1.18 +	unsigned int tex_targ;
    1.19 +	int tex_face;
    1.20 +	unsigned int rbuf_zstencil;
    1.21 +
    1.22 +public:
    1.23 +	RenderTarget();
    1.24 +	~RenderTarget();
    1.25 +
    1.26 +	bool create(unsigned int fmt = GL_RGBA);
    1.27 +	bool create(int width, int height, unsigned int fmt = GL_RGBA);
    1.28 +	bool create(Texture *tex, int face = 0);
    1.29 +
    1.30 +	void cleanup();
    1.31 +
    1.32 +	bool resize(int width, int height);
    1.33 +
    1.34 +	int get_width() const;
    1.35 +	int get_height() const;
    1.36 +
    1.37 +	Texture *get_texture() const;
    1.38 +
    1.39 +	/** calculates a texture matrix to map the full texture space
    1.40 +	 * onto the part of the texture occupied by the render target
    1.41 +	 */
    1.42 +	Matrix4x4 get_texture_matrix() const;
    1.43 +
    1.44 +	bool check() const;
    1.45 +	void bind() const;
    1.46 +};
    1.47 +
    1.48 +void set_render_target(const RenderTarget *rtarg);
    1.49 +
    1.50 +int next_pow2(int x);
    1.51 +
    1.52 +#endif	// RTARG_H_