diff --git a/Makefile b/Makefile index 3826d3e..1b40d7c 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,17 @@ all : glslview glslwrite -USE_INOTIFY = -DUSE_INOTIFY +ifeq ($(shell uname -s),Linux) +USE_INOTIFY ?= -DUSE_INOTIFY +endif -CFLAGS = -O3 -Wall $(USE_INOTIFY) -LIBS = -lSDL2 -lGL -lGLEW -lm +CFLAGS ?= -O3 -Wall +LIBS := -lSDL2 -lGL -lGLEW -lm glslview : glslview.c common.c common.h - $(CC) $(CFLAGS) -o $@ glslview.c common.c $(LIBS) + $(CC) $(CFLAGS) $(USE_INOTIFY) -o $@ glslview.c common.c $(LIBS) glslwrite : glslwrite.c common.c common.h $(CC) $(CFLAGS) -o $@ glslwrite.c common.c $(LIBS) -lpng + +clean : + rm -f glslview glslwrite diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..f329dec --- /dev/null +++ b/README.txt @@ -0,0 +1,129 @@ +glslview +======== + +glslview is a simple program to run GLSL fragment shaders and interact with them. + +glslview will render a simple fullscreen rectangle, the shader will determine each +pixel's color. + +The glslwrite tool can be used to write the generated frames to PNG files +(with transparency support!). + +You will need a graphics adapter and drivers with modern OpenGL/GLSL support. + +Building +~~~~~~~~ + +glslview has been tested on Linux only, but it should work on other systems as well. +If it doesn't, I'm happy to take patches. + +glslview has the following dependencies: + +* SDL2 +* libGL +* libGLEW + +glslwrite additionally depends on libpng. + +On Linux, glslview will use inotify to watch the loaded shader file for changes. + + +Running +~~~~~~~ + +Shader +------ + +glslview will supply the following uniform parameters to the shader: + +vec2 res + The current resolution of the window + +float time + Current time in milliseconds (by default since start of the program) + +int param0, param1, param2 + Modifiable parameters, 0 by default + +The shader must define an output vec4 called "fragColor" into which the fragment color +is to be written. + +See the examples provided with the source for more information. The "symmetry" +example makes use of all parameters. + + +Command line +------------ + + glslview + glslwrite + + +Common options: + +-w + Initial window width (default: 800) + +-h + Initial window height (default: 800) + +-0, -1, -2 + Initial value for the shader parameters + + +glslview options: + +-s + Initial speed factor (default: 1.0, negative values make time run backwards) + +-t