Add server only irrlicht device

This commit is contained in:
Benau 2020-06-14 15:07:15 +08:00
parent 128ef93abf
commit fa8665a360
6 changed files with 128 additions and 60 deletions

View File

@ -129,11 +129,9 @@ source/Irrlicht/CImageLoaderPNG.cpp
source/Irrlicht/CImageWriterBMP.cpp source/Irrlicht/CImageWriterBMP.cpp
source/Irrlicht/CImageWriterJPG.cpp source/Irrlicht/CImageWriterJPG.cpp
source/Irrlicht/CImageWriterPNG.cpp source/Irrlicht/CImageWriterPNG.cpp
source/Irrlicht/CIrrDeviceAndroid.cpp
source/Irrlicht/CIrrDeviceLinux.cpp
source/Irrlicht/CIrrDeviceSDL.cpp source/Irrlicht/CIrrDeviceSDL.cpp
source/Irrlicht/CIrrDeviceServer.cpp
source/Irrlicht/CIrrDeviceStub.cpp source/Irrlicht/CIrrDeviceStub.cpp
source/Irrlicht/CIrrDeviceWin32.cpp
source/Irrlicht/CLightSceneNode.cpp source/Irrlicht/CLightSceneNode.cpp
source/Irrlicht/CLimitReadFile.cpp source/Irrlicht/CLimitReadFile.cpp
source/Irrlicht/CLogger.cpp source/Irrlicht/CLogger.cpp
@ -260,11 +258,9 @@ source/Irrlicht/CImageLoaderPNG.h
source/Irrlicht/CImageWriterBMP.h source/Irrlicht/CImageWriterBMP.h
source/Irrlicht/CImageWriterJPG.h source/Irrlicht/CImageWriterJPG.h
source/Irrlicht/CImageWriterPNG.h source/Irrlicht/CImageWriterPNG.h
source/Irrlicht/CIrrDeviceAndroid.h
source/Irrlicht/CIrrDeviceLinux.h
source/Irrlicht/CIrrDeviceSDL.h source/Irrlicht/CIrrDeviceSDL.h
source/Irrlicht/CIrrDeviceServer.h
source/Irrlicht/CIrrDeviceStub.h source/Irrlicht/CIrrDeviceStub.h
source/Irrlicht/CIrrDeviceWin32.h
source/Irrlicht/CLightSceneNode.h source/Irrlicht/CLightSceneNode.h
source/Irrlicht/CLimitReadFile.h source/Irrlicht/CLimitReadFile.h
source/Irrlicht/CLogger.h source/Irrlicht/CLogger.h
@ -537,26 +533,6 @@ include/vector2d.h
include/vector3d.h include/vector3d.h
) )
if(APPLE AND NOT IOS)
set(IRRLICHT_SOURCES
${IRRLICHT_SOURCES}
source/Irrlicht/MacOSX/AppDelegate.mm
source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
source/Irrlicht/MacOSX/OSXClipboard.mm)
#list(APPEND CMAKE_C_SOURCE_FILE_EXTENSIONS mm)
#set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS cpp)
set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
set_source_files_properties(source/Irrlicht/MacOSX/AppDelegate.mm PROPERTIES LANGUAGE C)
set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
set_source_files_properties(source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm PROPERTIES LANGUAGE C)
set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES COMPILE_FLAGS "-x objective-c++ -O3 -fno-rtti")
set_source_files_properties(source/Irrlicht/MacOSX/OSXClipboard.mm PROPERTIES LANGUAGE C)
endif()
if(IOS) if(IOS)
set(IRRLICHT_SOURCES set(IRRLICHT_SOURCES
${IRRLICHT_SOURCES} ${IRRLICHT_SOURCES}
@ -579,5 +555,5 @@ if(NOT SERVER_ONLY)
endif() endif()
if(WIN32) if(WIN32)
target_link_libraries(stkirrlicht imm32) target_link_libraries(stkirrlicht)
endif() endif()

View File

@ -65,6 +65,8 @@ namespace irr
Does not need X11 or other graphical subsystems. Does not need X11 or other graphical subsystems.
May support hw-acceleration via OpenGL-ES */ May support hw-acceleration via OpenGL-ES */
EIDT_ANDROID, EIDT_ANDROID,
//! A device for STK server only compilation
EIDT_SERVER,
}; };
} // end namespace irr } // end namespace irr

View File

