Skip to content

Commit

Permalink
Added missing GLSL version of the anti-aliased Euclidean distance tra…
Browse files Browse the repository at this point in the history
…nsform
  • Loading branch information
Christophe Riccio committed Jul 7, 2013
1 parent b63f6e4 commit da48e19
Show file tree
Hide file tree
Showing 21 changed files with 10,947 additions and 0 deletions.
Binary file not shown.
8,643 changes: 8,643 additions & 0 deletions Chapter 12 2D Shape Rendering by Distance Fields/jfa-AA-demo/GL/glext.h

Large diffs are not rendered by default.

509 changes: 509 additions & 0 deletions Chapter 12 2D Shape Rendering by Distance Fields/jfa-AA-demo/GL/glfw.h

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
[Project]
FileName=GLSL-JFA.dev
Name=GLSL-JFA
UnitCount=5
Type=1
Ver=1
ObjFiles=
Includes=
Libs=
PrivateResource=
ResourceIncludes=
MakeIncludes=
Compiler=-Wall -O3 -ffast-math -I"C:\Dev-Cpp\include"_@@_
CppCompiler=
Linker=-lglfw -lopengl32 -lglu32 -mwindows -mconsole_@@_
IsCpp=0
Icon=
ExeOutput=
ObjectOutput=
OverrideOutput=0
OverrideOutputName=texremap.exe
HostApplication=
Folders=
CommandLine=
UseCustomMakefile=0
CustomMakefile=
IncludeVersionInfo=0
SupportXPThemes=0
CompilerSet=0
CompilerSettings=0000000000000001000000

[Unit1]
FileName=GLSL-JFA.c
CompileCpp=0
Folder=
Compile=1
Link=1
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[VersionInfo]
Major=0
Minor=1
Release=1
Build=1
LanguageID=1033
CharsetID=1252
CompanyName=
FileVersion=
FileDescription=Developed using the Dev-C++ IDE
InternalName=
LegalCopyright=
LegalTrademarks=
OriginalFilename=
ProductName=
ProductVersion=
AutoIncBuildNr=0

[Unit2]
FileName=vertex.glsl
Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[Unit4]
FileName=fragment_flood.glsl
CompileCpp=0
Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[Unit5]
FileName=fragment_display.glsl
Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=$(CC) -c fragment_display.glsl.c -o fragment_display.glsl.o $(CFLAGS)

[Unit7]
FileName=fragment4.glsl
Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=

[Unit3]
FileName=fragment_seed.glsl
Folder=
Compile=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[Editor_4]
CursorCol=1
CursorRow=9
TopLine=1
LeftChar=1
Open=1
Top=0
[Editors]
Focused=0
Order=2,3,4,0
[Editor_0]
Open=1
Top=1
CursorCol=1
CursorRow=558
TopLine=530
LeftChar=1
[Editor_1]
Open=0
Top=0
[Editor_2]
Open=1
Top=0
CursorCol=1
CursorRow=38
TopLine=16
LeftChar=1
[Editor_3]
Open=1
Top=0
CursorCol=1
CursorRow=47
TopLine=33
LeftChar=1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#Makefile for Windows mingw32, Linux and MacOSX (gcc environments)

Usage:
@echo "Usage: make Win32 | Linux | MacOSX | clean | distclean"

Win32:
gcc.exe -c GLSL-JFA.c -o GLSL-JFA.o -I. -IC:/Dev-Cpp/include -Wall -O3 -ffast-math -g3
gcc.exe GLSL-JFA.o -o GLSL-JFA.exe -LC:/Dev-Cpp/lib -mwindows -lglfw -lopengl32 -lglu32 -mconsole -g3

Linux:
gcc -I. -I/usr/X11/include GLSL-JFA.c -lglfw -o GLSL-JFA

MacOSX:
./bundle.sh GLSL-JFA
gcc -I. -I/usr/X11/include GLSL-JFA.c -o GLSL-JFA.app/Contents/MacOS/GLSL-JFA -lglfw -framework Cocoa -framework OpenGL

clean:
rm -f GLSL-JFA.o

distclean:
rm -rf GLSL-JFA.o GLSL-JFA GLSL-JFA.exe GLSL-JFA.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Project: GLSL-JFA
# Makefile created by Dev-C++ 4.9.9.2

CPP = g++.exe -D__DEBUG__
CC = gcc.exe -D__DEBUG__
WINDRES = windres.exe
RES =
OBJ = GLSL-JFA.o $(RES)
LINKOBJ = GLSL-JFA.o $(RES)
LIBS = -L"C:/Dev-Cpp/lib" -lglfw -lopengl32 -lglu32 -mwindows -mconsole -g3
INCS = -I"C:/Dev-Cpp/include"
CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"
BIN = GLSL-JFA.exe
CXXFLAGS = $(CXXINCS) -g3
CFLAGS = $(INCS) -Wall -O3 -ffast-math -I"C:\Dev-Cpp\include" -g3
RM = rm -f

.PHONY: all all-before all-after clean clean-custom

all: all-before GLSL-JFA.exe all-after


clean: clean-custom
${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
$(CC) $(LINKOBJ) -o "GLSL-JFA.exe" $(LIBS)

GLSL-JFA.o: GLSL-JFA.c
$(CC) -c GLSL-JFA.c -o GLSL-JFA.o $(CFLAGS)
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh

# Creates application bundles for use on Mac OS X.

if [ -z "$1" ]; then
echo "usage: `basename $0` BUNDLE-NAME"
exit 1
fi

bundle_name="$1"

if [ ! -d "${bundle_name}.app/Contents/MacOS" ]; then
mkdir -p "${bundle_name}.app/Contents/MacOS"
fi

if [ ! -d "${bundle_name}.app/Contents/Resources" ]; then
mkdir -p "${bundle_name}.app/Contents/Resources"
fi

if [ ! -f "${bundle_name}.app/Contents/PkgInfo" ]; then
echo -n "APPL????" > "${bundle_name}.app/Contents/PkgInfo"
fi

if [ ! -f "${bundle_name}.app/Contents/Info.plist" ]; then
cat > "${bundle_name}.app/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${bundle_name}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.1</string>
</dict>
</plist>
EOF
fi

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Jump flooding algorithm for EDT according
// to Danielsson (1980) and Guodong Rong (2007),
// with added support for anti-aliased edges.
// Implementation by Stefan Gustavson 2010.
// This code is in the public domain.

// This shader displays the final distance field
// visualized as an RGB image.

uniform sampler2D texture;
uniform float texw, texh;
uniform float texlevels;
varying vec2 uv;

vec2 remap(vec2 floatdata) {
return floatdata * (texlevels-1.0) / texlevels * 2.0 - 1.0;
}

void main( void )
{
vec3 texel;
texel = texture2D(texture, uv).rgb;
vec2 distvec = remap(texel.rg);
// vec2 rainbow = 0.5+0.5*(normalize(distvec));
// gl_FragColor = vec4(rainbow, 1.0-(length(distvec)+texel.b-0.5)*4.0, 1.0);
float dist = length(distvec)+(texel.b-0.5)/texw;
gl_FragColor = vec4(vec2(mod(10.0*dist, 1.0)), texel.b, 1.0);
}
Loading

0 comments on commit da48e19

Please sign in to comment.