diff --git a/example2/Makefile b/example2/Makefile new file mode 100755 index 0000000..7a7fe8b --- /dev/null +++ b/example2/Makefile @@ -0,0 +1,13 @@ +# Attempt to load a config.make file. +# If none is found, project defaults in config.project.make will be used. +ifneq ($(wildcard config.make),) + include config.make +endif + +# make sure the the OF_ROOT location is defined +ifndef OF_ROOT + OF_ROOT=../../.. +endif + +# call the project makefile! +include $(OF_ROOT)/libs/openFrameworksCompiled/project/makefileCommon/compile.project.mk diff --git a/example2/Project.xcconfig b/example2/Project.xcconfig new file mode 100755 index 0000000..e570b15 --- /dev/null +++ b/example2/Project.xcconfig @@ -0,0 +1,17 @@ +//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" + +//ICONS - NEW IN 0072 +ICON_NAME_DEBUG = icon-debug.icns +ICON_NAME_RELEASE = icon.icns +ICON_FILE_PATH = $(OF_PATH)/libs/openFrameworksCompiled/project/osx/ + +//IF YOU WANT AN APP TO HAVE A CUSTOM ICON - PUT THEM IN YOUR DATA FOLDER AND CHANGE ICON_FILE_PATH to: +//ICON_FILE_PATH = bin/data/ + +OTHER_LDFLAGS = $(OF_CORE_LIBS) $(OF_CORE_FRAMEWORKS) +HEADER_SEARCH_PATHS = $(OF_CORE_HEADERS) diff --git a/example2/bin/data/.gitkeep b/example2/bin/data/.gitkeep new file mode 100755 index 0000000..e69de29 diff --git a/example2/bin/data/display.txt b/example2/bin/data/display.txt new file mode 100755 index 0000000..aac5204 --- /dev/null +++ b/example2/bin/data/display.txt @@ -0,0 +1,9 @@ +[Main Display] +display id:69731906 +display bounds:0:0:1440:900 +[Sub Display] +display id:188934339 +display bounds:-720:480:720:480 +[Sub Display] +display id:188934340 +display bounds:-720:0:720:480 diff --git a/example2/config.make b/example2/config.make new file mode 100755 index 0000000..df10f64 --- /dev/null +++ b/example2/config.make @@ -0,0 +1,142 @@ +################################################################################ +# CONFIGURE PROJECT MAKEFILE (optional) +# This file is where we make project specific configurations. +################################################################################ + +################################################################################ +# OF ROOT +# The location of your root openFrameworks installation +# (default) OF_ROOT = ../../.. +################################################################################ +# OF_ROOT = ../../.. + +################################################################################ +# PROJECT ROOT +# The location of the project - a starting place for searching for files +# (default) PROJECT_ROOT = . (this directory) +# +################################################################################ +# PROJECT_ROOT = . + +################################################################################ +# PROJECT SPECIFIC CHECKS +# This is a project defined section to create internal makefile flags to +# conditionally enable or disable the addition of various features within +# this makefile. For instance, if you want to make changes based on whether +# GTK is installed, one might test that here and create a variable to check. +################################################################################ +# None + +################################################################################ +# PROJECT EXTERNAL SOURCE PATHS +# These are fully qualified paths that are not within the PROJECT_ROOT folder. +# Like source folders in the PROJECT_ROOT, these paths are subject to +# exlclusion via the PROJECT_EXLCUSIONS list. +# +# (default) PROJECT_EXTERNAL_SOURCE_PATHS = (blank) +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_EXTERNAL_SOURCE_PATHS = + +################################################################################ +# PROJECT EXCLUSIONS +# These makefiles assume that all folders in your current project directory +# and any listed in the PROJECT_EXTERNAL_SOURCH_PATHS are are valid locations +# to look for source code. The any folders or files that match any of the +# items in the PROJECT_EXCLUSIONS list below will be ignored. +# +# Each item in the PROJECT_EXCLUSIONS list will be treated as a complete +# string unless teh user adds a wildcard (%) operator to match subdirectories. +# GNU make only allows one wildcard for matching. The second wildcard (%) is +# treated literally. +# +# (default) PROJECT_EXCLUSIONS = (blank) +# +# Will automatically exclude the following: +# +# $(PROJECT_ROOT)/bin% +# $(PROJECT_ROOT)/obj% +# $(PROJECT_ROOT)/%.xcodeproj +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_EXCLUSIONS = + +################################################################################ +# PROJECT LINKER FLAGS +# These flags will be sent to the linker when compiling the executable. +# +# (default) PROJECT_LDFLAGS = -Wl,-rpath=./libs +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ + +# Currently, shared libraries that are needed are copied to the +# $(PROJECT_ROOT)/bin/libs directory. The following LDFLAGS tell the linker to +# add a runtime path to search for those shared libraries, since they aren't +# incorporated directly into the final executable application binary. +# TODO: should this be a default setting? +# PROJECT_LDFLAGS=-Wl,-rpath=./libs + +################################################################################ +# PROJECT DEFINES +# Create a space-delimited list of DEFINES. The list will be converted into +# CFLAGS with the "-D" flag later in the makefile. +# +# (default) PROJECT_DEFINES = (blank) +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_DEFINES = + +################################################################################ +# PROJECT CFLAGS +# This is a list of fully qualified CFLAGS required when compiling for this +# project. These CFLAGS will be used IN ADDITION TO the PLATFORM_CFLAGS +# defined in your platform specific core configuration files. These flags are +# presented to the compiler BEFORE the PROJECT_OPTIMIZATION_CFLAGS below. +# +# (default) PROJECT_CFLAGS = (blank) +# +# Note: Before adding PROJECT_CFLAGS, note that the PLATFORM_CFLAGS defined in +# your platform specific configuration file will be applied by default and +# further flags here may not be needed. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_CFLAGS = + +################################################################################ +# PROJECT OPTIMIZATION CFLAGS +# These are lists of CFLAGS that are target-specific. While any flags could +# be conditionally added, they are usually limited to optimization flags. +# These flags are added BEFORE the PROJECT_CFLAGS. +# +# PROJECT_OPTIMIZATION_CFLAGS_RELEASE flags are only applied to RELEASE targets. +# +# (default) PROJECT_OPTIMIZATION_CFLAGS_RELEASE = (blank) +# +# PROJECT_OPTIMIZATION_CFLAGS_DEBUG flags are only applied to DEBUG targets. +# +# (default) PROJECT_OPTIMIZATION_CFLAGS_DEBUG = (blank) +# +# Note: Before adding PROJECT_OPTIMIZATION_CFLAGS, please note that the +# PLATFORM_OPTIMIZATION_CFLAGS defined in your platform specific configuration +# file will be applied by default and further optimization flags here may not +# be needed. +# +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_OPTIMIZATION_CFLAGS_RELEASE = +# PROJECT_OPTIMIZATION_CFLAGS_DEBUG = + +################################################################################ +# PROJECT COMPILERS +# Custom compilers can be set for CC and CXX +# (default) PROJECT_CXX = (blank) +# (default) PROJECT_CC = (blank) +# Note: Leave a leading space when adding list items with the += operator +################################################################################ +# PROJECT_CXX = +# PROJECT_CC = diff --git a/example2/example.xcodeproj/project.pbxproj b/example2/example.xcodeproj/project.pbxproj new file mode 100755 index 0000000..1075963 --- /dev/null +++ b/example2/example.xcodeproj/project.pbxproj @@ -0,0 +1,367 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 9AB63D361B33FC50008CA372 /* ofxDisplayLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9AB63D351B33FC50008CA372 /* ofxDisplayLayout.mm */; }; + E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E4328148138ABC890047C5CB /* openFrameworksDebug.a */; }; + E4B69E210A3A1BDC003C02F2 /* ofApp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */; }; +/* End PBXBuildFile 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 = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 9AB63D341B33FC50008CA372 /* ofxDisplayLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ofxDisplayLayout.h; sourceTree = ""; }; + 9AB63D351B33FC50008CA372 /* ofxDisplayLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ofxDisplayLayout.mm; sourceTree = ""; }; + E4328143138ABC890047C5CB /* openFrameworksLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = openFrameworksLib.xcodeproj; path = ../../../libs/openFrameworksCompiled/project/osx/openFrameworksLib.xcodeproj; sourceTree = SOURCE_ROOT; }; + E4B69B5B0A3A1756003C02F2 /* exampleDebug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = exampleDebug.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = ofApp.cpp; path = src/ofApp.cpp; sourceTree = SOURCE_ROOT; }; + E4B6FCAD0C3E899E008CF71C /* openFrameworks-Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.plist.xml; path = "openFrameworks-Info.plist"; 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 = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E4B69B590A3A1756003C02F2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E4328149138ABC9F0047C5CB /* openFrameworksDebug.a in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9AB63D1B1B33FBC3008CA372 /* ofxDisplayLayout */ = { + isa = PBXGroup; + children = ( + 9AB63D331B33FC50008CA372 /* src */, + ); + name = ofxDisplayLayout; + path = ..; + sourceTree = ""; + }; + 9AB63D331B33FC50008CA372 /* src */ = { + isa = PBXGroup; + children = ( + 9AB63D341B33FC50008CA372 /* ofxDisplayLayout.h */, + 9AB63D351B33FC50008CA372 /* ofxDisplayLayout.mm */, + ); + path = src; + sourceTree = ""; + }; + BB4B014C10F69532006C3DED /* addons */ = { + isa = PBXGroup; + children = ( + 9AB63D1B1B33FBC3008CA372 /* ofxDisplayLayout */, + ); + name = addons; + sourceTree = ""; + }; + E4328144138ABC890047C5CB /* Products */ = { + isa = PBXGroup; + children = ( + E4328148138ABC890047C5CB /* openFrameworksDebug.a */, + ); + name = Products; + sourceTree = ""; + }; + E4B69B4A0A3A1720003C02F2 = { + isa = PBXGroup; + children = ( + E4B6FCAD0C3E899E008CF71C /* openFrameworks-Info.plist */, + E4EB6923138AFD0F00A09F29 /* Project.xcconfig */, + E4B69E1C0A3A1BDC003C02F2 /* src */, + E4EEC9E9138DF44700A80321 /* openFrameworks */, + BB4B014C10F69532006C3DED /* addons */, + E4B69B5B0A3A1756003C02F2 /* exampleDebug.app */, + ); + sourceTree = ""; + }; + E4B69E1C0A3A1BDC003C02F2 /* src */ = { + isa = PBXGroup; + children = ( + E4B69E1E0A3A1BDC003C02F2 /* ofApp.cpp */, + ); + 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 = ( + ); + 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; + attributes = { + LastUpgradeCheck = 0600; + }; + buildConfigurationList = E4B69B4D0A3A1720003C02F2 /* Build configuration list for PBXProject "example" */; + compatibilityVersion = "Xcode 3.2"; + 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\";\nmkdir -p \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources/\"\ncp -f \"$ICON_FILE\" \"$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Contents/Resources/\"\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E4B69B580A3A1756003C02F2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9AB63D361B33FC50008CA372 /* ofxDisplayLayout.mm in Sources */, + E4B69E210A3A1BDC003C02F2 /* ofApp.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 = { + 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; + MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; + OTHER_CPLUSPLUSFLAGS = ( + "-D__MACOSX_CORE__", + "-lpthread", + "-mtune=native", + ); + SDKROOT = macosx; + }; + name = Debug; + }; + E4B69B4F0A3A1720003C02F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4EB6923138AFD0F00A09F29 /* Project.xcconfig */; + buildSettings = { + 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; + MACOSX_DEPLOYMENT_TARGET = 10.8; + OTHER_CPLUSPLUSFLAGS = ( + "-D__MACOSX_CORE__", + "-lpthread", + "-mtune=native", + ); + SDKROOT = macosx; + }; + name = Release; + }; + E4B69B600A3A1757003C02F2 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4EB6923138AFD0F00A09F29 /* Project.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; + COMBINE_HIDPI_IMAGES = YES; + 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_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_TUNING = NONE; + ICON = "$(ICON_NAME_DEBUG)"; + ICON_FILE = "$(ICON_FILE_PATH)$(ICON)"; + INFOPLIST_FILE = "openFrameworks-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = "$(inherited)"; + PRODUCT_NAME = exampleDebug; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + E4B69B610A3A1757003C02F2 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = E4EB6923138AFD0F00A09F29 /* Project.xcconfig */; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD)"; + COMBINE_HIDPI_IMAGES = YES; + 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_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_MODEL_TUNING = NONE; + ICON = "$(ICON_NAME_RELEASE)"; + ICON_FILE = "$(ICON_FILE_PATH)$(ICON)"; + INFOPLIST_FILE = "openFrameworks-Info.plist"; + INSTALL_PATH = "$(HOME)/Applications"; + LIBRARY_SEARCH_PATHS = "$(inherited)"; + PRODUCT_NAME = example; + WRAPPER_EXTENSION = app; + baseConfigurationReference = E4EB6923138AFD0F00A09F29; + }; + 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/example2/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme b/example2/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme new file mode 100755 index 0000000..f4181e3 --- /dev/null +++ b/example2/example.xcodeproj/xcshareddata/xcschemes/Debug.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example2/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme b/example2/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme new file mode 100755 index 0000000..fb20cc3 --- /dev/null +++ b/example2/example.xcodeproj/xcshareddata/xcschemes/Release.xcscheme @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example2/openFrameworks-Info.plist b/example2/openFrameworks-Info.plist new file mode 100755 index 0000000..8d64d2b --- /dev/null +++ b/example2/openFrameworks-Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + cc.openFrameworks.ofapp + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + CFBundleSignature + ???? + CFBundleVersion + 1.0 + CFBundleIconFile + ${ICON} + + diff --git a/example2/src/ofApp.cpp b/example2/src/ofApp.cpp new file mode 100755 index 0000000..d084318 --- /dev/null +++ b/example2/src/ofApp.cpp @@ -0,0 +1,52 @@ +#include "ofMain.h" + +#include "ofxDisplayLayout.h" + +class ofApp : public ofBaseApp +{ + + ofxDisplayLayout manager; + +public: + + void setup() { + ofSetLogLevel(OF_LOG_VERBOSE); + } + + void update() { + + } + + void draw() { + + stringstream report; + report << "Press [s] to save current display order" << endl; + report << "Press [l] to load settings, align displays" << endl; + ofDrawBitmapString(report.str(), 20, 20); + + manager.debugDraw(300, 300); + } + + void keyReleased(int key) { + + if (key == 's') { + manager.save2(); + } + if (key == 'l') { + // horizontal + manager.load2("display.txt", ofxDisplayLayout::ALIGN_HORIZONTAL); + + // vertical + // manager.load("display.txt", ofxDisplayLayout::ALIGN_VERTICAL); + } + } +}; + + + +#pragma mark - +#pragma mark main +int main(){ + ofSetupOpenGL(1024, 780, OF_WINDOW); + ofRunApp(new ofApp()); +} diff --git a/src/ofxDisplayLayout.h b/src/ofxDisplayLayout.h old mode 100644 new mode 100755 index 5314c6d..0c552c8 --- a/src/ofxDisplayLayout.h +++ b/src/ofxDisplayLayout.h @@ -19,16 +19,24 @@ class ofxDisplayLayout{ ofxDisplayLayout(); bool save(string filepath = "display.txt") const; bool load(string filepath = "display.txt", AlignmentDirection direction = ALIGN_HORIZONTAL) const; - void debugDraw(int x, int y, float scale = 0.1); + + bool save2(string filepath = "display.txt") const; + bool load2(string filepath = "display.txt", AlignmentDirection direction = ALIGN_HORIZONTAL) const; + + + void debugDraw(int x, int y, float scale = 0.1); private: bool arrange(vector display_ids, AlignmentDirection direction) const; - + bool setResAndOrigin(vector display_ids, vector display_rects) const; + bool isMainDisplay(unsigned int display_id) const; bool hasDisplay(unsigned int display_id) const; ofRectangle getDisplayBounds(unsigned int display_id) const; vector getDisplayIds() const; size_t getNumDisplay() const; + + CGDisplayModeRef getDisplayMode(unsigned int _id, int _w, int _h) const; }; diff --git a/src/ofxDisplayLayout.mm b/src/ofxDisplayLayout.mm old mode 100644 new mode 100755 index a319723..bccd7d9 --- a/src/ofxDisplayLayout.mm +++ b/src/ofxDisplayLayout.mm @@ -11,154 +11,307 @@ ofxDisplayLayout::ofxDisplayLayout() { #ifndef TARGET_OSX - ofSystemAlertDialog("Sorry! ofxDisplayLayout supports only MacOS."); + ofSystemAlertDialog("Sorry! ofxDisplayLayout supports only MacOS."); #endif } -bool ofxDisplayLayout::save(string filepath) const { - - /*! - getting display ids - */ - const vector display_ids = getDisplayIds(); - - ofLogVerbose() << "ofxDisplayLayout found " << display_ids.size() << " displays." << endl; - - if (display_ids.size() < 2) { - ofLogError() << "you don't need to arange display layout. aborted" << endl; - return false; - } - +bool ofxDisplayLayout::save2(string filepath) const { + + /*! + getting display ids + */ + const vector display_ids = getDisplayIds(); + + ofLogVerbose() << "ofxDisplayLayout found " << display_ids.size() << " displays." << endl; + + if (display_ids.size() < 2) { + ofLogError() << "you don't need to arange display layout. aborted" << endl; + return false; + } + + + + /*! + creating reports + */ + // stringstream stream; + stringstream report; + + // auto create_report = [this, &stream] + auto create_report = [this, &report] + (unsigned int display_id) + { + + + const ofRectangle bounds = getDisplayBounds(display_id); + + //stringstream report; + report << "[" << (isMainDisplay(display_id) ? "Main" : "Sub") << " Display]" << endl; + report << "display id:" << display_id << endl; + report << "display bounds:" + << bounds.x + << ":"<< bounds.y + << ":" << bounds.width + << ":" << bounds.height<< endl; + //won't use thus number but rather find new mode number via stored resolution info + // report << "displayMode:" < display_ids; + vector display_rects; + vector display_modes; + + ofBuffer buf = ofBufferFromFile(filepath); + ofBuffer::Lines lines = buf.getLines(); + + int lineCnt = 0; + for (ofBuffer::Line l = lines.begin(); l != lines.end(); ++l) { + + const string linestr = l.asString(); + + if (linestr.empty()) continue; + + if(lineCnt == 0){ + ofLog()<<" read_from_file display name = "< temp_strSplit; + temp_strSplit = ofSplitString(linestr, ":"); + + const unsigned int display_id = stoul(temp_strSplit[1]); + ofLog()<<"display_id = "< temp_strSplit; + temp_strSplit = ofSplitString(linestr, ":"); + + for(int i=0; i temp_strSplit; +// temp_strSplit = ofSplitString(linestr, ":"); +// +// for(int i=0; i 2) lineCnt = 0; + + + } + + + /*! + arrange + */ + //return arrange(display_ids, direction); + return setResAndOrigin(display_ids, display_rects); +} + +bool ofxDisplayLayout::save(string filepath) const { + + /*! + getting display ids + */ + const vector display_ids = getDisplayIds(); + + ofLogVerbose() << "ofxDisplayLayout found " << display_ids.size() << " displays." << endl; + + if (display_ids.size() < 2) { + ofLogError() << "you don't need to arange display layout. aborted" << endl; + return false; + } + + + /*! + creating reports + */ + stringstream stream; + + auto create_report = [this, &stream] + (unsigned int display_id) + { + const ofRectangle bounds = getDisplayBounds(display_id); + + stringstream report; + report << "[" << (isMainDisplay(display_id) ? "Main" : "Sub") << " Display]" << endl; + report << "display id: " << display_id << endl; + report << "display bounds: {" + << "x:" << bounds.x + << ", y:" << bounds.y + << ", w:" << bounds.width + << ", h:" << bounds.height + << "}" << endl; + + ofLogVerbose() << report.str(); + + stream << display_id << endl; + }; + + for_each(begin(display_ids), + end(display_ids), + create_report); + + + /*! + writing to tile + */ + ofLogVerbose() << "start saving current monitor order..."; + + ofBuffer buf(stream.str()); + + if (ofBufferToFile(filepath, buf)) { + ofLogVerbose() << "succeeded!"; + ofLogVerbose() << "the display order is saved to: " << filepath << endl; + } + + return true; } bool ofxDisplayLayout::load(string filepath, AlignmentDirection direction) const { - - /*! - file check - */ - if (!ofFile::doesFileExist(filepath)) { - ofLogVerbose() << filepath << " doesn't exist. aborted" << endl; - return false; - } - - - /*! - reading valid display id - */ - vector display_ids; - - ofBuffer buf = ofBufferFromFile(filepath); - ofBuffer::Lines lines = buf.getLines(); - - for (ofBuffer::Line l = lines.begin(); l != lines.end(); ++l) { - - const string linestr = l.asString(); - - if (linestr.empty()) continue; - - const unsigned int display_id = stoul(linestr); - - if (hasDisplay(display_id) == false) { - ofLogVerbose() << "Aborted. couldn't found the display : " << display_id; - return false; - } - - display_ids.emplace_back(display_id); - } - - - /*! - arrange - */ - return arrange(display_ids, direction); + + /*! + file check + */ + if (!ofFile::doesFileExist(filepath)) { + ofLogVerbose() << filepath << " doesn't exist. aborted" << endl; + return false; + } + + + /*! + reading valid display id + */ + vector display_ids; + + ofBuffer buf = ofBufferFromFile(filepath); + ofBuffer::Lines lines = buf.getLines(); + + for (ofBuffer::Line l = lines.begin(); l != lines.end(); ++l) { + + const string linestr = l.asString(); + + if (linestr.empty()) continue; + + const unsigned int display_id = stoul(linestr); + + if (hasDisplay(display_id) == false) { + ofLogVerbose() << "Aborted. couldn't found the display : " << display_id; + return false; + } + + display_ids.emplace_back(display_id); + } + + + /*! + arrange + */ + return arrange(display_ids, direction); } void ofxDisplayLayout::debugDraw(int x, int y, float scale) { - - auto draw = [this, &scale] + + auto draw = [this, &scale] (unsigned int display_id) - { - ofRectangle rect = getDisplayBounds(display_id); - - ofPushMatrix(); - { - ofScale(scale, scale); - - ofFill(); - ofSetColor(255, 0, 0, 100); - ofDrawRectangle(rect); - - ofNoFill(); - ofSetColor(255, 0, 0); - ofSetLineWidth(2); - ofDrawRectangle(rect); - } - ofPopMatrix(); - - if (isMainDisplay(display_id)) { - ofDrawBitmapStringHighlight("Main", - rect.getPosition() * scale, - ofColor::red, - ofColor::white); - } - - ofSetColor(255); - ofDrawBitmapString(ofToString(display_id), rect.getPosition()*scale+20); - }; - - const vector display_ids = getDisplayIds(); - - ofPushStyle(); - ofTranslate(x, y); - for_each(begin(display_ids), - end(display_ids), - draw); - ofPopStyle(); + { + ofRectangle rect = getDisplayBounds(display_id); + + ofPushMatrix(); + { + ofScale(scale, scale); + + ofFill(); + ofSetColor(255, 0, 0, 100); + ofDrawRectangle(rect); + + ofNoFill(); + ofSetColor(255, 0, 0); + ofSetLineWidth(2); + ofDrawRectangle(rect); + } + ofPopMatrix(); + + if (isMainDisplay(display_id)) { + ofDrawBitmapStringHighlight("Main", + rect.getPosition() * scale, + ofColor::red, + ofColor::white); + } + + ofSetColor(255); + ofDrawBitmapString(ofToString(display_id), rect.getPosition()*scale+20); + }; + + const vector display_ids = getDisplayIds(); + + ofPushStyle(); + ofTranslate(x, y); + for_each(begin(display_ids), + end(display_ids), + draw); + ofPopStyle(); } @@ -166,155 +319,256 @@ #pragma mark private bool ofxDisplayLayout::isMainDisplay(unsigned int display_id) const { - return CGMainDisplayID() == display_id; + return CGMainDisplayID() == display_id; } bool ofxDisplayLayout::hasDisplay(unsigned int display_id) const { - - const vector display_ids = getDisplayIds(); - - return find(begin(display_ids), - end(display_ids), - display_id) != end(display_ids); + + const vector display_ids = getDisplayIds(); + + return find(begin(display_ids), + end(display_ids), + display_id) != end(display_ids); } ofRectangle ofxDisplayLayout::getDisplayBounds(unsigned int display_id) const { - - const CGRect bounds = CGDisplayBounds(display_id); - - return ofRectangle(bounds.origin.x, - bounds.origin.y, - bounds.size.width, - bounds.size.height); + + const CGRect bounds = CGDisplayBounds(display_id); + + return ofRectangle(bounds.origin.x, + bounds.origin.y, + bounds.size.width, + bounds.size.height); } vector ofxDisplayLayout::getDisplayIds() const { - - const unsigned int num_max_displays = 50; - - NSRect frame; - CGDirectDisplayID displays[num_max_displays]; - CGDisplayCount num_displays; - - CGError err = CGGetOnlineDisplayList(num_max_displays, displays, &num_displays); - vector ids(num_displays); - - if (err != kCGErrorSuccess) { - ofLogError() << "faild to get display ids."; - return ids; - } - - for (int i=0; i ids(num_displays); + + if (err != kCGErrorSuccess) { + ofLogError() << "faild to get display ids."; + return ids; + } + + for (int i=0; i display_ids, vector display_rects) const { + + + try { + for(int i=0; i, CGDisplayModeRef mode, <#CFDictionaryRef options#>) + err = CGDisplaySetDisplayMode(display_ids[i], temp_mode, NULL); + + + if (err != kCGErrorSuccess) { + + ofLogError() << "display mode failed on display: " << display_ids[i]; + ofLogError() << "reason: " << err << endl; + //CGCancelDisplayConfiguration(configRef0); + return false; + } + + else { + ofLogVerbose() + << "Succeeded! Display " << display_ids[i] << " is set to the mode " + << temp_mode; + //CGCompleteDisplayConfiguration(configRef0, kCGConfigureForSession); + } + + + CGDisplayConfigRef configRef; + CGBeginDisplayConfiguration(&configRef); + + err = CGConfigureDisplayOrigin(configRef, + (CGDirectDisplayID)display_ids[i], + display_rects[i].x, + display_rects[i].y); + + if (err != kCGErrorSuccess) { + + ofLogError() << "display order arrangement failed on display: " << display_ids[i]; + ofLogError() << "reason: " << err << endl; + CGCancelDisplayConfiguration(configRef); + return false; + } + + else { + ofLogVerbose() + << "Succeeded! Display " << display_ids[i] << " is set to the origin " + << "{x:" << display_rects[i].x << ", y:" << display_rects[i].y << "}"; + CGCompleteDisplayConfiguration(configRef, kCGConfigureForSession); + } + + }//end for + + } + catch (const exception& e) { + ofLogError() << "Error: " << e.what(); + return false; + } + + ofLogVerbose() << "display alignment done!"; + + return true; } bool ofxDisplayLayout::arrange(vector display_ids, AlignmentDirection direction) const { - - // see also: Quartz Display Services Reference - // https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/index.html - - if (direction >= NUM_ALIGNMENT_TYPES) { - ofLogError() << "unknown alignment type. aborted"; - return false; - } - - - /*! - estimating the new origin for each display - */ - struct Display { - - Display(unsigned int _id, ofRectangle _bounds, ofPoint _origin) - : id(_id) - , old_bounds(_bounds) - , new_origin(_origin) - {} - - unsigned int id; - ofRectangle old_bounds; - ofPoint new_origin; - }; - - vector displays; - - for (int i=0; i= NUM_ALIGNMENT_TYPES) { + ofLogError() << "unknown alignment type. aborted"; + return false; + } + + + /*! + estimating the new origin for each display + */ + struct Display { + + Display(unsigned int _id, ofRectangle _bounds, ofPoint _origin) + : id(_id) + , old_bounds(_bounds) + , new_origin(_origin) + {} + + unsigned int id; + ofRectangle old_bounds; + ofPoint new_origin; + }; + + vector displays; + + for (int i=0; i