EffectChain::EffectChain(float aspect_nom, float aspect_denom)
: aspect_nom(aspect_nom),
aspect_denom(aspect_denom),
+ fbo(0),
finalized(false) {}
+EffectChain::~EffectChain()
+{
+ for (unsigned i = 0; i < nodes.size(); ++i) {
+ if (nodes[i]->output_texture != 0) {
+ glDeleteTextures(1, &nodes[i]->output_texture);
+ }
+ delete nodes[i]->effect;
+ delete nodes[i];
+ }
+ for (unsigned i = 0; i < phases.size(); ++i) {
+ glDeleteProgram(phases[i]->glsl_program_num);
+ glDeleteShader(phases[i]->vertex_shader);
+ glDeleteShader(phases[i]->fragment_shader);
+ delete phases[i];
+ }
+ if (fbo != 0) {
+ glDeleteFramebuffers(1, &fbo);
+ }
+}
+
Input *EffectChain::add_input(Input *input)
{
inputs.push_back(input);
node->effect_id = effect_id;
node->output_color_space = COLORSPACE_INVALID;
node->output_gamma_curve = GAMMA_INVALID;
+ node->output_texture = 0;
nodes.push_back(node);
node_map[effect] = node;
Phase *phase = new Phase;
phase->glsl_program_num = glsl_program_num;
+ phase->vertex_shader = vs_obj;
+ phase->fragment_shader = fs_obj;
phase->input_needs_mipmaps = input_needs_mipmaps;
phase->inputs = true_inputs;
phase->effects = effects;
// A rendering phase; a single GLSL program rendering a single quad.
struct Phase {
- GLint glsl_program_num;
+ GLint glsl_program_num, vertex_shader, fragment_shader;
bool input_needs_mipmaps;
// Inputs are only inputs from other phases (ie., those that come from RTT);
class EffectChain {
public:
EffectChain(float aspect_nom, float aspect_denom); // E.g., 16.0f, 9.0f for 16:9.
+ ~EffectChain();
// User API:
// input, effects, output, finalize need to come in that specific order.
SDL_WM_SetCaption("OpenGL window for unit test", NULL);
testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ int err = RUN_ALL_TESTS();
+ SDL_Quit();
+ exit(err);
}
check_error();
}
+EffectChainTester::~EffectChainTester()
+{
+ glDeleteFramebuffers(1, &fbo);
+ glDeleteTextures(1, &texnum);
+}
+
Input *EffectChainTester::add_input(const float *data, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve)
{
ImageFormat format;
class EffectChainTester {
public:
EffectChainTester(const float *data, unsigned width, unsigned height, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve);
+ ~EffectChainTester();
+
EffectChain *get_chain() { return &chain; }
Input *add_input(const float *data, MovitPixelFormat pixel_format, ColorSpace color_space, GammaCurve gamma_curve);
void run(float *out_data, GLenum format, ColorSpace color_space, GammaCurve gamma_curve);