From 4741eb869e0b12b043f9ca4be7c115ac03791552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hor=C3=A1=C4=8Dek?= Date: Fri, 22 Feb 2013 18:22:16 +0100 Subject: [PATCH 1/9] add Mac OS X "Scope" menu with empty action --- interface/CMakeLists.txt | 2 +- interface/src/InterfaceMacOSX.h | 6 ++++ interface/src/InterfaceMacOSX.mm | 55 ++++++++++++++++++++++++++++++++ interface/src/main.cpp | 12 ++++++- 4 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 interface/src/InterfaceMacOSX.h create mode 100644 interface/src/InterfaceMacOSX.mm diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 0685aca6cd..d3bb79281b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -21,7 +21,7 @@ endif (APPLE) configure_file(InterfaceConfig.h.in ${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h) # grab the implementation and header files from src dir -file(GLOB INTERFACE_SRCS src/*.cpp src/*.h) +file(GLOB INTERFACE_SRCS src/*.mm src/*.cpp src/*.h) if (APPLE) # set how the icon shows up in the Info.plist file diff --git a/interface/src/InterfaceMacOSX.h b/interface/src/InterfaceMacOSX.h new file mode 100644 index 0000000000..1416d637a4 --- /dev/null +++ b/interface/src/InterfaceMacOSX.h @@ -0,0 +1,6 @@ +#ifndef __interface__InterfaceMacOSX +#define __interface__InterfaceMacOSX + +void initMacOSXMenu(); + +#endif diff --git a/interface/src/InterfaceMacOSX.mm b/interface/src/InterfaceMacOSX.mm new file mode 100644 index 0000000000..c834067324 --- /dev/null +++ b/interface/src/InterfaceMacOSX.mm @@ -0,0 +1,55 @@ +#import +#import + +@interface InterfaceMainMenuTarget : NSObject + +@property (strong, nonatomic) NSMenuItem *scopeAudioMenuItem; +@property (strong, nonatomic) NSMenuItem *scopeNoneMenuItem; + +@end + +@implementation InterfaceMainMenuTarget + +- (void)scopeAudioAction { + NSLog(@"scopeAudioAction"); +} + +- (void)scopeNoneAction { + NSLog(@"scopeNoneAction"); +} + +@end + +static InterfaceMainMenuTarget *sharedInterfaceMainMenuTarget = nil; + +void initMacOSXMenu() { + @autoreleasepool { + if (NSApp) { + if (!sharedInterfaceMainMenuTarget) { + sharedInterfaceMainMenuTarget = [[InterfaceMainMenuTarget alloc] init]; + } + + NSMenu *mainMenu = [NSApp mainMenu]; + + NSMenuItem *scopeMenuItem = [mainMenu insertItemWithTitle:@"Scope" + action:nil + keyEquivalent:@"" + atIndex:3]; + + NSMenu *scopeMenu = [[[NSMenu alloc] init] initWithTitle:@"Scope"]; + [scopeMenuItem setSubmenu:scopeMenu]; + sharedInterfaceMainMenuTarget.scopeAudioMenuItem = [scopeMenu addItemWithTitle:@"Audio" + action:@selector(scopeAudioAction) + keyEquivalent:@""]; + [sharedInterfaceMainMenuTarget.scopeAudioMenuItem setTarget:sharedInterfaceMainMenuTarget]; + [sharedInterfaceMainMenuTarget.scopeAudioMenuItem setState:NSOnState]; + + sharedInterfaceMainMenuTarget.scopeNoneMenuItem = [scopeMenu addItemWithTitle:@"None" + action:@selector(scopeNoneAction) + keyEquivalent:@""]; + [sharedInterfaceMainMenuTarget.scopeNoneMenuItem setTarget:sharedInterfaceMainMenuTarget]; + + [NSApp setMainMenu:mainMenu]; + } + } +} diff --git a/interface/src/main.cpp b/interface/src/main.cpp index 0f96ceb951..e20ef1a23d 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -44,6 +44,12 @@ #include "Oscilloscope.h" #include "UDPSocket.h" +#ifdef __APPLE__ + +#include "InterfaceMacOSX.h" + +#endif + using namespace std; int audio_on = 1; // Whether to turn on the audio support @@ -966,7 +972,11 @@ int main(int argc, char** argv) printf( "Init() complete.\n" ); glutTimerFunc(1000, Timer, 0); - + +#ifdef __APPLE__ + initMacOSXMenu(); +#endif + glutMainLoop(); pthread_join(networkReceiveThread, NULL); From 36a558d1236781d0bb72e66610f602d8d3ef2521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hor=C3=A1=C4=8Dek?= Date: Fri, 22 Feb 2013 18:38:25 +0100 Subject: [PATCH 2/9] add "Scope" menu functionality --- interface/src/InterfaceMacOSX.h | 4 +++- interface/src/InterfaceMacOSX.mm | 24 ++++++++++++++++++++---- interface/src/main.cpp | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/interface/src/InterfaceMacOSX.h b/interface/src/InterfaceMacOSX.h index 1416d637a4..2b36ff811f 100644 --- a/interface/src/InterfaceMacOSX.h +++ b/interface/src/InterfaceMacOSX.h @@ -1,6 +1,8 @@ #ifndef __interface__InterfaceMacOSX #define __interface__InterfaceMacOSX -void initMacOSXMenu(); +class Oscilloscope; + +void initMacOSXMenu(Oscilloscope *audioScope); #endif diff --git a/interface/src/InterfaceMacOSX.mm b/interface/src/InterfaceMacOSX.mm index c834067324..500dd6efc8 100644 --- a/interface/src/InterfaceMacOSX.mm +++ b/interface/src/InterfaceMacOSX.mm @@ -1,6 +1,16 @@ +#include "Oscilloscope.h" + #import #import +#import "InterfaceMacOSX.h" + +@class InterfaceMainMenuTarget; + +static InterfaceMainMenuTarget *sharedInterfaceMainMenuTarget = nil; +static Oscilloscope *sharedAudioScope; + + @interface InterfaceMainMenuTarget : NSObject @property (strong, nonatomic) NSMenuItem *scopeAudioMenuItem; @@ -8,21 +18,27 @@ @end + @implementation InterfaceMainMenuTarget - (void)scopeAudioAction { - NSLog(@"scopeAudioAction"); + sharedAudioScope->setState(true); + [self.scopeAudioMenuItem setState:NSOnState]; + [self.scopeNoneMenuItem setState:NSOffState]; } - (void)scopeNoneAction { - NSLog(@"scopeNoneAction"); + sharedAudioScope->setState(false); + [self.scopeAudioMenuItem setState:NSOffState]; + [self.scopeNoneMenuItem setState:NSOnState]; } @end -static InterfaceMainMenuTarget *sharedInterfaceMainMenuTarget = nil; -void initMacOSXMenu() { +void initMacOSXMenu(Oscilloscope *audioScope) { + sharedAudioScope = audioScope; + @autoreleasepool { if (NSApp) { if (!sharedInterfaceMainMenuTarget) { diff --git a/interface/src/main.cpp b/interface/src/main.cpp index e20ef1a23d..5ab8451f04 100644 --- a/interface/src/main.cpp +++ b/interface/src/main.cpp @@ -974,7 +974,7 @@ int main(int argc, char** argv) glutTimerFunc(1000, Timer, 0); #ifdef __APPLE__ - initMacOSXMenu(); + initMacOSXMenu(&audioScope); #endif glutMainLoop(); From 7d73ca9b418aa67143f5605fd1c30d02ac456654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hor=C3=A1=C4=8Dek?= Date: Fri, 22 Feb 2013 18:46:41 +0100 Subject: [PATCH 3/9] code cleanup --- interface/src/InterfaceMacOSX.mm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/interface/src/InterfaceMacOSX.mm b/interface/src/InterfaceMacOSX.mm index 500dd6efc8..466212207b 100644 --- a/interface/src/InterfaceMacOSX.mm +++ b/interface/src/InterfaceMacOSX.mm @@ -37,13 +37,12 @@ static Oscilloscope *sharedAudioScope; void initMacOSXMenu(Oscilloscope *audioScope) { - sharedAudioScope = audioScope; - @autoreleasepool { if (NSApp) { if (!sharedInterfaceMainMenuTarget) { sharedInterfaceMainMenuTarget = [[InterfaceMainMenuTarget alloc] init]; } + sharedAudioScope = audioScope; NSMenu *mainMenu = [NSApp mainMenu]; @@ -55,17 +54,15 @@ void initMacOSXMenu(Oscilloscope *audioScope) { NSMenu *scopeMenu = [[[NSMenu alloc] init] initWithTitle:@"Scope"]; [scopeMenuItem setSubmenu:scopeMenu]; sharedInterfaceMainMenuTarget.scopeAudioMenuItem = [scopeMenu addItemWithTitle:@"Audio" - action:@selector(scopeAudioAction) - keyEquivalent:@""]; + action:@selector(scopeAudioAction) + keyEquivalent:@""]; [sharedInterfaceMainMenuTarget.scopeAudioMenuItem setTarget:sharedInterfaceMainMenuTarget]; [sharedInterfaceMainMenuTarget.scopeAudioMenuItem setState:NSOnState]; sharedInterfaceMainMenuTarget.scopeNoneMenuItem = [scopeMenu addItemWithTitle:@"None" - action:@selector(scopeNoneAction) - keyEquivalent:@""]; + action:@selector(scopeNoneAction) + keyEquivalent:@""]; [sharedInterfaceMainMenuTarget.scopeNoneMenuItem setTarget:sharedInterfaceMainMenuTarget]; - - [NSApp setMainMenu:mainMenu]; } } } From cbc6e07362b197adb7d9d0a03797b5d68413a900 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 13:00:31 -0800 Subject: [PATCH 4/9] test for source of hifi-mini build failure --- CMakeLists.txt | 4 ++-- interface/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f7bc3a473..78d3019a69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.8) project(hifi) if(APPLE) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) - set(CMAKE_OSX_SYSROOT macosx) + # set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) +# set(CMAKE_OSX_SYSROOT macosx) endif() add_subdirectory(space) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 1c2c45f0e4..1d0c2b7264 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,8 +12,8 @@ if (APPLE) # link in required OS X frameworks and include the right GL headers set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") set(GL_HEADERS "#include \n#include ") - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) - set(CMAKE_OSX_SYSROOT macosx) + # set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) + # set(CMAKE_OSX_SYSROOT macosx) else (APPLE) # include the right GL headers for UNIX set(GL_HEADERS "#include \n#include \n#include ") From 64ecfa3b50ab50eecbdd20f0e1627e184b4cb87c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 13:05:03 -0800 Subject: [PATCH 5/9] Revert "test for source of hifi-mini build failure" This reverts commit cbc6e07362b197adb7d9d0a03797b5d68413a900. --- CMakeLists.txt | 4 ++-- interface/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d3019a69..9f7bc3a473 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 2.8) project(hifi) if(APPLE) - # set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) -# set(CMAKE_OSX_SYSROOT macosx) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) + set(CMAKE_OSX_SYSROOT macosx) endif() add_subdirectory(space) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 1d0c2b7264..1c2c45f0e4 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,8 +12,8 @@ if (APPLE) # link in required OS X frameworks and include the right GL headers set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") set(GL_HEADERS "#include \n#include ") - # set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) - # set(CMAKE_OSX_SYSROOT macosx) + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) + set(CMAKE_OSX_SYSROOT macosx) else (APPLE) # include the right GL headers for UNIX set(GL_HEADERS "#include \n#include \n#include ") From 28832177ac7b249287287461042cb42f0ad81b0f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 13:26:11 -0800 Subject: [PATCH 6/9] force use of 10.7 SDK to make hifi-mini happy again --- CMakeLists.txt | 2 +- interface/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f7bc3a473..415fe7e101 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(hifi) if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) - set(CMAKE_OSX_SYSROOT macosx) + set(CMAKE_OSX_SYSROOT macosx10.7) endif() add_subdirectory(space) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 1c2c45f0e4..aff2ef6fcf 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -13,7 +13,7 @@ if (APPLE) set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") set(GL_HEADERS "#include \n#include ") set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) - set(CMAKE_OSX_SYSROOT macosx) + set(CMAKE_OSX_SYSROOT macosx10.7) else (APPLE) # include the right GL headers for UNIX set(GL_HEADERS "#include \n#include \n#include ") From 127dbf8da301865aa0ac10fa0b3a91c88c754668 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 14:26:18 -0800 Subject: [PATCH 7/9] remove the deployment target specifier --- CMakeLists.txt | 1 - interface/CMakeLists.txt | 1 - 2 files changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 415fe7e101..c4219e21e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,6 @@ cmake_minimum_required(VERSION 2.8) project(hifi) if(APPLE) - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) set(CMAKE_OSX_SYSROOT macosx10.7) endif() diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index aff2ef6fcf..6306138e14 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,7 +12,6 @@ if (APPLE) # link in required OS X frameworks and include the right GL headers set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") set(GL_HEADERS "#include \n#include ") - set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7) set(CMAKE_OSX_SYSROOT macosx10.7) else (APPLE) # include the right GL headers for UNIX From 171c919946d6bc32f32b4827cf810cb9f201743b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 14:28:52 -0800 Subject: [PATCH 8/9] remove SDK specifiers alltogether to confirm cause of hifi-mini error --- CMakeLists.txt | 4 ---- interface/CMakeLists.txt | 1 - 2 files changed, 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4219e21e2..6e227c95f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,6 @@ cmake_minimum_required(VERSION 2.8) project(hifi) -if(APPLE) - set(CMAKE_OSX_SYSROOT macosx10.7) -endif() - add_subdirectory(space) add_subdirectory(domain) add_subdirectory(mixer) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 6306138e14..0685aca6cd 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -12,7 +12,6 @@ if (APPLE) # link in required OS X frameworks and include the right GL headers set(CMAKE_EXE_LINKER_FLAGS "-framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreServices -framework Carbon") set(GL_HEADERS "#include \n#include ") - set(CMAKE_OSX_SYSROOT macosx10.7) else (APPLE) # include the right GL headers for UNIX set(GL_HEADERS "#include \n#include \n#include ") From 7064beba8bdf78f8a3ef3f1dbe5db339449d3795 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 4 Mar 2013 15:10:53 -0800 Subject: [PATCH 9/9] fix calcuation of distance attenuation coefficient --- mixer/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixer/src/main.cpp b/mixer/src/main.cpp index 49ddd98bd8..dd6ad8c974 100644 --- a/mixer/src/main.cpp +++ b/mixer/src/main.cpp @@ -96,7 +96,7 @@ void *sendBuffer(void *args) int lowAgentIndex = std::min(i, j); int highAgentIndex = std::max(i, j); - if (distanceCoeffs[lowAgentIndex][highAgentIndex] != 0) { + if (distanceCoeffs[lowAgentIndex][highAgentIndex] == 0) { float distanceToAgent = sqrtf(powf(agentPosition[0] - otherAgentPosition[0], 2) + powf(agentPosition[1] - otherAgentPosition[1], 2) + powf(agentPosition[2] - otherAgentPosition[2], 2));