]> git.sesse.net Git - movit/commitdiff
Add a “sandbox effect” that does nothing but is a useful playground for development...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 3 Oct 2012 17:56:22 +0000 (19:56 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 3 Oct 2012 17:58:55 +0000 (19:58 +0200)
Makefile
effect_chain.cpp
effect_id.h
main.cpp
sandbox_effect.cpp [new file with mode: 0644]
sandbox_effect.frag [new file with mode: 0644]
sandbox_effect.h [new file with mode: 0644]

index b2cb05971f1a2f0093226e786cb0c4de53cf5bb4..1b6bdd5cae7cb8425e591b29b5bef32dc924e055 100644 (file)
--- 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)
index 462633c2916526663bebe217af5b4853b4da09bf..c55ee26849617374010b879785b6fcfd5cd55b52 100644 (file)
@@ -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:
index 291002b033e75b1215af6f72b670e7f3061f2358..bed27f5e8b265b921c349db2051cf3baa563fd1d 100644 (file)
@@ -6,6 +6,7 @@ enum EffectId {
        EFFECT_GAMMA_EXPANSION = 0,
        EFFECT_GAMMA_COMPRESSION,
        EFFECT_COLOR_SPACE_CONVERSION,
+       EFFECT_SANDBOX,
 
        // Color.
        EFFECT_LIFT_GAMMA_GAIN,
index f00abaa636ee9ee49dac77adbcf914ced9dfef32..35d5bc8df4c9f16df8ebdb5fa7371127cf2c00f9 100644 (file)
--- 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 (file)
index 0000000..85fa900
--- /dev/null
@@ -0,0 +1,27 @@
+#define GL_GLEXT_PROTOTYPES 1
+
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glext.h>
+#include <assert.h>
+
+#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 (file)
index 0000000..30e03e4
--- /dev/null
@@ -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 (file)
index 0000000..391be6d
--- /dev/null
@@ -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)