New ImageFilter applied to Clone Sources

Preliminary implementation, effective but without consequence on the rendering.
This commit is contained in:
Bruno Herbelin
2022-04-19 01:23:50 +02:00
parent 3c465f9a7a
commit d41a85f4a1
5 changed files with 346 additions and 6 deletions

69
ImageFilter.h Normal file
View File

@@ -0,0 +1,69 @@
#ifndef IMAGEFILTER_H
#define IMAGEFILTER_H
#include <map>
class Surface;
class FrameBuffer;
#include "Shader.h"
class ImageFilteringShader : public Shader
{
ShadingProgram custom_shading_;
// fragment shader GLSL code
std::string code_;
// list of uniform vars in GLSL
// with associated pair (current_value, default_values) in range [0.f 1.f]
std::map<std::string, glm::vec2> uniforms_;
public:
ImageFilteringShader();
~ImageFilteringShader();
void use() override;
void reset() override;
void accept(Visitor& v) override;
void copy(ImageFilteringShader const& S);
// set fragment shader code and uniforms (with default values)
void setFragmentCode(const std::string &code, std::map<std::string, float> parameters);
};
class ImageFilter
{
Surface *surface_;
FrameBuffer *buffer_;
ImageFilteringShader *shader_;
uint type_;
public:
// instanciate an image filter at given resolution, with alpha channel
ImageFilter(glm::vec3 resolution, bool useAlpha = false);
~ImageFilter();
// set the texture to draw into the framebuffer
void setInputTexture(uint t);
// typedef enum {
// } ;
void setFilter(uint filter);
// draw the input texture with filter on the framebuffer
void draw();
// get the texture id of the rendered framebuffer
uint getOutputTexture() const;
};
#endif // IMAGEFILTER_H