V3.5.1 no window (#11016)

This commit is contained in:
yangchao
2022-05-12 09:43:46 +08:00
committed by GitHub
parent 60e44f7564
commit bd1c1e0088
13 changed files with 115 additions and 128 deletions
+4 -2
View File
@@ -25,7 +25,7 @@
import { JSB } from 'internal:constants';
import { JSB, SERVER_MODE } from 'internal:constants';
import { builtinResMgr } from './builtin';
import { Pool } from './memop';
import { RenderPipeline, createDefaultPipeline, DeferredPipeline } from './pipeline';
@@ -450,7 +450,9 @@ export class Root {
legacyCC.director.emit(legacyCC.Director.EVENT_BEFORE_COMMIT);
cameraList.sort((a: Camera, b: Camera) => a.priority - b.priority);
this._pipeline.render(cameraList);
if (!SERVER_MODE) {
this._pipeline.render(cameraList);
}
this._device.present();
}
+50 -46
View File
@@ -353,12 +353,6 @@ cocos_source_files(
)
############ main
if(USE_SERVER_MODE)
cocos_source_files(
cocos/main/EmptyMain.cpp
)
endif()
if(NOT USE_SERVER_MODE AND (WINDOWS OR LINUX))
cocos_source_files(
cocos/platform/SDLHelper.h
@@ -374,12 +368,7 @@ cocos_source_files(
cocos/platform/UniversalPlatform.cpp
cocos/platform/UniversalPlatform.h
)
if(USE_SERVER_MODE)
cocos_source_files(
cocos/platform/empty/EmptyPlatform.cpp
cocos/platform/empty/EmptyPlatform.h
)
elseif(WINDOWS)
if(WINDOWS)
cocos_source_files(
cocos/platform/win32/WindowsPlatform.cpp
cocos/platform/win32/WindowsPlatform.h
@@ -474,40 +463,34 @@ endif()
############ platform : Interface implementation of windows
if(USE_SERVER_MODE)
cocos_source_files(
cocos/platform/empty/modules/Accelerometer.cpp
cocos/platform/empty/modules/Accelerometer.h
cocos/platform/empty/modules/Battery.cpp
cocos/platform/empty/modules/Battery.h
cocos/platform/empty/modules/Screen.cpp
cocos/platform/empty/modules/Screen.h
cocos/platform/empty/modules/Network.cpp
cocos/platform/empty/modules/Network.h
cocos/platform/empty/modules/Vibrator.cpp
cocos/platform/empty/modules/Vibrator.h
cocos/platform/empty/modules/System.cpp
cocos/platform/empty/modules/System.h
cocos/platform/empty/modules/SystemWindow.cpp
cocos/platform/empty/modules/SystemWindow.h
)
elseif(WINDOWS)
if(WINDOWS)
cocos_source_files(
cocos/platform/win32/modules/Accelerometer.cpp
cocos/platform/win32/modules/Accelerometer.h
cocos/platform/win32/modules/Battery.cpp
cocos/platform/win32/modules/Battery.h
cocos/platform/win32/modules/Screen.cpp
cocos/platform/win32/modules/Screen.h
cocos/platform/win32/modules/Network.cpp
cocos/platform/win32/modules/Network.h
cocos/platform/win32/modules/Vibrator.cpp
cocos/platform/win32/modules/Vibrator.h
cocos/platform/win32/modules/System.cpp
cocos/platform/win32/modules/System.h
cocos/platform/win32/modules/SystemWindow.cpp
cocos/platform/win32/modules/SystemWindow.h
)
if(USE_SERVER_MODE)
cocos_source_files(
cocos/platform/empty/modules/Screen.cpp
cocos/platform/empty/modules/Screen.h
cocos/platform/empty/modules/SystemWindow.cpp
cocos/platform/empty/modules/SystemWindow.h
)
else()
cocos_source_files(
cocos/platform/win32/modules/Screen.cpp
cocos/platform/win32/modules/Screen.h
cocos/platform/win32/modules/SystemWindow.cpp
cocos/platform/win32/modules/SystemWindow.h
)
endif()
elseif(ANDROID OR OHOS)
cocos_source_files(
cocos/platform/java/modules/Accelerometer.cpp
@@ -526,9 +509,8 @@ elseif(ANDROID OR OHOS)
cocos/platform/java/modules/SystemWindow.h
)
endif()
if (USE_SERVER_MODE)
#nothing
elseif(ANDROID)
if(ANDROID)
cocos_source_files(
cocos/platform/android/modules/Screen.cpp
cocos/platform/android/modules/Screen.h
@@ -548,17 +530,28 @@ elseif(MACOSX)
cocos/platform/mac/modules/Accelerometer.h
cocos/platform/mac/modules/Battery.mm
cocos/platform/mac/modules/Battery.h
cocos/platform/mac/modules/Screen.mm
cocos/platform/mac/modules/Screen.h
cocos/platform/mac/modules/Network.mm
cocos/platform/mac/modules/Network.h
cocos/platform/mac/modules/Vibrator.mm
cocos/platform/mac/modules/Vibrator.h
cocos/platform/mac/modules/System.mm
cocos/platform/mac/modules/System.h
cocos/platform/mac/modules/SystemWindow.mm
cocos/platform/mac/modules/SystemWindow.h
)
if(USE_SERVER_MODE)
cocos_source_files(
cocos/platform/empty/modules/Screen.cpp
cocos/platform/empty/modules/Screen.h
cocos/platform/empty/modules/SystemWindow.cpp
cocos/platform/empty/modules/SystemWindow.h
)
else()
cocos_source_files(
cocos/platform/mac/modules/Screen.mm
cocos/platform/mac/modules/Screen.h
cocos/platform/mac/modules/SystemWindow.mm
cocos/platform/mac/modules/SystemWindow.h
)
endif()
elseif(IOS)
cocos_source_files(
cocos/platform/ios/modules/Accelerometer.mm
@@ -582,17 +575,28 @@ elseif(LINUX)
cocos/platform/linux/modules/Accelerometer.h
cocos/platform/linux/modules/Battery.cpp
cocos/platform/linux/modules/Battery.h
cocos/platform/linux/modules/Screen.cpp
cocos/platform/linux/modules/Screen.h
cocos/platform/linux/modules/Network.cpp
cocos/platform/linux/modules/Network.h
cocos/platform/linux/modules/Vibrator.cpp
cocos/platform/linux/modules/Vibrator.h
cocos/platform/linux/modules/System.cpp
cocos/platform/linux/modules/System.h
cocos/platform/linux/modules/SystemWindow.cpp
cocos/platform/linux/modules/SystemWindow.h
)
if(USE_SERVER_MODE)
cocos_source_files(
cocos/platform/empty/modules/Screen.cpp
cocos/platform/empty/modules/Screen.h
cocos/platform/empty/modules/SystemWindow.cpp
cocos/platform/empty/modules/SystemWindow.h
)
else()
cocos_source_files(
cocos/platform/linux/modules/Screen.cpp
cocos/platform/linux/modules/Screen.h
cocos/platform/linux/modules/SystemWindow.cpp
cocos/platform/linux/modules/SystemWindow.h
)
endif()
endif()
############ module log
@@ -2481,4 +2485,4 @@ elseif(LINUX)
${LINUX_GRAPHIC_LIBS}
${CC_EXTERNAL_LIBS}
)
endif()
endif()
+2 -6
View File
@@ -24,9 +24,7 @@
****************************************************************************/
#include "platform/BasePlatform.h"
#if defined(CC_SERVER_MODE)
#include "platform/empty/EmptyPlatform.h"
#elif (CC_PLATFORM == CC_PLATFORM_WINDOWS)
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
#include "platform/win32/WindowsPlatform.h"
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/AndroidPlatform.h"
@@ -55,9 +53,7 @@ BasePlatform::~BasePlatform() {
}
BasePlatform* BasePlatform::createDefaultPlatform() {
#if defined(CC_SERVER_MODE)
static EmptyPlatform platform;
#elif (CC_PLATFORM == CC_PLATFORM_WINDOWS)
#if (CC_PLATFORM == CC_PLATFORM_WINDOWS)
static WindowsPlatform platform;
#elif (CC_PLATFORM == CC_PLATFORM_ANDROID)
static AndroidPlatform platform;
+3 -63
View File
@@ -25,10 +25,8 @@
#include "platform/empty/modules/System.h"
#include <string.h>
#include <sys/utsname.h>
namespace cc {
using OSType = System::OSType;
OSType System::getOSType() const {
@@ -40,31 +38,11 @@ std::string System::getDeviceModel() const {
}
System::LanguageType System::getCurrentLanguage() const {
char* pLanguageName = getenv("LANG");
if (!pLanguageName) {
return LanguageType::ENGLISH;
}
strtok(pLanguageName, "_");
if (!pLanguageName) {
return LanguageType::ENGLISH;
}
return getLanguageTypeByISO2(pLanguageName);
return LanguageType::ENGLISH;
}
std::string System::getCurrentLanguageCode() const {
static char code[3] = {0};
char* pLanguageName = getenv("LANG");
if (!pLanguageName) {
return "en";
}
strtok(pLanguageName, "_");
if (!pLanguageName) {
return "en";
}
strncpy(code, pLanguageName, 2);
code[2] = '\0';
return code;
return "en";
}
std::string System::getSystemVersion() const {
@@ -79,44 +57,6 @@ System::LanguageType System::getLanguageTypeByISO2(const char* code) const {
// this function is used by all platforms to get system language
// except windows: cocos/platform/win32/CCApplication-win32.cpp
LanguageType ret = LanguageType::ENGLISH;
if (strncmp(code, "zh", 2) == 0) {
ret = LanguageType::CHINESE;
} else if (strncmp(code, "ja", 2) == 0) {
ret = LanguageType::JAPANESE;
} else if (strncmp(code, "fr", 2) == 0) {
ret = LanguageType::FRENCH;
} else if (strncmp(code, "it", 2) == 0) {
ret = LanguageType::ITALIAN;
} else if (strncmp(code, "de", 2) == 0) {
ret = LanguageType::GERMAN;
} else if (strncmp(code, "es", 2) == 0) {
ret = LanguageType::SPANISH;
} else if (strncmp(code, "nl", 2) == 0) {
ret = LanguageType::DUTCH;
} else if (strncmp(code, "ru", 2) == 0) {
ret = LanguageType::RUSSIAN;
} else if (strncmp(code, "hu", 2) == 0) {
ret = LanguageType::HUNGARIAN;
} else if (strncmp(code, "pt", 2) == 0) {
ret = LanguageType::PORTUGUESE;
} else if (strncmp(code, "ko", 2) == 0) {
ret = LanguageType::KOREAN;
} else if (strncmp(code, "ar", 2) == 0) {
ret = LanguageType::ARABIC;
} else if (strncmp(code, "nb", 2) == 0) {
ret = LanguageType::NORWEGIAN;
} else if (strncmp(code, "pl", 2) == 0) {
ret = LanguageType::POLISH;
} else if (strncmp(code, "tr", 2) == 0) {
ret = LanguageType::TURKISH;
} else if (strncmp(code, "uk", 2) == 0) {
ret = LanguageType::UKRAINIAN;
} else if (strncmp(code, "ro", 2) == 0) {
ret = LanguageType::ROMANIAN;
} else if (strncmp(code, "bg", 2) == 0) {
ret = LanguageType::BULGARIAN;
}
return ret;
}
} // namespace cc
} // namespace cc
@@ -39,7 +39,7 @@ namespace {
} // namespace
namespace cc {
SystemWindow::SystemWindow() {
SystemWindow::SystemWindow(IEventDispatch* delegate) {
}
SystemWindow::~SystemWindow() {
@@ -56,8 +56,20 @@ void SystemWindow::copyTextToClipboard(const std::string &text) {
//TODO
}
int SystemWindow::init() {
return 0;
}
void SystemWindow::pollEvent(bool* quit) {
return;
}
void SystemWindow::swapWindow() {
return;
}
SystemWindow::Size SystemWindow::getViewSize() const {
return Size{static_cast<float>(_width), static_cast<float>(_height)};
}
} // namespace cc
} // namespace cc
@@ -33,7 +33,7 @@ namespace cc {
class CC_DLL SystemWindow : public ISystemWindow {
public:
explicit SystemWindow();
explicit SystemWindow(IEventDispatch* delegate);
~SystemWindow() override;
uintptr_t getWindowHandler() const override;
@@ -45,6 +45,10 @@ public:
void setCursorEnabled(bool value) override;
void copyTextToClipboard(const std::string& text) override;
int init();
void pollEvent(bool* quit);
void swapWindow();
private:
int _width{0};
int _height{0};
@@ -33,11 +33,17 @@
#include "modules/Accelerometer.h"
#include "modules/Battery.h"
#include "modules/Network.h"
#include "modules/Screen.h"
#include "modules/System.h"
#include "modules/SystemWindow.h"
#include "modules/Vibrator.h"
#if defined(CC_SERVER_MODE)
#include "platform/empty/modules/Screen.h"
#include "platform/empty/modules/SystemWindow.h"
#else
#include "modules/Screen.h"
#include "modules/SystemWindow.h"
#endif
namespace {
} // namespace
+8 -2
View File
@@ -30,11 +30,17 @@
#include "modules/Accelerometer.h"
#include "modules/Battery.h"
#include "modules/Network.h"
#include "modules/Screen.h"
#include "modules/System.h"
#include "modules/SystemWindow.h"
#include "modules/Vibrator.h"
#if defined(CC_SERVER_MODE)
#include "platform/empty/modules/Screen.h"
#include "platform/empty/modules/SystemWindow.h"
#else
#include "modules/Screen.h"
#include "modules/SystemWindow.h"
#endif
#import <AppKit/AppKit.h>
extern int cocos_main(int argc, const char** argv);
@@ -32,9 +32,14 @@
#include "modules/Accelerometer.h"
#include "modules/Battery.h"
#include "modules/Network.h"
#include "modules/Screen.h"
#include "modules/System.h"
#include "modules/SystemWindow.h"
#if defined(CC_SERVER_MODE)
#include "platform/empty/modules/Screen.h"
#include "platform/empty/modules/SystemWindow.h"
#else
#include "modules/Screen.h"
#include "modules/SystemWindow.h"
#endif
#include "modules/Vibrator.h"
namespace {
+2
View File
@@ -122,9 +122,11 @@ private:
device = CC_NEW(gfx::DeviceAgent(device));
}
#if !defined(CC_SERVER_MODE)
if (CC_DEBUG > 0 && !FORCE_DISABLE_VALIDATION || FORCE_ENABLE_VALIDATION) {
device = CC_NEW(gfx::DeviceValidator(device));
}
#endif
if (!device->initialize(info)) {
CC_SAFE_DELETE(device);
@@ -37,7 +37,9 @@ Swapchain::Swapchain()
Swapchain::~Swapchain() = default;
void Swapchain::initialize(const SwapchainInfo &info) {
#if !defined(CC_SERVER_MODE)
CCASSERT(info.windowHandle, "Invalid window handle");
#endif
_windowHandle = info.windowHandle;
_vsyncMode = info.vsyncMode;
@@ -73,7 +73,6 @@ bool EmptyDevice::doInit(const DeviceInfo & /*info*/) {
_formatFeatures.fill(static_cast<FormatFeature>(-1)); // allow all usages for all formats
_formatFeatures[toNumber(Format::UNKNOWN)] = FormatFeature::NONE;
_formatFeatures[toNumber(Format::COUNT)] = FormatFeature::NONE;
CC_LOG_INFO("Empty device initialized.");
+10 -1
View File
@@ -26,8 +26,17 @@
#include <iostream>
#include "platform/BasePlatform.h"
#if defined(CC_SERVER_MODE)
#include <windows.h>
int WINAPI
WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) {
START_PLATFORM(0, nullptr);
}
#else
#include "sdl2/SDL_main.h"
int SDL_main(int argc, char** argv) {
START_PLATFORM(argc, (const char**)argv);
}
}
#endif