diff --git a/example_color/addons.make b/example_color/addons.make new file mode 100644 index 0000000..6fc1b7e --- /dev/null +++ b/example_color/addons.make @@ -0,0 +1 @@ +ofxGpuParticles diff --git a/example_color/bin/data/.gitkeep b/example_color/bin/data/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/example_color/bin/data/colors.png b/example_color/bin/data/colors.png new file mode 100644 index 0000000..5ff2f56 Binary files /dev/null and b/example_color/bin/data/colors.png differ diff --git a/example_color/bin/data/draw.frag b/example_color/bin/data/draw.frag new file mode 100644 index 0000000..08dc7b1 --- /dev/null +++ b/example_color/bin/data/draw.frag @@ -0,0 +1,7 @@ +#version 120 +#extension GL_ARB_texture_rectangle : enable + +void main() +{ + gl_FragColor = gl_Color; +} diff --git a/example_color/bin/data/draw.vert b/example_color/bin/data/draw.vert new file mode 100644 index 0000000..f940927 --- /dev/null +++ b/example_color/bin/data/draw.vert @@ -0,0 +1,12 @@ +#version 120 +#extension GL_ARB_texture_rectangle : enable + +uniform sampler2DRect particles0; +uniform sampler2DRect particles1; + +void main() +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_FrontColor = gl_Color; + gl_Position = gl_ModelViewProjectionMatrix * vec4(texture2DRect(particles0, gl_TexCoord[0].st).xyz, 1.0); +} diff --git a/example_color/bin/data/update.frag b/example_color/bin/data/update.frag new file mode 100644 index 0000000..43ac72d --- /dev/null +++ b/example_color/bin/data/update.frag @@ -0,0 +1,41 @@ +#version 120 +#extension GL_ARB_texture_rectangle : enable + +// ping pong inputs +uniform sampler2DRect particles0; +uniform sampler2DRect particles1; + +uniform vec3 mouse; +uniform float radiusSquared; +uniform float elapsed; + +void main() +{ + vec3 pos = texture2DRect(particles0, gl_TexCoord[0].st).xyz; + vec3 vel = texture2DRect(particles1, gl_TexCoord[0].st).xyz; + + // mouse attraction + vec3 direction = mouse - pos.xyz; + float distSquared = dot(direction, direction); + float magnitude = 500.0 * (1.0 - distSquared / radiusSquared); + vec3 force = step(distSquared, radiusSquared) * magnitude * normalize(direction); + + // gravity + force += vec3(0.0, -0.5, 0.0); + + // accelerate + vel += elapsed * force; + + // bounce off the sides + vel.x *= step(abs(pos.x), 512.0) * 2.0 - 1.0; + vel.y *= step(abs(pos.y), 384.0) * 2.0 - 1.0; + + // damping + vel *= 0.995; + + // move + pos += elapsed * vel; + + gl_FragData[0] = vec4(pos, 1.0); + gl_FragData[1] = vec4(vel, 0.0); +} \ No newline at end of file diff --git a/example_color/bin/data/update.vert b/example_color/bin/data/update.vert new file mode 100644 index 0000000..32b3238 --- /dev/null +++ b/example_color/bin/data/update.vert @@ -0,0 +1,8 @@ +#version 120 +#extension GL_ARB_texture_rectangle : enable + +void main() +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = gl_Vertex; +} diff --git a/example_color/example_color.sln b/example_color/example_color.sln new file mode 100644 index 0000000..9e65af3 --- /dev/null +++ b/example_color/example_color.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_color", "example_color.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openframeworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openframeworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.ActiveCfg = Debug|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|Win32.Build.0 = Debug|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.ActiveCfg = Release|Win32 + {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|Win32.Build.0 = Release|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.ActiveCfg = Debug|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|Win32.Build.0 = Debug|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.ActiveCfg = Release|Win32 + {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/example_color/example_color.v11.suo b/example_color/example_color.v11.suo new file mode 100644 index 0000000..997ba5f Binary files /dev/null and b/example_color/example_color.v11.suo differ diff --git a/example_color/example_color.vcxproj b/example_color/example_color.vcxproj new file mode 100644 index 0000000..cf28733 --- /dev/null +++ b/example_color/example_color.vcxproj @@ -0,0 +1,115 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {7FD42DF7-442E-479A-BA76-D0022F99702A} + Win32Proj + example_color + + + + Application + Unicode + v110 + + + Application + Unicode + true + v110 + + + + + + + + + + + + + bin\ + obj\$(Configuration)\ + $(ProjectName)_debug + true + true + + + bin\ + obj\$(Configuration)\ + false + + + + Disabled + true + EnableFastChecks + %(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + EditAndContinue + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGpuParticles\libs;..\..\..\addons\ofxGpuParticles\src + CompileAsCpp + + + true + Console + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + false + %(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + %(AdditionalIncludeDirectories);..\..\..\addons\ofxGpuParticles\libs;..\..\..\addons\ofxGpuParticles\src + CompileAsCpp + + + false + false + Console + true + true + false + %(AdditionalDependencies) + %(AdditionalLibraryDirectories) + + + + + + + + + + + + + + + + + {5837595d-aca9-485c-8e76-729040ce4b0b} + + + + + /D_DEBUG %(AdditionalOptions) + + + + diff --git a/example_color/example_color.vcxproj.filters b/example_color/example_color.vcxproj.filters new file mode 100644 index 0000000..7924c36 --- /dev/null +++ b/example_color/example_color.vcxproj.filters @@ -0,0 +1,48 @@ + + + + + src + + + src + + + addons\ofxGpuParticles\src + + + addons\ofxGpuParticles\src + + + + + {d8376475-7454-4a24-b08a-aac121d3ad6f} + + + {71834F65-F3A9-211E-73B8-DC85} + + + {B7A3A1F0-9289-7823-A037-9F40} + + + {4DDEE1DE-620F-6E3F-FC5F-A25F} + + + + + src + + + addons\ofxGpuParticles\src + + + addons\ofxGpuParticles\src + + + addons\ofxGpuParticles\src + + + + + + diff --git a/example_color/example_color.vcxproj.user b/example_color/example_color.vcxproj.user new file mode 100644 index 0000000..bedf919 --- /dev/null +++ b/example_color/example_color.vcxproj.user @@ -0,0 +1,11 @@ + + + + $(ProjectDir)/bin + WindowsLocalDebugger + + + $(ProjectDir)/bin + WindowsLocalDebugger + + \ No newline at end of file diff --git a/example_color/icon.rc b/example_color/icon.rc new file mode 100644 index 0000000..97f3db2 --- /dev/null +++ b/example_color/icon.rc @@ -0,0 +1,8 @@ +// Icon Resource Definition +#define MAIN_ICON 102 + +#if defined(_DEBUG) +MAIN_ICON ICON "..\..\..\libs\openFrameworksCompiled\project\vs\icon_debug.ico" +#else +MAIN_ICON ICON "..\..\..\libs\openFrameworksCompiled\project\vs\icon.ico" +#endif diff --git a/example_color/obj/Debug/CL.read.1.tlog b/example_color/obj/Debug/CL.read.1.tlog new file mode 100644 index 0000000..d89fd8e Binary files /dev/null and b/example_color/obj/Debug/CL.read.1.tlog differ diff --git a/example_color/obj/Debug/CL.write.1.tlog b/example_color/obj/Debug/CL.write.1.tlog new file mode 100644 index 0000000..4415022 Binary files /dev/null and b/example_color/obj/Debug/CL.write.1.tlog differ diff --git a/example_color/obj/Debug/GpuParticles.obj b/example_color/obj/Debug/GpuParticles.obj new file mode 100644 index 0000000..3eca13b Binary files /dev/null and b/example_color/obj/Debug/GpuParticles.obj differ diff --git a/example_color/obj/Debug/cl.command.1.tlog b/example_color/obj/Debug/cl.command.1.tlog new file mode 100644 index 0000000..606f234 Binary files /dev/null and b/example_color/obj/Debug/cl.command.1.tlog differ diff --git a/example_color/obj/Debug/example_color.lastbuildstate b/example_color/obj/Debug/example_color.lastbuildstate new file mode 100644 index 0000000..6704305 --- /dev/null +++ b/example_color/obj/Debug/example_color.lastbuildstate @@ -0,0 +1,2 @@ +#v4.0:v110:false +Debug|Win32|C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\| diff --git a/example_color/obj/Debug/example_color.log b/example_color/obj/Debug/example_color.log new file mode 100644 index 0000000..7553cc9 --- /dev/null +++ b/example_color/obj/Debug/example_color.log @@ -0,0 +1,55 @@ +Build started 5/18/2015 5:01:57 PM. + 1>Project "C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\example_color.vcxproj" on node 2 (Build target(s)). + 1>ClCompile: + C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /I..\..\..\libs\openFrameworks /I..\..\..\libs\openFrameworks\graphics /I..\..\..\libs\openFrameworks\app /I..\..\..\libs\openFrameworks\sound /I..\..\..\libs\openFrameworks\utils /I..\..\..\libs\openFrameworks\communication /I..\..\..\libs\openFrameworks\video /I..\..\..\libs\openFrameworks\types /I..\..\..\libs\openFrameworks\math /I..\..\..\libs\openFrameworks\3d /I..\..\..\libs\openFrameworks\gl /I..\..\..\libs\openFrameworks\events /I..\..\..\libs\glut\include /I..\..\..\libs\rtAudio\include /I..\..\..\libs\quicktime\include /I..\..\..\libs\freetype\include /I..\..\..\libs\freetype\include\freetype2 /I..\..\..\libs\freeImage\include /I..\..\..\libs\fmodex\include /I..\..\..\libs\videoInput\include /I..\..\..\libs\glew\include\ /I..\..\..\libs\glu\include /I..\..\..\libs\tess2\include /I..\..\..\libs\cairo\include\cairo /I..\..\..\libs\poco\include /I..\..\..\libs\glfw\include /I..\..\..\libs\openssl\include /I..\..\..\addons /I..\..\..\addons\ofxGpuParticles\libs /I..\..\..\addons\ofxGpuParticles\src /ZI /nologo /W3 /WX- /Od /Oy- /D WIN32 /D _DEBUG /D _CONSOLE /D POCO_STATIC /D CAIRO_WIN32_STATIC_BUILD /D DISABLE_SOME_FLOATING_POINT /D _UNICODE /D UNICODE /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"obj\Debug\\" /Fd"obj\Debug\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt src\ofApp.cpp + ofApp.cpp + 1>c:\users\chris\documents\projects\of_v0.8.4_vs_release\libs\poco\include\poco\streamconverter.h(126): warning C4250: 'Poco::InputStreamConverter' : inherits 'std::basic_istream<_Elem,_Traits>::std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' via dominance + with + [ + _Elem=char, + _Traits=std::char_traits + ] + c:\program files (x86)\microsoft visual studio 11.0\vc\include\istream(74) : see declaration of 'std::basic_istream<_Elem,_Traits>::_Add_vtordisp1' + with + [ + _Elem=char, + _Traits=std::char_traits + ] + 1>c:\users\chris\documents\projects\of_v0.8.4_vs_release\libs\poco\include\poco\streamconverter.h(144): warning C4250: 'Poco::OutputStreamConverter' : inherits 'std::basic_ostream<_Elem,_Traits>::std::basic_ostream<_Elem,_Traits>::_Add_vtordisp2' via dominance + with + [ + _Elem=char, + _Traits=std::char_traits + ] + c:\program files (x86)\microsoft visual studio 11.0\vc\include\ostream(90) : see declaration of 'std::basic_ostream<_Elem,_Traits>::_Add_vtordisp2' + with + [ + _Elem=char, + _Traits=std::char_traits + ] + Link: + C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\link.exe /ERRORREPORT:PROMPT /OUT:"bin\example_color_debug.exe" /INCREMENTAL /NOLOGO /LIBPATH:..\..\..\libs\glut\lib\vs /LIBPATH:..\..\..\libs\glfw\lib\vs /LIBPATH:..\..\..\libs\rtAudio\lib\vs /LIBPATH:..\..\..\libs\FreeImage\lib\vs /LIBPATH:..\..\..\libs\freetype\lib\vs /LIBPATH:..\..\..\libs\quicktime\lib\vs /LIBPATH:..\..\..\libs\fmodex\lib\vs /LIBPATH:..\..\..\libs\videoInput\lib\vs /LIBPATH:..\..\..\libs\cairo\lib\vs /LIBPATH:..\..\..\libs\glew\lib\vs /LIBPATH:..\..\..\libs\glu\lib\vs /LIBPATH:..\..\..\libs\openssl\lib\vs /LIBPATH:..\..\..\libs\Poco\lib\vs /LIBPATH:..\..\..\libs\tess2\lib\vs "cairo-static.lib" "pixman-1.lib" msimg32.lib OpenGL32.lib GLu32.lib kernel32.lib setupapi.lib Vfw32.lib comctl32.lib glut32.lib rtAudioD.lib videoInputD.lib libfreetype.lib FreeImage.lib qtmlClient.lib dsound.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib glew32s.lib fmodex_vc.lib glu32.lib ssleay32MD.lib libeay32MD.lib crypt32.lib PocoFoundationmdd.lib PocoNetmdd.lib PocoUtilmdd.lib PocoXMLmdd.lib Ws2_32.lib tess2.lib glfw3.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /NODEFAULTLIB:PocoFoundationmdd.lib /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt /NODEFAULTLIB:libcmt /NODEFAULTLIB:LIBC /NODEFAULTLIB:LIBCMTD /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /DEBUG /PDB:"bin\example_color_debug.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE:NO /NXCOMPAT /IMPLIB:"bin\example_color_debug.lib" /MACHINE:X86 /SAFESEH obj\Debug\icon.res + obj\Debug\main.obj + obj\Debug\ofApp.obj + obj\Debug\GpuParticles.obj + obj\Debug\GpuParticles.obj + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\libs\openFrameworksCompiled\lib\vs\openframeworksLib_debug.lib + example_color.vcxproj -> C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.exe + PostBuildEvent: + xcopy /e /i /y "C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\*.dll" "C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin" + :VCEnd + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\Assimp32.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\fmodex.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\fmodexL.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\FreeImage.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\FreeType-6.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\glut32.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\libeay32.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\ssleay32.dll + C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\..\..\..\export\vs\Zlib.dll + 9 File(s) copied + 1>Done Building Project "C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\example_color.vcxproj" (Build target(s)). + +Build succeeded. + +Time Elapsed 00:00:03.08 diff --git a/example_color/obj/Debug/example_color.vcxprojResolveAssemblyReference.cache b/example_color/obj/Debug/example_color.vcxprojResolveAssemblyReference.cache new file mode 100644 index 0000000..44f5d5e Binary files /dev/null and b/example_color/obj/Debug/example_color.vcxprojResolveAssemblyReference.cache differ diff --git a/example_color/obj/Debug/example_color.write.1.tlog b/example_color/obj/Debug/example_color.write.1.tlog new file mode 100644 index 0000000..abaa95e --- /dev/null +++ b/example_color/obj/Debug/example_color.write.1.tlog @@ -0,0 +1,10 @@ +^C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\example_color.vcxproj +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.lib +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.lib +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.exp +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.exp +^C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\example_color.vcxproj +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.lib +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.lib +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.exp +C:\Users\chris\Documents\Projects\of_v0.8.4_vs_release\addons\ofxGpuParticles\example_color\bin\example_color_debug.exp diff --git a/example_color/obj/Debug/icon.res b/example_color/obj/Debug/icon.res new file mode 100644 index 0000000..1c17250 Binary files /dev/null and b/example_color/obj/Debug/icon.res differ diff --git a/example_color/obj/Debug/link-cvtres.read.1.tlog b/example_color/obj/Debug/link-cvtres.read.1.tlog new file mode 100644 index 0000000..46b134b --- /dev/null +++ b/example_color/obj/Debug/link-cvtres.read.1.tlog @@ -0,0 +1 @@ +ÿþ \ No newline at end of file diff --git a/example_color/obj/Debug/link-cvtres.write.1.tlog b/example_color/obj/Debug/link-cvtres.write.1.tlog new file mode 100644 index 0000000..46b134b --- /dev/null +++ b/example_color/obj/Debug/link-cvtres.write.1.tlog @@ -0,0 +1 @@ +ÿþ \ No newline at end of file diff --git a/example_color/obj/Debug/link-rc.read.1.tlog b/example_color/obj/Debug/link-rc.read.1.tlog new file mode 100644 index 0000000..46b134b --- /dev/null +++ b/example_color/obj/Debug/link-rc.read.1.tlog @@ -0,0 +1 @@ +ÿþ \ No newline at end of file diff --git a/example_color/obj/Debug/link-rc.write.1.tlog b/example_color/obj/Debug/link-rc.write.1.tlog new file mode 100644 index 0000000..46b134b --- /dev/null +++ b/example_color/obj/Debug/link-rc.write.1.tlog @@ -0,0 +1 @@ +ÿþ \ No newline at end of file diff --git a/example_color/obj/Debug/link.command.1.tlog b/example_color/obj/Debug/link.command.1.tlog new file mode 100644 index 0000000..1869f1f Binary files /dev/null and b/example_color/obj/Debug/link.command.1.tlog differ diff --git a/example_color/obj/Debug/link.read.1.tlog b/example_color/obj/Debug/link.read.1.tlog new file mode 100644 index 0000000..3754487 Binary files /dev/null and b/example_color/obj/Debug/link.read.1.tlog differ diff --git a/example_color/obj/Debug/link.write.1.tlog b/example_color/obj/Debug/link.write.1.tlog new file mode 100644 index 0000000..1ac1314 Binary files /dev/null and b/example_color/obj/Debug/link.write.1.tlog differ diff --git a/example_color/obj/Debug/main.obj b/example_color/obj/Debug/main.obj new file mode 100644 index 0000000..e8c3968 Binary files /dev/null and b/example_color/obj/Debug/main.obj differ diff --git a/example_color/obj/Debug/ofApp.obj b/example_color/obj/Debug/ofApp.obj new file mode 100644 index 0000000..72a8096 Binary files /dev/null and b/example_color/obj/Debug/ofApp.obj differ diff --git a/example_color/obj/Debug/rc.command.1.tlog b/example_color/obj/Debug/rc.command.1.tlog new file mode 100644 index 0000000..58cdae8 Binary files /dev/null and b/example_color/obj/Debug/rc.command.1.tlog differ diff --git a/example_color/obj/Debug/rc.read.1.tlog b/example_color/obj/Debug/rc.read.1.tlog new file mode 100644 index 0000000..e0770c6 Binary files /dev/null and b/example_color/obj/Debug/rc.read.1.tlog differ diff --git a/example_color/obj/Debug/rc.write.1.tlog b/example_color/obj/Debug/rc.write.1.tlog new file mode 100644 index 0000000..1d97879 Binary files /dev/null and b/example_color/obj/Debug/rc.write.1.tlog differ diff --git a/example_color/obj/Debug/vc110.idb b/example_color/obj/Debug/vc110.idb new file mode 100644 index 0000000..7c0e5a6 Binary files /dev/null and b/example_color/obj/Debug/vc110.idb differ diff --git a/example_color/obj/Debug/vc110.pdb b/example_color/obj/Debug/vc110.pdb new file mode 100644 index 0000000..7cbefa1 Binary files /dev/null and b/example_color/obj/Debug/vc110.pdb differ diff --git a/example_color/src/main.cpp b/example_color/src/main.cpp new file mode 100644 index 0000000..e57370b --- /dev/null +++ b/example_color/src/main.cpp @@ -0,0 +1,13 @@ +#include "ofMain.h" +#include "ofApp.h" + +//======================================================================== +int main( ){ + ofSetupOpenGL(1024,768,OF_WINDOW); // <-------- setup the GL context + + // this kicks off the running of my app + // can be OF_WINDOW or OF_FULLSCREEN + // pass in width and height too: + ofRunApp(new ofApp()); + +} diff --git a/example_color/src/ofApp.cpp b/example_color/src/ofApp.cpp new file mode 100644 index 0000000..1116d64 --- /dev/null +++ b/example_color/src/ofApp.cpp @@ -0,0 +1,115 @@ +#include "ofApp.h" + +//-------------------------------------------------------------- +void ofApp::setup() + { + ofBackground(0); + ofSetFrameRate(60); + + unsigned w = 1000; + unsigned h = 1000; + + float* particlePosns = new float[w * h * 4]; + ofColor* colors = new ofColor[w * h]; + + ofImage image; + image.loadImage("colors.png"); + + for (unsigned y = 0; y < image.getHeight(); ++y) + { + for (unsigned x = 0; x < image.getWidth(); ++x) + { + ofColor cur = image.getColor(x, y); + if (cur.a > 0){ + cur.a = 255; + unsigned idx = y * w + x; + + particlePosns[idx * 4] = 400.f * x / (float)w - 200.f; + particlePosns[idx * 4 + 1] = 400.f * y / (float)h - 200.f; + particlePosns[idx * 4 + 2] = 0.f; + particlePosns[idx * 4 + 3] = 0.f; + + colors[idx] = cur; + } + } + } + particles.init(w, h, colors); + particles.loadDataTexture(ofxGpuParticles::POSITION, particlePosns); + delete[] particlePosns; + delete[] colors; + + // initial velocities + particles.zeroDataTexture(ofxGpuParticles::VELOCITY); + + // listen for update event to set additonal update uniforms + ofAddListener(particles.updateEvent, this, &ofApp::onParticlesUpdate); +} + +//-------------------------------------------------------------- +void ofApp::update() +{ + ofSetWindowTitle(ofToString(ofGetFrameRate(), 2)); + particles.update(); +} + +// set any update uniforms in this function +void ofApp::onParticlesUpdate(ofShader& shader) +{ + ofVec3f mouse(ofGetMouseX() - .5f * ofGetWidth(), .5f * ofGetHeight() - ofGetMouseY() , 0.f); + shader.setUniform3fv("mouse", mouse.getPtr()); + shader.setUniform1f("elapsed", ofGetLastFrameTime()); + shader.setUniform1f("radiusSquared", 200.f * 200.f); +} + +//-------------------------------------------------------------- +void ofApp::draw() +{ + cam.begin(); + particles.draw(); + cam.end(); +} + +//-------------------------------------------------------------- +void ofApp::keyPressed(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::keyReleased(int key){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseMoved(int x, int y ){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseDragged(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mousePressed(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::mouseReleased(int x, int y, int button){ + +} + +//-------------------------------------------------------------- +void ofApp::windowResized(int w, int h){ + +} + +//-------------------------------------------------------------- +void ofApp::gotMessage(ofMessage msg){ + +} + +//-------------------------------------------------------------- +void ofApp::dragEvent(ofDragInfo dragInfo){ + +} \ No newline at end of file diff --git a/example_color/src/ofApp.h b/example_color/src/ofApp.h new file mode 100644 index 0000000..8023f60 --- /dev/null +++ b/example_color/src/ofApp.h @@ -0,0 +1,29 @@ +#pragma once + +#include "ofMain.h" +#include "ofxGpuParticles.h" + +class ofApp : public ofBaseApp +{ +public: + void setup(); + void update(); + void draw(); + + void keyPressed (int key); + void keyReleased(int key); + void mouseMoved(int x, int y ); + void mouseDragged(int x, int y, int button); + void mousePressed(int x, int y, int button); + void mouseReleased(int x, int y, int button); + void windowResized(int w, int h); + void dragEvent(ofDragInfo dragInfo); + void gotMessage(ofMessage msg); + +private: + // set any update uniforms in this function + void onParticlesUpdate(ofShader& shader); + + ofxGpuParticles particles; + ofEasyCam cam; +}; diff --git a/src/GpuParticles.cpp b/src/GpuParticles.cpp index a00e53c..b0a4043 100644 --- a/src/GpuParticles.cpp +++ b/src/GpuParticles.cpp @@ -41,7 +41,7 @@ namespace itg { } - void GpuParticles::init(unsigned width, unsigned height, ofPrimitiveMode primitive, bool loadShaders, unsigned numDataTextures) + void GpuParticles::init(unsigned width, unsigned height, ofColor *colors, ofPrimitiveMode primitive, bool loadShaders, unsigned numDataTextures) { this->width = width; this->height = height; @@ -71,6 +71,8 @@ namespace itg { mesh.addVertex(ofVec3f(200.f * x / (float)width - 100.f, 200.f * y / (float)height - 100.f, -500.f)); mesh.addTexCoord(ofVec2f(x, y)); + if (colors != NULL) + mesh.addColor(colors[y * width + x]); } } mesh.setMode(primitive); @@ -215,4 +217,4 @@ namespace itg } else ofLogError() << "Could not load particle data from " << ofToDataPath(fileName, true); } -} \ No newline at end of file +} diff --git a/src/GpuParticles.cpp~ b/src/GpuParticles.cpp~ new file mode 100644 index 0000000..a00e53c --- /dev/null +++ b/src/GpuParticles.cpp~ @@ -0,0 +1,218 @@ +/* + * GpuParticles.cpp + * + * Copyright (c) 2013, Neil Mendoza, http://www.neilmendoza.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Neil Mendoza nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +#include "GpuParticles.h" + +namespace itg +{ + const string GpuParticles::UNIFORM_PREFIX = "particles"; + const string GpuParticles::UPDATE_SHADER_NAME = "update"; + const string GpuParticles::DRAW_SHADER_NAME = "draw"; + + GpuParticles::GpuParticles() : currentReadFbo(0), textureLocation(0) + { + } + + void GpuParticles::init(unsigned width, unsigned height, ofPrimitiveMode primitive, bool loadShaders, unsigned numDataTextures) + { + this->width = width; + this->height = height; + numFloats = width * height * FLOATS_PER_TEXEL; + + // fbos + ofFbo::Settings s; + s.internalformat = GL_RGBA32F_ARB; + s.textureTarget = GL_TEXTURE_RECTANGLE_ARB; + s.minFilter = GL_NEAREST; + s.maxFilter = GL_NEAREST; + s.wrapModeHorizontal = GL_CLAMP; + s.wrapModeVertical = GL_CLAMP; + s.width = width; + s.height = height; + s.numColorbuffers = numDataTextures; + for (unsigned i = 0; i < 2; ++i) + { + fbos[i].allocate(s); + } + + // mesh + mesh.clear(); + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + mesh.addVertex(ofVec3f(200.f * x / (float)width - 100.f, 200.f * y / (float)height - 100.f, -500.f)); + mesh.addTexCoord(ofVec2f(x, y)); + } + } + mesh.setMode(primitive); + + // shaders + if (loadShaders) + { + updateShader.load(UPDATE_SHADER_NAME); + drawShader.load(DRAW_SHADER_NAME); + } + } + + void GpuParticles::update() + { + fbos[1 - currentReadFbo].begin(false); + glPushAttrib(GL_ENABLE_BIT); + // we set up no camera model and ignore the modelview and projection matrices + // in the vertex shader, we make a viewport large enought to ensure the shader + // is executed for each pixel + glViewport(0, 0, width, height); + glDisable(GL_BLEND); + ofSetColor(255, 255, 255); + fbos[1 - currentReadFbo].activateAllDrawBuffers(); + + updateShader.begin(); + ofNotifyEvent(updateEvent, updateShader, this); + setUniforms(updateShader); + texturedQuad(-1, -1, 2, 2, width, height); + updateShader.end(); + glPopAttrib(); + + fbos[1 - currentReadFbo].end(); + + currentReadFbo = 1 - currentReadFbo; + } + + void GpuParticles::draw() + { + drawShader.begin(); + ofNotifyEvent(drawEvent, drawShader, this); + setUniforms(drawShader); + mesh.draw(); + drawShader.end(); + } + + void GpuParticles::setUniforms(ofShader& shader) + { + for (unsigned i = 0; i < fbos[currentReadFbo].getNumTextures(); ++i) + { + ostringstream oss; + oss << UNIFORM_PREFIX << ofToString(i); + shader.setUniformTexture(oss.str().c_str(), fbos[currentReadFbo].getTextureReference(i), i + textureLocation); + } + } + + void GpuParticles::loadDataTexture(unsigned idx, float* data, + unsigned x, unsigned y, unsigned width, unsigned height) + { + if (idx < fbos[currentReadFbo].getNumTextures()) + { + if (!width) width = this->width; + if (!height) height = this->height; + fbos[currentReadFbo].getTextureReference(idx).bind(); + glTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, x, y, width, height, GL_RGBA, GL_FLOAT, data); + fbos[currentReadFbo].getTextureReference(idx).unbind(); + } + else ofLogError() << "Trying to load data from array into non-existent buffer."; + } + + void GpuParticles::zeroDataTexture(unsigned idx, + unsigned x, unsigned y, unsigned width, unsigned height) + { + if (!width) width = this->width; + if (!height) height = this->height; + float* zeroes = new float[width * height * FLOATS_PER_TEXEL]; + memset(zeroes, 0, sizeof(float) * width * height * FLOATS_PER_TEXEL); + loadDataTexture(idx, zeroes, x, y, width, height); + delete[] zeroes; + } + + void GpuParticles::texturedQuad(float x, float y, float width, float height, float s, float t) + { + // TODO: change to triangle fan/strip + glBegin(GL_QUADS); + glTexCoord2f(0, 0); + glVertex3f(x, y, 0); + + glTexCoord2f(s, 0); + glVertex3f(x + width, y, 0); + + glTexCoord2f(s, t); + glVertex3f(x + width, y + height, 0); + + glTexCoord2f(0, t); + glVertex3f(x, y + height, 0); + glEnd(); + } + + void GpuParticles::save(const string& fileName) + { + ofstream fileStream(ofToDataPath(fileName, true).c_str()); + if (fileStream.is_open()) + { + for (unsigned i = 0; i < fbos[currentReadFbo].getNumTextures(); ++i) + { + if (i) fileStream << "|"; + ofFloatPixels pixels; + fbos[currentReadFbo].getTextureReference(i).readToPixels(pixels); + for (unsigned j = 0; j < pixels.size(); ++j) + { + if (j) fileStream << ","; + fileStream << pixels[j]; + } + } + fileStream.close(); + } + else ofLogError() << "Could not save particle data to " << ofToDataPath(fileName, true); + } + + void GpuParticles::load(const string& fileName) + { + ifstream fileStream(ofToDataPath(fileName, true).c_str()); + if (fileStream.is_open()) + { + string data((istreambuf_iterator(fileStream)), std::istreambuf_iterator()); + vector textureData = ofSplitString(data, "|"); + for (unsigned i = 0; i < textureData.size(); ++i) + { + if (i < fbos[currentReadFbo].getNumTextures()) + { + vector floatsAsText = ofSplitString(textureData[i], ","); + vector floats(floatsAsText.size(), 0); + for (unsigned j = 0; j < floats.size(); ++j) + { + floats[j] = atof(floatsAsText[j].c_str()); + } + loadDataTexture(i, &floats[0]); + } + else ofLogError() << "Trying to load data from file into non-existent buffer."; + } + fileStream.close(); + } + else ofLogError() << "Could not load particle data from " << ofToDataPath(fileName, true); + } +} \ No newline at end of file diff --git a/src/GpuParticles.h b/src/GpuParticles.h index c266744..4983cc0 100644 --- a/src/GpuParticles.h +++ b/src/GpuParticles.h @@ -56,7 +56,7 @@ namespace itg GpuParticles(); - void init(unsigned width, unsigned height, + void init(unsigned width, unsigned height, ofColor *colors = NULL, ofPrimitiveMode primitive = OF_PRIMITIVE_POINTS, bool loadShaders = true, unsigned numDataTextures = 2); void update(); void draw(); diff --git a/src/GpuParticles.h~ b/src/GpuParticles.h~ new file mode 100644 index 0000000..4983cc0 --- /dev/null +++ b/src/GpuParticles.h~ @@ -0,0 +1,99 @@ +/* + * GpuParticles.h + * + * Copyright (c) 2013, Neil Mendoza, http://www.neilmendoza.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Neil Mendoza nor the names of its contributors may be used + * to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ +#pragma once + +#include "ofMain.h" + +namespace itg +{ + /** + * For now, only uses RGBA and TEXTURE_RECTANGLE to make usage simpler + */ + class GpuParticles + { + public: + static const string UNIFORM_PREFIX; + static const string UPDATE_SHADER_NAME; + static const string DRAW_SHADER_NAME; + static const unsigned FLOATS_PER_TEXEL = 4; + + // you don't have to use these but makes + // code more readable + enum DataTextureIndex + { + POSITION, + VELOCITY + }; + + GpuParticles(); + + void init(unsigned width, unsigned height, ofColor *colors = NULL, + ofPrimitiveMode primitive = OF_PRIMITIVE_POINTS, bool loadShaders = true, unsigned numDataTextures = 2); + void update(); + void draw(); + + void loadDataTexture(unsigned idx, float* data, + unsigned x = 0, unsigned y = 0, unsigned width = 0, unsigned height = 0); + void zeroDataTexture(unsigned idx, + unsigned x = 0, unsigned y = 0, unsigned width = 0, unsigned height = 0); + + unsigned getWidth() const { return width; } + unsigned getHeight() const { return height; } + unsigned getNumFloats() const { return numFloats; } + + void setTextureLocation(unsigned textureLocation) { this->textureLocation = textureLocation; } + + // listen to these events to set custom uniforms + ofEvent updateEvent; + ofEvent drawEvent; + + ofVboMesh& getMeshRef() { return mesh; } + + // advanced + ofShader& getUpdateShaderRef() { return updateShader; } + ofShader& getDrawShaderRef() { return drawShader; } + + void save(const string& fileName); + void load(const string& fileName); + + private: + void texturedQuad(float x, float y, float width, float height, float s, float t); + void setUniforms(ofShader& shader); + + ofFbo fbos[2]; + ofVboMesh mesh; + ofShader updateShader, drawShader; + unsigned currentReadFbo; + unsigned textureLocation; + unsigned width, height, numFloats; + }; +}