/*This class performs integration across a series of rectangular texture samples. Basically, this is a downsample using a large box filter and can be used to sum the results of multiple calculations that are combined in a single texture.*/ #include "rts_glRenderToTexture.h" #include "rts_glShaderProgram.h" #define MEAN 0 #define SUM 1 #define MIN 2 #define MAX 3 class rts_glIntegrateTexture { private: int x_sample_size; int y_sample_size; int x_sample_num; int y_sample_num; rts_glShaderProgram x_pass_mean; rts_glShaderProgram y_pass_mean; rts_glShaderProgram x_pass_min; rts_glShaderProgram y_pass_min; rts_glShaderProgram x_pass_max; rts_glShaderProgram y_pass_max; //this is a two-pass downsample rts_glRenderToTexture x_pass; rts_glRenderToTexture y_pass; void initialize_shaders(); inline void x_pass_enable(int type, rts_glTextureMap texture); inline void x_pass_disable(int type); inline void y_pass_enable(int type); inline void y_pass_disable(int type); public: //initialize the integrator with the number and size of samples void Init(int x_size, int y_size, int samples_x, int samples_y, rts_glTextureMap test); void Integrate(float* result, rts_glTextureMap texture, int type = MEAN); rts_glTextureMap getResultTexture(){return y_pass.GetTexture(0);} }; void rts_glIntegrateTexture::initialize_shaders() { //load and initialize the integration shaders x_pass_mean.AttachShader(GL_FRAGMENT_SHADER, "x_pass_mean.glsl"); x_pass_mean.Compile(); x_pass_mean.Link(); cout<<"x_pass_mean.glsl"<