From: Steinar H. Gunderson Date: Wed, 3 Oct 2012 17:56:22 +0000 (+0200) Subject: Add a “sandbox effect” that does nothing but is a useful playground for development... X-Git-Tag: 1.0~396 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=0b4a4101426130d2b7037cdb219d5c05b8d4c3d3 Add a “sandbox effect” that does nothing but is a useful playground for development of new effects. --- diff --git a/Makefile b/Makefile index b2cb059..1b6bdd5 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ CXX=g++ CXXFLAGS=-Wall -g LDFLAGS=-lSDL -lSDL_image -lGL OBJS=main.o util.o widgets.o effect.o effect_chain.o -OBJS += lift_gamma_gain_effect.o gamma_expansion_effect.o gamma_compression_effect.o colorspace_conversion_effect.o saturation_effect.o vignette_effect.o mirror_effect.o blur_effect.o +OBJS += lift_gamma_gain_effect.o gamma_expansion_effect.o gamma_compression_effect.o colorspace_conversion_effect.o saturation_effect.o vignette_effect.o mirror_effect.o blur_effect.o sandbox_effect.o test: $(OBJS) $(CXX) -o test $(OBJS) $(LDFLAGS) diff --git a/effect_chain.cpp b/effect_chain.cpp index 462633c..c55ee26 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -13,6 +13,7 @@ #include "gamma_compression_effect.h" #include "lift_gamma_gain_effect.h" #include "colorspace_conversion_effect.h" +#include "sandbox_effect.h" #include "saturation_effect.h" #include "mirror_effect.h" #include "vignette_effect.h" @@ -42,6 +43,8 @@ Effect *instantiate_effect(EffectId effect) return new GammaCompressionEffect(); case EFFECT_COLOR_SPACE_CONVERSION: return new ColorSpaceConversionEffect(); + case EFFECT_SANDBOX: + return new SandboxEffect(); case EFFECT_LIFT_GAMMA_GAIN: return new LiftGammaGainEffect(); case EFFECT_SATURATION: diff --git a/effect_id.h b/effect_id.h index 291002b..bed27f5 100644 --- a/effect_id.h +++ b/effect_id.h @@ -6,6 +6,7 @@ enum EffectId { EFFECT_GAMMA_EXPANSION = 0, EFFECT_GAMMA_COMPRESSION, EFFECT_COLOR_SPACE_CONVERSION, + EFFECT_SANDBOX, // Color. EFFECT_LIFT_GAMMA_GAIN, diff --git a/main.cpp b/main.cpp index f00abaa..35d5bc8 100644 --- a/main.cpp +++ b/main.cpp @@ -174,6 +174,8 @@ int main(int argc, char **argv) Effect *saturation_effect = chain.add_effect(EFFECT_SATURATION); Effect *blur_effect = chain.add_effect(EFFECT_BLUR); Effect *vignette_effect = chain.add_effect(EFFECT_VIGNETTE); + //Effect *sandbox_effect = chain.add_effect(EFFECT_SANDBOX); + //sandbox_effect->set_float("parm", 42.0f); //chain.add_effect(EFFECT_MIRROR); chain.add_output(inout_format); chain.finalize(); diff --git a/sandbox_effect.cpp b/sandbox_effect.cpp new file mode 100644 index 0000000..85fa900 --- /dev/null +++ b/sandbox_effect.cpp @@ -0,0 +1,27 @@ +#define GL_GLEXT_PROTOTYPES 1 + +#include +#include +#include +#include + +#include "sandbox_effect.h" +#include "util.h" + +SandboxEffect::SandboxEffect() + : parm(0.0f) +{ + register_float("parm", &parm); +} + +std::string SandboxEffect::output_fragment_shader() +{ + return read_file("sandbox_effect.frag"); +} + +void SandboxEffect::set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) +{ + Effect::set_uniforms(glsl_program_num, prefix, sampler_num); + + // Any OpenGL state you might want to set, goes here. +} diff --git a/sandbox_effect.frag b/sandbox_effect.frag new file mode 100644 index 0000000..30e03e4 --- /dev/null +++ b/sandbox_effect.frag @@ -0,0 +1,5 @@ +vec4 FUNCNAME(vec2 tc) { + // Your code goes here, obviously. + // You can use PREFIX(parm) to access the parameter you gave in. + return LAST_INPUT(tc); +} diff --git a/sandbox_effect.h b/sandbox_effect.h new file mode 100644 index 0000000..391be6d --- /dev/null +++ b/sandbox_effect.h @@ -0,0 +1,24 @@ +#ifndef _SANDBOX_EFFECT_H +#define _SANDBOX_EFFECT_H 1 + +// This effect, by default, does nothing. +// +// But imagine all the cool things you can make it do! Thus, the SandboxEffect +// is intended to be a sandbox for you to have a place to write your test or +// throwaway code. When you're happy, you can do a bit of search and replace +// to give it a proper name and its own place in the build system. + +#include "effect.h" + +class SandboxEffect : public Effect { +public: + SandboxEffect(); + std::string output_fragment_shader(); + + void set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num); + +private: + float parm; +}; + +#endif // !defined(_SANDBOX_EFFECT_H)