@ -45,23 +45,19 @@
//! Uncomment this line to compile with the SDL device //! Uncomment this line to compile with the SDL device
//#define _IRR_COMPILE_WITH_SDL_DEVICE_ //#define _IRR_COMPILE_WITH_SDL_DEVICE_
#ifdef NO_IRR_COMPILE_WITH_SDL_DEVICE_ // Always use SDL2 in STK unless server only compilation
#if defined(NO_IRR_COMPILE_WITH_SDL_DEVICE_) || defined(ANDROID)
#undef _IRR_COMPILE_WITH_SDL_DEVICE_ #undef _IRR_COMPILE_WITH_SDL_DEVICE_
#else
#define _IRR_COMPILE_WITH_SDL_DEVICE_
#endif #endif
//! WIN32 for Windows32 //! WIN32 for Windows32
//! WIN64 for Windows64 //! WIN64 for Windows64
// The windows platform and API support SDL and WINDOW device // The windows platform and API support SDL and WINDOW device
#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64) #if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(WIN64)
#define _IRR_WINDOWS_ #define _IRR_WINDOWS_
#define _IRR_WINDOWS_API_ #define _IRR_WINDOWS_API_
#ifndef NO_IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_SDL_DEVICE_
#undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#else
#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#endif
#endif #endif
@ -74,10 +70,6 @@
#undef _IRR_WINDOWS_ #undef _IRR_WINDOWS_
#define _IRR_XBOX_PLATFORM_ #define _IRR_XBOX_PLATFORM_
#define _IRR_WINDOWS_API_ #define _IRR_WINDOWS_API_
//#define _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#undef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
//#define _IRR_COMPILE_WITH_SDL_DEVICE_
#include <xtl.h> #include <xtl.h>
#endif #endif
@ -93,19 +85,8 @@
#define _IRR_COMPILE_WITH_SDL_DEVICE_ #define _IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_OGLES2_ #define _IRR_COMPILE_WITH_OGLES2_
#else #else
#ifndef NO_IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_SDL_DEVICE_
#undef _IRR_COMPILE_WITH_OSX_DEVICE_
#else
#define _IRR_COMPILE_WITH_OSX_DEVICE_
#endif #endif
#endif #endif
#endif
// Disable macOS/OSX device
#ifdef NO_IRR_COMPILE_WITH_OSX_DEVICE_
#undef _IRR_COMPILE_WITH_OSX_DEVICE_
#endif
#if defined(ANDROID) #if defined(ANDROID)
#define _IRR_ANDROID_PLATFORM_ #define _IRR_ANDROID_PLATFORM_
@ -123,12 +104,6 @@
#define _IRR_LINUX_PLATFORM_ #define _IRR_LINUX_PLATFORM_
#endif #endif
#define _IRR_POSIX_API_ #define _IRR_POSIX_API_
#ifndef NO_IRR_COMPILE_WITH_SDL_DEVICE_
#define _IRR_COMPILE_WITH_SDL_DEVICE_
#else
// For server only STK
#define _IRR_COMPILE_WITH_X11_DEVICE_
#endif
#endif #endif
#ifdef NO_IRR_COMPILE_WITH_WAYLAND_DEVICE_ #ifdef NO_IRR_COMPILE_WITH_WAYLAND_DEVICE_

View File

@ -0,0 +1,33 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "IrrCompileConfig.h"
#ifdef SERVER_ONLY
#include "CIrrDeviceServer.h"
#include "MobileCursorControl.h"
#include "SIrrCreationParameters.h"
namespace irr
{
//! constructor
CIrrDeviceServer::CIrrDeviceServer(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceServer");
#endif
Operator = 0;
CursorControl = new gui::MobileCursorControl();
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
createGUIAndScene();
}
} // end namespace irr
#endif // SERVER_ONLY

View File

@ -0,0 +1,79 @@
// Copyright (C) 2002-2012 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// This device code is based on the original SDL device implementation
// contributed by Shane Parker (sirshane).
#ifndef __C_IRR_DEVICE_SERVER_H_INCLUDED__
#define __C_IRR_DEVICE_SERVER_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef SERVER_ONLY
#include "IrrlichtDevice.h"
#include "CIrrDeviceStub.h"
namespace irr
{
class CIrrDeviceServer : public CIrrDeviceStub
{
public:
//! constructor
CIrrDeviceServer(const SIrrlichtCreationParameters& param);
//! runs the device. Returns false if device wants to be deleted
virtual bool run() { return !Close; }
//! pause execution temporarily
virtual void yield() {}
//! pause execution for a specified time
virtual void sleep(u32 timeMs, bool pauseTimer) {}
//! sets the caption of the window
virtual void setWindowCaption(const wchar_t* text) {}
//! sets the class of the window
virtual void setWindowClass(const char* text) {}
//! returns if window is active. if not, nothing need to be drawn
virtual bool isWindowActive() const { return true; }
//! returns if window has focus.
bool isWindowFocused() const { return true; }
//! returns if window is minimized.
bool isWindowMinimized() const { return false; }
//! notifies the device that it should close itself
virtual void closeDevice() { Close = true; }
//! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize=false) {}
//! Minimizes the window.
virtual void minimizeWindow() {}
//! Maximizes the window.
virtual void maximizeWindow() {}
//! Restores the window size.
virtual void restoreWindow() {}
//! Move window to requested position
virtual bool moveWindow(int x, int y) { return true; }
//! Get current window position.
virtual bool getWindowPosition(int* x, int* y) { return true; }
//! Get the device type
virtual E_DEVICE_TYPE getType() const { return EIDT_SERVER; }
};
} // end namespace irr
#endif // _IRR_COMPILE_WITH_SDL_DEVICE_
#endif // __C_IRR_DEVICE_SDL_H_INCLUDED__

View File

@ -34,6 +34,10 @@
#include "CIrrDeviceSDL.h" #include "CIrrDeviceSDL.h"
#endif #endif
#ifdef SERVER_ONLY
#include "CIrrDeviceServer.h"
#endif
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ #ifdef _IRR_COMPILE_WITH_IOS_DEVICE_
#include "CIrrDeviceiOS.h" #include "CIrrDeviceiOS.h"
#endif #endif
@ -120,9 +124,8 @@ namespace irr
SIrrlichtCreationParameters creation_params = params; SIrrlichtCreationParameters creation_params = params;
overrideDeviceType(creation_params.DeviceType); overrideDeviceType(creation_params.DeviceType);
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_ #ifdef SERVER_ONLY
if (creation_params.DeviceType == EIDT_IOS || (!dev && creation_params.DeviceType == EIDT_BEST)) dev = new CIrrDeviceServer(creation_params);
dev = new CIrrDeviceiOS(creation_params);
#endif #endif
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_