diff --git a/CMakeLists.txt b/CMakeLists.txt index d627048..d3f11ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,10 @@ if(UNIX) # the RPATH to be used when installing set(CMAKE_SKIP_RPATH TRUE) - set(OpenGL_DIR /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/) set(CMAKE_OSX_ARCHITECTURES x86_64) set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") +# set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X version to target for deployment") else() add_definitions(-DLINUX) @@ -283,6 +283,7 @@ set(VMIX_SRCS ActionManager.cpp ) + set(VMIX_RSC_FILES ./rsc/shaders/simple.fs ./rsc/shaders/simple.vs @@ -370,6 +371,7 @@ IF(APPLE) # create the application add_executable(${VMIX_BINARY} MACOSX_BUNDLE ${VMIX_SRCS} + ./osx/CustomDelegate.m ${IMGUITEXTEDIT_SRC} ${MACOSX_BUNDLE_ICON_FILE} ) @@ -378,6 +380,11 @@ IF(APPLE) set(MACOSX_BUNDLE_PLIST_FILE ${CMAKE_SOURCE_DIR}/osx/Info.plist) set_target_properties(${VMIX_BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${MACOSX_BUNDLE_PLIST_FILE}) + set(PLATFORM_LIBS + "-framework CoreFoundation" + "-framework Appkit" + ) + ELSE(APPLE) add_executable(${VMIX_BINARY} @@ -385,6 +392,9 @@ ELSE(APPLE) ${IMGUITEXTEDIT_SRC} ) + set(PLATFORM_LIBS "" + ) + ENDIF(APPLE) @@ -421,6 +431,7 @@ target_link_libraries(${VMIX_BINARY} LINK_PRIVATE IMGUI OSCPACK vmix::rc + ${PLATFORM_LIBS} ) macro_display_feature_log() @@ -434,7 +445,7 @@ SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md") SET(CPACK_PACKAGE_CONTACT "bruno.herbelin@gmail.com") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.txt") SET(CPACK_PACKAGE_VERSION_MAJOR "0") -SET(CPACK_PACKAGE_VERSION_MINOR "3") +SET(CPACK_PACKAGE_VERSION_MINOR "4") SET(CPACK_PACKAGE_VENDOR "Bruno Herbelin") SET(CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" @@ -471,7 +482,7 @@ IF(APPLE) ### TODO configure auto to find installation dir of gst # intall the gst-plugin-scanner program (used by plugins at load time) - install(FILES "/usr/local/Cellar/gstreamer/1.18.0/libexec/gstreamer-1.0/gst-plugin-scanner" + install(FILES "/usr/local/Cellar/gstreamer/1.18.1/libexec/gstreamer-1.0/gst-plugin-scanner" DESTINATION "${plugin_dest_dir}" PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT Runtime @@ -482,11 +493,11 @@ IF(APPLE) # Install the gst-plugins (all those installed with brew ) install(DIRECTORY "${PKG_GSTREAMER_PLUGIN_DIR}" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) - install(DIRECTORY "/usr/local/Cellar/gst-plugins-base/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) - install(DIRECTORY "/usr/local/Cellar/gst-plugins-good/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) -# install(DIRECTORY "/usr/local/Cellar/gst-plugins-bad/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) - install(DIRECTORY "/usr/local/Cellar/gst-plugins-ugly/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) - install(DIRECTORY "/usr/local/Cellar/gst-libav/1.18.0/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) + install(DIRECTORY "/usr/local/Cellar/gst-plugins-base/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) + install(DIRECTORY "/usr/local/Cellar/gst-plugins-good/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) +# install(DIRECTORY "/usr/local/Cellar/gst-plugins-bad/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) + install(DIRECTORY "/usr/local/Cellar/gst-plugins-ugly/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) + install(DIRECTORY "/usr/local/Cellar/gst-libav/1.18.1/lib/gstreamer-1.0" DESTINATION "${plugin_dest_dir}" COMPONENT Runtime) # install locally recompiled gst-plugins-bad install(FILES "/Users/herbelin/Development/gst/gst-plugins-bad-1.18.0/build/ext/libde265/libgstde265.dylib" DESTINATION "${plugin_dest_dir}/gstreamer-1.0" COMPONENT Runtime) diff --git a/main.cpp b/main.cpp index cb04318..a243761 100644 --- a/main.cpp +++ b/main.cpp @@ -31,13 +31,20 @@ #include "Connection.h" +#if defined(APPLE) +extern "C"{ + void forward_load_message(const char * filename){ + Settings::application.argument_file = std::string(filename); + } +} +#endif + + void drawScene() { Mixer::manager().draw(); } - - int main(int argc, char *argv[]) { // one extra argument is given diff --git a/osx/CocoaToolkit.h b/osx/CocoaToolkit.h index cbfd3ea..738570e 100644 --- a/osx/CocoaToolkit.h +++ b/osx/CocoaToolkit.h @@ -11,4 +11,4 @@ void * get_current_nsopengl_context(); }; -#endif // COCOA_TOOLKIT_H \ No newline at end of file +#endif // COCOA_TOOLKIT_H diff --git a/osx/CustomDelegate.h b/osx/CustomDelegate.h new file mode 100644 index 0000000..760d0f6 --- /dev/null +++ b/osx/CustomDelegate.h @@ -0,0 +1,10 @@ +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface GLFWCustomDelegate : NSObject ++ (void)load; // load is called before even main() is run (as part of objc class registration) +@end + +NS_ASSUME_NONNULL_END diff --git a/osx/CustomDelegate.m b/osx/CustomDelegate.m new file mode 100644 index 0000000..c4eb44a --- /dev/null +++ b/osx/CustomDelegate.m @@ -0,0 +1,49 @@ +#import "CustomDelegate.h" +#import + +// part of your application +extern void forward_load_message(const char * filename); + +@implementation GLFWCustomDelegate + ++ (void)load{ + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + Class class = objc_getClass("GLFWApplicationDelegate"); + + [GLFWCustomDelegate swizzle:class src:@selector(application:openFile:) tgt:@selector(swz_application:openFile:)]; + [GLFWCustomDelegate swizzle:class src:@selector(application:openFiles:) tgt:@selector(swz_application:openFiles:)]; + }); +} + ++ (void) swizzle:(Class) original_c src:(SEL)original_s tgt:(SEL)target_s{ + Class target_c = [GLFWCustomDelegate class]; + Method originalMethod = class_getInstanceMethod(original_c, original_s); + Method swizzledMethod = class_getInstanceMethod(target_c, target_s); + + BOOL didAddMethod = + class_addMethod(original_c, + original_s, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + + if (didAddMethod) { + class_replaceMethod(original_c, + target_s, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + +- (BOOL)swz_application:(NSApplication *)sender openFile:(NSString *)filename{ + forward_load_message(filename.UTF8String); + return YES; +} + +- (void)swz_application:(NSApplication *)sender openFiles:(NSArray *)filenames{ + forward_load_message(filenames.firstObject.UTF8String); +} + +@end diff --git a/osx/Info.plist b/osx/Info.plist index 3044533..c395868 100644 --- a/osx/Info.plist +++ b/osx/Info.plist @@ -9,22 +9,18 @@ CFBundleDocumentTypes - CFBundleTypeExtensions - - mix - - CFBundleTypeIconFile - vimix.icns CFBundleTypeName - GLMixer Session - CFBundleTypeOSTypes - - MIX - + vimix session CFBundleTypeRole Editor - LSIsAppleDefaultForType - + LSIsAppleDefaultForType + + LSHandlerRank + Owner + LSItemContentTypes + + com.bhbn.mix + CFBundleExecutable