From fefd8efcda5bfd4dc74287366084a3d38fa28db9 Mon Sep 17 00:00:00 2001 From: yangchao <1162485779@qq.com> Date: Tue, 19 Jul 2022 13:42:21 +0800 Subject: [PATCH] mac server mod (#12054) * mac server mod Co-authored-by: bravetwo --- native/CMakeLists.txt | 3 ++- native/cocos/audio/apple/AudioEngine-inl.mm | 2 +- native/cocos/platform/mac/MacPlatform.mm | 2 +- native/cocos/platform/mac/View.h | 2 -- native/cocos/platform/mac/modules/SystemWindow.h | 2 +- native/cocos/platform/mac/modules/SystemWindow.mm | 6 +++++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index 184add1a9d..fb87d0fb4a 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -63,6 +63,7 @@ set(CC_USE_METAL ${CC_USE_METAL} CACHE INTERNAL "") if(USE_SERVER_MODE) set(CC_USE_VULKAN OFF) + set(CC_USE_METAL OFF) set(CC_USE_GLES3 OFF) set(CC_USE_GLES2 OFF) add_definitions(-DCC_SERVER_MODE) @@ -492,7 +493,7 @@ cocos_source_files( cocos/platform/interfaces/modules/canvas/ICanvasRenderingContext2D.cpp cocos/platform/interfaces/modules/canvas/ICanvasRenderingContext2D.h ) -if(USE_SERVER_MODE) +if(USE_SERVER_MODE AND (NOT MACOSX)) cocos_source_files( cocos/platform/empty/modules/CanvasRenderingContext2DDelegate.cpp cocos/platform/empty/modules/CanvasRenderingContext2DDelegate.h diff --git a/native/cocos/audio/apple/AudioEngine-inl.mm b/native/cocos/audio/apple/AudioEngine-inl.mm index cecaba063d..c268367dd7 100644 --- a/native/cocos/audio/apple/AudioEngine-inl.mm +++ b/native/cocos/audio/apple/AudioEngine-inl.mm @@ -39,7 +39,7 @@ #include "base/Utils.h" #include "base/memory/Memory.h" #include "platform/FileUtils.h" -#include "AudioDecoder.h"" +#include "AudioDecoder.h" using namespace cc; diff --git a/native/cocos/platform/mac/MacPlatform.mm b/native/cocos/platform/mac/MacPlatform.mm index 5fc3593397..e8e82585d2 100644 --- a/native/cocos/platform/mac/MacPlatform.mm +++ b/native/cocos/platform/mac/MacPlatform.mm @@ -118,7 +118,7 @@ int32_t MacPlatform::init() { registerInterface(std::make_shared()); registerInterface(std::make_shared()); registerInterface(std::make_shared()); - registerInterface(std::make_shared()); + registerInterface(std::make_shared(this)); registerInterface(std::make_shared()); return 0; } diff --git a/native/cocos/platform/mac/View.h b/native/cocos/platform/mac/View.h index 890da35fb3..e49a72b8b5 100644 --- a/native/cocos/platform/mac/View.h +++ b/native/cocos/platform/mac/View.h @@ -28,8 +28,6 @@ @interface View : NSView -#ifdef CC_USE_METAL @property (nonatomic, assign) id device; -#endif @end diff --git a/native/cocos/platform/mac/modules/SystemWindow.h b/native/cocos/platform/mac/modules/SystemWindow.h index 9b6f59a8d0..4d90c808e4 100644 --- a/native/cocos/platform/mac/modules/SystemWindow.h +++ b/native/cocos/platform/mac/modules/SystemWindow.h @@ -33,7 +33,7 @@ namespace cc { class SystemWindow : public ISystemWindow { public: - SystemWindow(); + SystemWindow(IEventDispatch *delegate); ~SystemWindow() override; bool createWindow(const char* title, diff --git a/native/cocos/platform/mac/modules/SystemWindow.mm b/native/cocos/platform/mac/modules/SystemWindow.mm index 3abd7af9a7..e6c88fb325 100644 --- a/native/cocos/platform/mac/modules/SystemWindow.mm +++ b/native/cocos/platform/mac/modules/SystemWindow.mm @@ -33,7 +33,7 @@ namespace { namespace cc { -SystemWindow::SystemWindow() = default; +SystemWindow::SystemWindow(IEventDispatch *delegate) {} SystemWindow::~SystemWindow() = default; @@ -47,7 +47,9 @@ bool SystemWindow::createWindow(const char *title, _height = h; AppDelegate *delegate = [[NSApplication sharedApplication] delegate]; NSString *aString = [NSString stringWithUTF8String:title]; +#if !defined(CC_SERVER_MODE) [delegate createLeftBottomWindow:aString width:w height:h]; +#endif return true; } @@ -62,7 +64,9 @@ bool SystemWindow::createWindow(const char *title, _height = h; AppDelegate *delegate = [[NSApplication sharedApplication] delegate]; NSString *aString = [NSString stringWithUTF8String:title]; +#if !defined(CC_SERVER_MODE) [delegate createWindow:aString xPos:x yPos:y width:w height:h]; +#endif return true; } void SystemWindow::closeWindow() {