From 3140175e3160e75d659e596e420afffb596e3c2c Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 5 Nov 2012 21:24:31 +0100 Subject: [PATCH] Add a function for EffectChainTester to get out the uint8 result. --- test_util.cpp | 18 ++++++++++++++++++ test_util.h | 1 + 2 files changed, 19 insertions(+) diff --git a/test_util.cpp b/test_util.cpp index cd79bd7..3aecd54 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -106,6 +106,24 @@ void EffectChainTester::run(float *out_data, GLenum format, Colorspace color_spa vertical_flip(out_data, width, height); } +void EffectChainTester::run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve) +{ + if (!finalized) { + finalize_chain(color_space, gamma_curve); + } + + chain.render_to_fbo(fbo, width, height); + + glBindFramebuffer(GL_FRAMEBUFFER, fbo); + glReadPixels(0, 0, width, height, format, GL_UNSIGNED_BYTE, out_data); + + if (format == GL_RGBA) { + width *= 4; + } + + vertical_flip(out_data, width, height); +} + void EffectChainTester::finalize_chain(Colorspace color_space, GammaCurve gamma_curve) { assert(!finalized); diff --git a/test_util.h b/test_util.h index d149fe1..412acad 100644 --- a/test_util.h +++ b/test_util.h @@ -15,6 +15,7 @@ public: Input *add_input(const float *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve); Input *add_input(const unsigned char *data, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve); void run(float *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve); + void run(unsigned char *out_data, GLenum format, Colorspace color_space, GammaCurve gamma_curve); private: void finalize_chain(Colorspace color_space, GammaCurve gamma_curve); -- 2.39.2