SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_OPENGL);
SDL_WM_SetCaption("OpenGL window", NULL);
- init_movit(".");
+ init_movit(".", MOVIT_DEBUG_ON);
printf("GPU texture subpixel precision: about %.1f bits\n",
log2(1.0f / movit_texel_subpixel_precision));
#include "colorspace_conversion_effect.h"
#include "dither_effect.h"
#include "input.h"
+#include "init.h"
EffectChain::EffectChain(float aspect_nom, float aspect_denom)
: aspect_nom(aspect_nom),
frag_shader += std::string("#define INPUT ") + effects.back()->effect_id + "\n";
frag_shader.append(read_file("footer.frag"));
-#ifndef NDEBUG
- // Output shader to a temporary file, for easier debugging.
- static int compiled_shader_num = 0;
- char filename[256];
- sprintf(filename, "chain-%03d.frag", compiled_shader_num++);
- FILE *fp = fopen(filename, "w");
- if (fp == NULL) {
- perror(filename);
- exit(1);
+ if (movit_debug_level == MOVIT_DEBUG_ON) {
+ // Output shader to a temporary file, for easier debugging.
+ static int compiled_shader_num = 0;
+ char filename[256];
+ sprintf(filename, "chain-%03d.frag", compiled_shader_num++);
+ FILE *fp = fopen(filename, "w");
+ if (fp == NULL) {
+ perror(filename);
+ exit(1);
+ }
+ fprintf(fp, "%s\n", frag_shader.c_str());
+ fclose(fp);
}
- fprintf(fp, "%s\n", frag_shader.c_str());
- fclose(fp);
-#endif
GLuint glsl_program_num = glCreateProgram();
GLuint vs_obj = compile_shader(read_file("vs.vert"), GL_VERTEX_SHADER);
void EffectChain::output_dot(const char *filename)
{
-#ifdef NDEBUG
- return;
-#endif
+ if (movit_debug_level != MOVIT_DEBUG_ON) {
+ return;
+ }
FILE *fp = fopen(filename, "w");
if (fp == NULL) {
#include "util.h"
bool movit_initialized = false;
+MovitDebugLevel movit_debug_level = MOVIT_DEBUG_ON;
float movit_texel_subpixel_precision;
bool movit_srgb_textures_supported;
} // namespace
-void init_movit(const std::string& data_directory)
+void init_movit(const std::string& data_directory, MovitDebugLevel debug_level)
{
if (movit_initialized) {
return;
}
movit_data_directory = new std::string(data_directory);
+ movit_debug_level = debug_level;
glewInit();
#include <string>
+enum MovitDebugLevel {
+ MOVIT_DEBUG_OFF = 0,
+ MOVIT_DEBUG_ON = 1,
+};
+
// Initialize the library; in particular, will query the GPU for information
// that is needed by various components. For instance, it verifies that
// we have all the OpenGL extensions we need.
//
-// The parameter gives which directory to read .frag files from.
+// The first parameter gives which directory to read .frag files from.
// This is a temporary hack until we add something more solid.
-// If you call init_movit() twice with different values for data_directory,
+//
+// The second parameter specifies whether debugging is on or off.
+// If it is on, Movit will write intermediate graphs and the final
+// generated shaders to the current directory.
+//
+// If you call init_movit() twice with different parameters,
// only the first will count.
-void init_movit(const std::string& data_directory);
+void init_movit(const std::string& data_directory, MovitDebugLevel debug_level);
// GPU features. These are not intended for end-user use.
// Whether init_movit() has been called.
extern bool movit_initialized;
+// The current debug level.
+extern MovitDebugLevel movit_debug_level;
+
// An estimate on the smallest values the linear texture interpolation
// of the GPU can distinguish between, i.e., for a GPU with N-bit
// texture subpixel precision, this value will be 2^-N.
GLenum framebuffer_format)
: chain(width, height), width(width), height(height), finalized(false)
{
- init_movit(".");
+ init_movit(".", MOVIT_DEBUG_ON);
if (data != NULL) {
add_input(data, pixel_format, color_space, gamma_curve);