diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..102fdd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +.svn +.hg +.cvs + +# osx +*.app +*.mode1v3 +*.pbxuser +.DS_Store +build +xcuserdata +DerivedData +project.xcworkspace diff --git a/example/.gitignore b/example/.gitignore new file mode 100644 index 0000000..102fdd7 --- /dev/null +++ b/example/.gitignore @@ -0,0 +1,13 @@ +.svn +.hg +.cvs + +# osx +*.app +*.mode1v3 +*.pbxuser +.DS_Store +build +xcuserdata +DerivedData +project.xcworkspace diff --git a/example/Project.xcconfig b/example/Project.xcconfig new file mode 100644 index 0000000..c10b9e5 --- /dev/null +++ b/example/Project.xcconfig @@ -0,0 +1,9 @@ +//THE PATH TO THE ROOT OF OUR OF PATH RELATIVE TO THIS PROJECT. +//THIS NEEDS TO BE DEFINED BEFORE CoreOF.xcconfig IS INCLUDED +OF_PATH = ../../.. + +//THIS HAS ALL THE HEADER AND LIBS FOR OF CORE +#include "../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig" + +OTHER_LDFLAGS = $(OF_CORE_LIBS) +HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) diff --git a/example/example.xcodeproj/project.pbxproj b/example/example.xcodeproj/project.pbxproj new file mode 100644 index 0000000..2c02d54 --- /dev/null +++ b/example/example.xcodeproj/project.pbxproj @@ -0,0 +1,583 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 602FB89F163AA4EE00127C41 /* ofxInteractivePrimitives.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 602FB89D163AA4EE00127C41 /* ofxInteractivePrimitives.cpp */; }; + BBAB23CB13894F3D00AA2426 /* GLUT.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; }; + E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; }; + E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9710E8CC7DD009D7055 /* AGL.framework */; }; + E45BE97C0E8CC7DD009D7055 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9720E8CC7DD009D7055 /* ApplicationServices.framework */; }; + E45BE97D0E8CC7DD009D7055 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9730E8CC7DD009D7055 /* AudioToolbox.framework */; }; + E45BE97E0E8CC7DD009D7055 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9740E8CC7DD009D7055 /* Carbon.framework */; }; + E45BE97F0E8CC7DD009D7055 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9750E8CC7DD009D7055 /* CoreAudio.framework */; }; + E45BE9800E8CC7DD009D7055 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9760E8CC7DD009D7055 /* CoreFoundation.framework */; }; + E45BE9810E8CC7DD009D7055 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9770E8CC7DD009D7055 /* CoreServices.framework */; }; + E45BE9830E8CC7DD009D7055 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE9790E8CC7DD009D7055 /* OpenGL.framework */; }; + E45BE9840E8CC7DD009D7055 /* QuickTime.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */; }; + E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1D0A3A1BDC003C02F2 /* main.cpp */; }; + E4B69E210A3A1BDC003C02F2 /* testApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */; }; + E4C2424710CC5A17004149E2 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424410CC5A17004149E2 /* AppKit.framework */; }; + E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424510CC5A17004149E2 /* Cocoa.framework */; }; + E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E4C2424610CC5A17004149E2 /* IOKit.framework */; }; + E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BBAB23BE13894E4700AA2426 /* GLUT.framework */; }; + E7E077E515D3B63C0020DFD4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7E077E415D3B63C0020DFD4 /* CoreVideo.framework */; }; + E7E077E815D3B6510020DFD4 /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7E077E715D3B6510020DFD4 /* QTKit.framework */; }; + E7F985F815E0DEA3003869B5 /* Accelerate.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7F985F515E0DE99003869B5 /* Accelerate.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXBuildRule section */ + 60B0F2F7163A78C80081B1DF /* PBXBuildRule */ = { + isa = PBXBuildRule; + compilerSpec = com.apple.compilers.proxy.script; + fileType = pattern.proxy; + isEditable = 1; + outputFiles = ( + ); + }; +/* End PBXBuildRule section */ + +/* Begin PBXContainerItemProxy section */ + E4328147138ABC890047C5CB /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = E4B27C1510CBEB8E00536013; + remoteInfo = openFrameworks; + }; + E4EEB9AB138B136A00A80321 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = E4B27C1410CBEB8E00536013; + remoteInfo = openFrameworks; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + E4C2427710CC5ABF004149E2 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + BBAB23CB13894F3D00AA2426 /* GLUT.framework in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 602FB89D163AA4EE00127C41 /* ofxInteractivePrimitives.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ofxInteractivePrimitives.cpp; path = ../src/ofxInteractivePrimitives.cpp; sourceTree = ""; }; + 602FB89E163AA4EE00127C41 /* ofxInteractivePrimitives.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ofxInteractivePrimitives.h; path = ../src/ofxInteractivePrimitives.h; sourceTree = ""; }; + BBAB23BE13894E4700AA2426 /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = ../../../libs/glut/lib/osx/GLUT.framework; sourceTree = ""; }; + E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openFrameworksLib.xcodeproj; path = ../../../libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj; sourceTree = SOURCE_ROOT; }; + E45BE9710E8CC7DD009D7055 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = ""; }; + E45BE9720E8CC7DD009D7055 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = ""; }; + E45BE9730E8CC7DD009D7055 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = ""; }; + E45BE9740E8CC7DD009D7055 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = ""; }; + E45BE9750E8CC7DD009D7055 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = /System/Library/Frameworks/CoreAudio.framework; sourceTree = ""; }; + E45BE9760E8CC7DD009D7055 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = ""; }; + E45BE9770E8CC7DD009D7055 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = ""; }; + E45BE9790E8CC7DD009D7055 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = ""; }; + E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickTime.framework; path = /System/Library/Frameworks/QuickTime.framework; sourceTree = ""; }; + E4B69B5B0A3A1756003C02F2 /* exampleDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = exampleDebug.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E4B69E1D0A3A1BDC003C02F2 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = src/main.cpp; sourceTree = SOURCE_ROOT; }; + E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 30; name = testApp.cpp; path = src/testApp.cpp; sourceTree = SOURCE_ROOT; }; + E4B69E1F0A3A1BDC003C02F2 /* testApp.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = testApp.h; path = src/testApp.h; sourceTree = SOURCE_ROOT; }; + E4B6FCAD0C3E899E008CF71C /* openFrameworks-Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = "openFrameworks-Info.plist"; sourceTree = ""; }; + E4C2424410CC5A17004149E2 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = ""; }; + E4C2424510CC5A17004149E2 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; + E4C2424610CC5A17004149E2 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = ""; }; + E4EB691F138AFCF100A09F29 /* CoreOF.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = CoreOF.xcconfig; path = ../../../libs/openFrameworksCompiled/project/osx/CoreOF.xcconfig; sourceTree = SOURCE_ROOT; }; + E4EB6923138AFD0F00A09F29 /* Project.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Project.xcconfig; sourceTree = ""; }; + E7E077E415D3B63C0020DFD4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = ""; }; + E7E077E715D3B6510020DFD4 /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = ""; }; + E7F985F515E0DE99003869B5 /* Accelerate.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Accelerate.framework; path = /System/Library/Frameworks/Accelerate.framework; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E4B69B590A3A1756003C02F2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E7F985F815E0DEA3003869B5 /* Accelerate.framework in Frameworks */, + E7E077E815D3B6510020DFD4 /* QTKit.framework in Frameworks */, + E4EB6799138ADC1D00A09F29 /* GLUT.framework in Frameworks */, + E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */, + E45BE97B0E8CC7DD009D7055 /* AGL.framework in Frameworks */, + E45BE97C0E8CC7DD009D7055 /* ApplicationServices.framework in Frameworks */, + E45BE97D0E8CC7DD009D7055 /* AudioToolbox.framework in Frameworks */, + E45BE97E0E8CC7DD009D7055 /* Carbon.framework in Frameworks */, + E45BE97F0E8CC7DD009D7055 /* CoreAudio.framework in Frameworks */, + E45BE9800E8CC7DD009D7055 /* CoreFoundation.framework in Frameworks */, + E45BE9810E8CC7DD009D7055 /* CoreServices.framework in Frameworks */, + E45BE9830E8CC7DD009D7055 /* OpenGL.framework in Frameworks */, + E45BE9840E8CC7DD009D7055 /* QuickTime.framework in Frameworks */, + E4C2424710CC5A17004149E2 /* AppKit.framework in Frameworks */, + E4C2424810CC5A17004149E2 /* Cocoa.framework in Frameworks */, + E4C2424910CC5A17004149E2 /* IOKit.framework in Frameworks */, + E7E077E515D3B63C0020DFD4 /* CoreVideo.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 602FB89C163AA4D900127C41 /* ofxInteractivePrimitives */ = { + isa = PBXGroup; + children = ( + 602FB89D163AA4EE00127C41 /* ofxInteractivePrimitives.cpp */, + 602FB89E163AA4EE00127C41 /* ofxInteractivePrimitives.h */, + ); + name = ofxInteractivePrimitives; + sourceTree = ""; + }; + BB4B014C10F69532006C3DED /* addons */ = { + isa = PBXGroup; + children = ( + 602FB89C163AA4D900127C41 /* ofxInteractivePrimitives */, + ); + name = addons; + sourceTree = ""; + }; + BBAB23C913894ECA00AA2426 /* system frameworks */ = { + isa = PBXGroup; + children = ( + E7F985F515E0DE99003869B5 /* Accelerate.framework */, + E4C2424410CC5A17004149E2 /* AppKit.framework */, + E4C2424510CC5A17004149E2 /* Cocoa.framework */, + E4C2424610CC5A17004149E2 /* IOKit.framework */, + E45BE9710E8CC7DD009D7055 /* AGL.framework */, + E45BE9720E8CC7DD009D7055 /* ApplicationServices.framework */, + E45BE9730E8CC7DD009D7055 /* AudioToolbox.framework */, + E45BE9740E8CC7DD009D7055 /* Carbon.framework */, + E45BE9750E8CC7DD009D7055 /* CoreAudio.framework */, + E45BE9760E8CC7DD009D7055 /* CoreFoundation.framework */, + E45BE9770E8CC7DD009D7055 /* CoreServices.framework */, + E45BE9790E8CC7DD009D7055 /* OpenGL.framework */, + E45BE97A0E8CC7DD009D7055 /* QuickTime.framework */, + E7E077E415D3B63C0020DFD4 /* CoreVideo.framework */, + E7E077E715D3B6510020DFD4 /* QTKit.framework */, + ); + name = "system frameworks"; + sourceTree = ""; + }; + BBAB23CA13894EDB00AA2426 /* 3rd party frameworks */ = { + isa = PBXGroup; + children = ( + BBAB23BE13894E4700AA2426 /* GLUT.framework */, + ); + name = "3rd party frameworks"; + sourceTree = ""; + }; + E4328144138ABC890047C5CB /* Products */ = { + isa = PBXGroup; + children = ( + E4328148138ABC890047C5CB /* openFrameworksDebug.a */, + ); + name = Products; + sourceTree = ""; + }; + E45BE5980E8CC70C009D7055 /* frameworks */ = { + isa = PBXGroup; + children = ( + BBAB23CA13894EDB00AA2426 /* 3rd party frameworks */, + BBAB23C913894ECA00AA2426 /* system frameworks */, + ); + name = frameworks; + sourceTree = ""; + }; + E4B69B4A0A3A1720003C02F2 = { + isa = PBXGroup; + children = ( + E4B6FCAD0C3E899E008CF71C /* openFrameworks-Info.plist */, + E4EB6923138AFD0F00A09F29 /* Project.xcconfig */, + E4B69E1C0A3A1BDC003C02F2 /* src */, + E4EEC9E9138DF44700A80321 /* openFrameworks */, + BB4B014C10F69532006C3DED /* addons */, + E45BE5980E8CC70C009D7055 /* frameworks */, + E4B69B5B0A3A1756003C02F2 /* exampleDebug.app */, + ); + sourceTree = ""; + }; + E4B69E1C0A3A1BDC003C02F2 /* src */ = { + isa = PBXGroup; + children = ( + E4B69E1D0A3A1BDC003C02F2 /* main.cpp */, + E4B69E1E0A3A1BDC003C02F2 /* testApp.cpp */, + E4B69E1F0A3A1BDC003C02F2 /* testApp.h */, + ); + path = src; + sourceTree = SOURCE_ROOT; + }; + E4EEC9E9138DF44700A80321 /* openFrameworks */ = { + isa = PBXGroup; + children = ( + E4EB691F138AFCF100A09F29 /* CoreOF.xcconfig */, + E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */, + ); + name = openFrameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E4B69B5A0A3A1756003C02F2 /* example */ = { + isa = PBXNativeTarget; + buildConfigurationList = E4B69B5F0A3A1757003C02F2 /* Build configuration list for PBXNativeTarget "example" */; + buildPhases = ( + E4B69B580A3A1756003C02F2 /* Sources */, + E4B69B590A3A1756003C02F2 /* Frameworks */, + E4B6FFFD0C3F9AB9008CF71C /* ShellScript */, + E4C2427710CC5ABF004149E2 /* CopyFiles */, + ); + buildRules = ( + 60B0F2F7163A78C80081B1DF /* PBXBuildRule */, + ); + dependencies = ( + E4EEB9AC138B136A00A80321 /* PBXTargetDependency */, + ); + name = example; + productName = myOFApp; + productReference = E4B69B5B0A3A1756003C02F2 /* exampleDebug.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + E4B69B4C0A3A1720003C02F2 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "example" */; + compatibilityVersion = "Xcode 2.4"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = E4B69B4A0A3A1720003C02F2; + productRefGroup = E4B69B4A0A3A1720003C02F2; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = E4328144138ABC890047C5CB /* Products */; + ProjectRef = E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + E4B69B5A0A3A1756003C02F2 /* example */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + E4328148138ABC890047C5CB /* openFrameworksDebug.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = openFrameworksDebug.a; + remoteRef = E4328147138ABC890047C5CB /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXShellScriptBuildPhase section */ + E4B6FFFD0C3F9AB9008CF71C /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "cp -f ../../../libs/fmodex/lib/osx/libfmodex.dylib \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/libfmodex.dylib\"; install_name_tool -change ./libfmodex.dylib @executable_path/libfmodex.dylib \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/MacOS/$PRODUCT_NAME\";"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E4B69B580A3A1756003C02F2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E4B69E200A3A1BDC003C02F2 /* main.cpp in Sources */, + E4B69E210A3A1BDC003C02F2 /* testApp.cpp in Sources */, + 602FB89F163AA4EE00127C41 /* ofxInteractivePrimitives.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + E4EEB9AC138B136A00A80321 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = openFrameworks; + targetProxy = E4EEB9AB138B136A00A80321 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + E4B69B4E0A3A1720003C02F2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4EB6923138AFD0F00A09F29 /* Project.xcconfig */; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/bin/"; + COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; + GCC_AUTO_VECTORIZATION = YES; + GCC_ENABLE_SSE3_EXTENSIONS = YES; + GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + GCC_WARN_UNINITIALIZED_AUTOS = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + OTHER_CPLUSPLUSFLAGS = ( + "-D__MACOSX_CORE__", + "-lpthread", + "-mtune=native", + ); + }; + name = Debug; + }; + E4B69B4F0A3A1720003C02F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4EB6923138AFD0F00A09F29 /* Project.xcconfig */; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + CONFIGURATION_BUILD_DIR = "$(SRCROOT)/bin/"; + COPY_PHASE_STRIP = YES; + DEAD_CODE_STRIPPING = YES; + GCC_AUTO_VECTORIZATION = YES; + GCC_ENABLE_SSE3_EXTENSIONS = YES; + GCC_ENABLE_SUPPLEMENTAL_SSE3_INSTRUCTIONS = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OPTIMIZATION_LEVEL = 3; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_UNROLL_LOOPS = YES; + GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = YES; + GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + GCC_WARN_UNINITIALIZED_AUTOS = NO; + GCC_WARN_UNUSED_VALUE = NO; + GCC_WARN_UNUSED_VARIABLE = NO; + OTHER_CPLUSPLUSFLAGS = ( + "-D__MACOSX_CORE__", + "-lpthread", + "-mtune=native", + ); + }; + name = Release; + }; + E4B69B600A3A1757003C02F2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/glut/lib/osx\""; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_TUNING = NONE; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; + INFOPLIST_FILE = "openFrameworks-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_5)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_10)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_11)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_12)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_13)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_14)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_15)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_10)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_11)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_12)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_13)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_16)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_17)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_18)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_19)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_20)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_21)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_22)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_23)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_24)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_25)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_26)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_27)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_28)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_29)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_30)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_31)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_32)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_33)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_34)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_35)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_36)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_37)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_38)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_39)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_40)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_41)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_42)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_43)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_44)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_45)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_46)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_47)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_48)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_49)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_50)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_51)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_52)", + ); + PREBINDING = NO; + PRODUCT_NAME = exampleDebug; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + E4B69B610A3A1757003C02F2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + ); + FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../../libs/glut/lib/osx\""; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_TUNING = NONE; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Headers/Carbon.h"; + INFOPLIST_FILE = "openFrameworks-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_1)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_4)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_5)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_6)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_10)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_11)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_12)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_13)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_14)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_15)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_2)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_3)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_7)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_8)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_9)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_10)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_11)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_12)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_13)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_16)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_17)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_18)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_19)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_20)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_21)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_22)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_23)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_24)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_25)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_26)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_27)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_28)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_29)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_30)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_31)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_32)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_33)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_34)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_35)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_36)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_37)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_38)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_39)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_40)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_41)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_42)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_43)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_44)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_45)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_46)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_47)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_48)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_49)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_50)", + "$(LIBRARY_SEARCH_PATHS_QUOTED_FOR_TARGET_51)", + ); + PREBINDING = NO; + PRODUCT_NAME = example; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E4B69B4E0A3A1720003C02F2 /* Debug */, + E4B69B4F0A3A1720003C02F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E4B69B5F0A3A1757003C02F2 /* Build configuration list for PBXNativeTarget "example" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E4B69B600A3A1757003C02F2 /* Debug */, + E4B69B610A3A1757003C02F2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = E4B69B4C0A3A1720003C02F2 /* Project object */; +} diff --git a/example/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme b/example/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme new file mode 100644 index 0000000..9db3c7b --- /dev/null +++ b/example/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme b/example/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme new file mode 100644 index 0000000..80c45c5 --- /dev/null +++ b/example/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/openFrameworks-Info.plist b/example/openFrameworks-Info.plist new file mode 100644 index 0000000..e5db555 --- /dev/null +++ b/example/openFrameworks-Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + com.yourcompany.openFrameworks + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + + diff --git a/example/src/main.cpp b/example/src/main.cpp new file mode 100644 index 0000000..e87667a --- /dev/null +++ b/example/src/main.cpp @@ -0,0 +1,11 @@ +#include "testApp.h" +#include "ofAppGlutWindow.h" + +//-------------------------------------------------------------- +int main() +{ + ofAppGlutWindow window; // create a window + // set width, height, mode (OF_WINDOW or OF_FULLSCREEN) + ofSetupOpenGL(&window, 1024, 768, OF_WINDOW); + ofRunApp(new testApp()); // start the app +} \ No newline at end of file diff --git a/example/src/testApp.cpp b/example/src/testApp.cpp new file mode 100644 index 0000000..5377b62 --- /dev/null +++ b/example/src/testApp.cpp @@ -0,0 +1,120 @@ +#include "testApp.h" + +#include "ofxInteractivePrimitives.h" + +class ControlPoint : public ofxInteractivePrimitives +{ +public: + + void draw() + { + if (isHover()) + { + ofFill(); + } + else + { + ofNoFill(); + } + + if (isDown()) + { + ofSetColor(255, 0, 0); + } + else + { + ofSetColor(255); + } + + ofRect(0, 0, 100, 100); + } + + void hittest() + { + ofFill(); + ofRect(0, 0, 100, 100); + } + + void mouseMoved(int x, int y) + { + printf("%i %i\n", x, y); + } +}; + +ControlPoint CP; + +//-------------------------------------------------------------- +void testApp::setup() +{ + ofSetFrameRate(60); + ofSetVerticalSync(true); + ofBackground(0); + + CP.setPosition(300, 300, 0); +} + +//-------------------------------------------------------------- +void testApp::update() +{ + +} + +//-------------------------------------------------------------- +void testApp::draw() +{ + +} + +//-------------------------------------------------------------- +void testApp::keyPressed(int key) +{ + +} + +//-------------------------------------------------------------- +void testApp::keyReleased(int key) +{ + +} + +//-------------------------------------------------------------- +void testApp::mouseMoved(int x, int y) +{ + +} + +//-------------------------------------------------------------- +void testApp::mouseDragged(int x, int y, int button) +{ + +} + +//-------------------------------------------------------------- +void testApp::mousePressed(int x, int y, int button) +{ + +} + +//-------------------------------------------------------------- +void testApp::mouseReleased(int x, int y, int button) +{ + +} + +//-------------------------------------------------------------- +void testApp::windowResized(int w, int h) +{ + +} + +//-------------------------------------------------------------- +void testApp::gotMessage(ofMessage msg) +{ + +} + +//-------------------------------------------------------------- +void testApp::dragEvent(ofDragInfo dragInfo) +{ + +} \ No newline at end of file diff --git a/example/src/testApp.h b/example/src/testApp.h new file mode 100644 index 0000000..a92fb6f --- /dev/null +++ b/example/src/testApp.h @@ -0,0 +1,21 @@ +#pragma once + +#include "ofMain.h" + +class testApp : 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); +}; \ No newline at end of file diff --git a/src/ofxInteractivePrimitives.cpp b/src/ofxInteractivePrimitives.cpp new file mode 100644 index 0000000..e8a79c1 --- /dev/null +++ b/src/ofxInteractivePrimitives.cpp @@ -0,0 +1,364 @@ +#include "ofxInteractivePrimitives.h" + +class ofxInteractivePrimitives::Context +{ +public: + + vector elements; + + GLint viewport[4]; + GLdouble projection[16], modelview[16]; + + unsigned long current_object_id; + float current_depth; + + ofxInteractivePrimitives *current_responder; + + Context() : current_object_id(0), current_depth(0), current_responder(NULL) + { + enableAllEvent(); + } + + ~Context() + { + disableAllEvent(); + } + + void registerElement(ofxInteractivePrimitives *o) + { + // TODO: error check + elements.push_back(o); + o->object_id = current_object_id++; + } + + void unregisterElement(ofxInteractivePrimitives *o) + { + elements.erase(remove(elements.begin(), elements.end(), o), elements.end()); + } + + void enableAllEvent() + { + ofAddListener(ofEvents().update, this, &ofxInteractivePrimitives::Context::update); + ofAddListener(ofEvents().draw, this, &ofxInteractivePrimitives::Context::draw); + + ofAddListener(ofEvents().mousePressed, this, &ofxInteractivePrimitives::Context::mousePressed); + ofAddListener(ofEvents().mouseReleased, this, &ofxInteractivePrimitives::Context::mouseReleased); + ofAddListener(ofEvents().mouseMoved, this, &ofxInteractivePrimitives::Context::mouseMoved); + ofAddListener(ofEvents().mouseDragged, this, &ofxInteractivePrimitives::Context::mouseDragged); + + } + + void disableAllEvent() + { + ofRemoveListener(ofEvents().update, this, &ofxInteractivePrimitives::Context::update); + ofRemoveListener(ofEvents().draw, this, &ofxInteractivePrimitives::Context::draw); + + ofRemoveListener(ofEvents().mousePressed, this, &ofxInteractivePrimitives::Context::mousePressed); + ofRemoveListener(ofEvents().mouseReleased, this, &ofxInteractivePrimitives::Context::mouseReleased); + ofRemoveListener(ofEvents().mouseMoved, this, &ofxInteractivePrimitives::Context::mouseMoved); + ofRemoveListener(ofEvents().mouseDragged, this, &ofxInteractivePrimitives::Context::mouseDragged); + + } + + void prepare() + { + glGetDoublev(GL_PROJECTION_MATRIX, projection); + glGetDoublev(GL_MODELVIEW_MATRIX, modelview); + glGetIntegerv(GL_VIEWPORT, viewport); + } + + void hittest() + { + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *e = elements[i]; + + e->transformGL(); + glPushName(e->object_id); + e->hittest(); + glPopName(); + e->restoreTransformGL(); + } + } + + struct Selection + { + GLuint min_depth, max_depth; + vector name_stack; + }; + + static bool sort_by_depth(const Selection &a, const Selection &b) + { + return a.min_depth < b.min_depth; + } + + vector pickup(int x, int y) + { + const int BUFSIZE = 256; + GLuint selectBuf[BUFSIZE]; + GLint hits; + + glPushAttrib(GL_ALL_ATTRIB_BITS); + ofPushView(); + + glEnable(GL_DEPTH_TEST); + + glSelectBuffer(BUFSIZE, selectBuf); + glRenderMode(GL_SELECT); + glMatrixMode(GL_PROJECTION); + + glPushMatrix(); + { + glLoadIdentity(); + gluPickMatrix(x, viewport[3] - y, 1.0, 1.0, viewport); + glMultMatrixd(projection); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glMultMatrixd(modelview); + + hittest(); + + glMatrixMode(GL_PROJECTION); + } + glPopMatrix(); + + glMatrixMode(GL_MODELVIEW); + + hits = glRenderMode(GL_RENDER); + + ofPopView(); + glPopAttrib(); + + if (hits <= 0) return vector(); + + GLuint *ptr = selectBuf; + + vector picked_stack; + + for (int i = 0; i < hits; i++) + { + GLuint num_names = ptr[0]; + GLuint min_depth = ptr[1]; + GLuint max_depth = ptr[2]; + + GLuint *names = &ptr[3]; + + Selection d; + + d.min_depth = min_depth; + d.max_depth = max_depth; + d.name_stack.insert(d.name_stack.begin(), names, (names + num_names)); + + picked_stack.push_back(d); + + ptr += (3 + num_names); + } + + sort(picked_stack.begin(), picked_stack.end(), sort_by_depth); + + return picked_stack; + } + + ofVec3f getLocalPosition(int x, int y) + { + GLdouble ox, oy, oz; + + gluUnProject(x, y, current_depth, + modelview, projection, viewport, + &ox, &oy, &oz); + + oy = viewport[3] - oy; + + return ofVec2f(ox, oy); + } + + + // event callbacks + + void draw(ofEventArgs&) + { + ofxInteractivePrimitives::prepareModelViewMatrix(); + + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *w = elements[i]; + w->transformGL(); + w->draw(); + w->restoreTransformGL(); + } + } + + void update(ofEventArgs&) + { + for (int i = 0; i < elements.size(); i++) + { + elements[i]->update(); + } + } + + void mousePressed(ofMouseEventArgs &e) + { + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *e = elements[i]; + e->hover = false; + } + + vector p = pickup(e.x, e.y); + + if (!p.empty()) + { + Selection &s = p[0]; + current_depth = (float)s.min_depth / 0xffffffff; + + for (int i = 0; i < s.name_stack.size(); i++) + { + ofxInteractivePrimitives *w = elements[s.name_stack.at(i)]; + ofVec3f p = getLocalPosition(e.x, e.y); + p = w->getGlobalTransformMatrix().getInverse().preMult(p); + + w->mousePressed(p.x, p.y, e.button); + + w->hover = true; + w->down = true; + + current_responder = w; + } + } + + if (p.empty()) current_responder = NULL; + } + + void mouseReleased(ofMouseEventArgs &e) + { + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *e = elements[i]; + e->hover = false; + } + + vector p = pickup(e.x, e.y); + + if (!p.empty()) + { + Selection &s = p[0]; + current_depth = (float)s.min_depth / 0xffffffff; + + for (int i = 0; i < s.name_stack.size(); i++) + { + ofxInteractivePrimitives *w = elements[s.name_stack.at(i)]; + ofVec3f p = getLocalPosition(e.x, e.y); + p = w->getGlobalTransformMatrix().getInverse().preMult(p); + + w->mouseReleased(p.x, p.y, e.button); + w->hover = true; + } + } + + if (current_responder) + { + current_responder->down = false; + current_responder = NULL; + } + } + + void mouseMoved(ofMouseEventArgs &e) + { + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *e = elements[i]; + e->hover = false; + } + + vector p = pickup(e.x, e.y); + + if (!p.empty()) + { + Selection &s = p[0]; + current_depth = (float)s.min_depth / 0xffffffff; + + for (int i = 0; i < s.name_stack.size(); i++) + { + ofxInteractivePrimitives *w = elements[s.name_stack.at(i)]; + ofVec3f p = getLocalPosition(e.x, e.y); + p = w->getGlobalTransformMatrix().getInverse().preMult(p); + + w->mouseMoved(p.x, p.y); + w->hover = true; + } + } + + if (current_responder) + { + current_responder->down = false; + current_responder = NULL; + } + } + + void mouseDragged(ofMouseEventArgs &e) + { + for (int i = 0; i < elements.size(); i++) + { + ofxInteractivePrimitives *e = elements[i]; + e->hover = false; + } + + bool forcus_is_out = true; + + if (!current_responder) + { + vector p = pickup(e.x, e.y); + + if (!p.empty()) + { + Selection &s = p[0]; + current_depth = (float)s.min_depth / 0xffffffff; + + for (int i = 0; i < s.name_stack.size(); i++) + { + ofxInteractivePrimitives *w = elements[s.name_stack.at(i)]; + ofVec3f p = getLocalPosition(e.x, e.y); + p = w->getGlobalTransformMatrix().getInverse().preMult(p); + + w->mouseDragged(p.x, p.y, e.button); + w->hover = true; + + if (w == current_responder) forcus_is_out = false; + } + } + } + + if (forcus_is_out && current_responder) + { + ofVec3f p = getLocalPosition(e.x, e.y); + p = current_responder->getGlobalTransformMatrix().getInverse().preMult(p); + + current_responder->mouseDragged(p.x, p.y, e.button); + current_responder->hover = true; + } + } +}; + +static ofxInteractivePrimitives::Context *_context = NULL; +static ofxInteractivePrimitives::Context& getContext() +{ + if (_context == NULL) + _context = new ofxInteractivePrimitives::Context; + return *_context; +} + +ofxInteractivePrimitives::ofxInteractivePrimitives() +{ + getContext().registerElement(this); +} + +ofxInteractivePrimitives::~ofxInteractivePrimitives() +{ + getContext().unregisterElement(this); +} + +void ofxInteractivePrimitives::prepareModelViewMatrix() +{ + getContext().prepare(); +} \ No newline at end of file diff --git a/src/ofxInteractivePrimitives.h b/src/ofxInteractivePrimitives.h new file mode 100644 index 0000000..55ffdf1 --- /dev/null +++ b/src/ofxInteractivePrimitives.h @@ -0,0 +1,41 @@ +#pragma once + +#include "ofMain.h" + +class ofxInteractivePrimitives : public ofNode +{ +public: + + class Context; + friend class Context; + + static void prepareModelViewMatrix(); + + ofxInteractivePrimitives(); + virtual ~ofxInteractivePrimitives(); + + virtual void update() {} + virtual void draw() {} + virtual void hittest() {} + + virtual void mousePressed(int x, int y, int button) {} + virtual void mouseReleased(int x, int y, int button) {} + virtual void mouseMoved(int x, int y) {} + virtual void mouseDragged(int x, int y, int button) {} + + // TODO: key events + // virtual void keyPressed(int key) {} + // virtual void keyReleased(int key) {} + + void setParent(ofxInteractivePrimitives *o) { ofNode::setParent(*o); } + ofxInteractivePrimitives* getParent() { return (ofxInteractivePrimitives*)ofNode::getParent(); } + + bool isHover() { return hover; } + bool isDown() { return down; } + +private: + + unsigned int object_id; + bool hover, down; + +};