From 103f0c2ab0c9c4c54d168b98a86bc10d0dac0449 Mon Sep 17 00:00:00 2001 From: assiduous Date: Thu, 30 Jan 2020 19:38:22 -0800 Subject: Renamed .h -> .hpp where appropriate --- NativeApp/include/Android/AndroidAppBase.h | 113 --------------------------- NativeApp/include/Android/AndroidAppBase.hpp | 113 +++++++++++++++++++++++++++ NativeApp/include/AppBase.h | 68 ---------------- NativeApp/include/AppBase.hpp | 68 ++++++++++++++++ NativeApp/include/IOS/IOSAppBase.h | 47 ----------- NativeApp/include/IOS/IOSAppBase.hpp | 47 +++++++++++ NativeApp/include/Linux/LinuxAppBase.h | 65 --------------- NativeApp/include/Linux/LinuxAppBase.hpp | 65 +++++++++++++++ NativeApp/include/MacOS/MacOSAppBase.h | 45 ----------- NativeApp/include/MacOS/MacOSAppBase.hpp | 45 +++++++++++ NativeApp/include/NativeAppBase.h | 87 --------------------- NativeApp/include/NativeAppBase.hpp | 87 +++++++++++++++++++++ NativeApp/include/UWP/UWPAppBase.h | 76 ------------------ NativeApp/include/UWP/UWPAppBase.hpp | 76 ++++++++++++++++++ NativeApp/include/Win32/Win32AppBase.h | 56 ------------- NativeApp/include/Win32/Win32AppBase.hpp | 56 +++++++++++++ 16 files changed, 557 insertions(+), 557 deletions(-) delete mode 100644 NativeApp/include/Android/AndroidAppBase.h create mode 100644 NativeApp/include/Android/AndroidAppBase.hpp delete mode 100644 NativeApp/include/AppBase.h create mode 100644 NativeApp/include/AppBase.hpp delete mode 100644 NativeApp/include/IOS/IOSAppBase.h create mode 100644 NativeApp/include/IOS/IOSAppBase.hpp delete mode 100644 NativeApp/include/Linux/LinuxAppBase.h create mode 100644 NativeApp/include/Linux/LinuxAppBase.hpp delete mode 100644 NativeApp/include/MacOS/MacOSAppBase.h create mode 100644 NativeApp/include/MacOS/MacOSAppBase.hpp delete mode 100644 NativeApp/include/NativeAppBase.h create mode 100644 NativeApp/include/NativeAppBase.hpp delete mode 100644 NativeApp/include/UWP/UWPAppBase.h create mode 100644 NativeApp/include/UWP/UWPAppBase.hpp delete mode 100644 NativeApp/include/Win32/Win32AppBase.h create mode 100644 NativeApp/include/Win32/Win32AppBase.hpp (limited to 'NativeApp/include') diff --git a/NativeApp/include/Android/AndroidAppBase.h b/NativeApp/include/Android/AndroidAppBase.h deleted file mode 100644 index 0b291c6..0000000 --- a/NativeApp/include/Android/AndroidAppBase.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include - -#include -#include "AppBase.h" - -#include "NDKHelper.h" - -struct android_app; - -namespace Diligent -{ - -class AndroidAppBase : public AppBase -{ -public: - int InitDisplay(); - void SetState(android_app* state, const char* native_activity_class_name); - void InitSensors(); - void ProcessSensors(int32_t id); - void DrawFrame(); - bool IsReady(); - virtual void TrimMemory() = 0; - virtual void TermDisplay() = 0; - static int32_t HandleInput(android_app* app, AInputEvent* event); - static void HandleCmd(android_app* app, int32_t cmd); - - bool CheckWindowSizeChanged() - { - auto new_window_width_ = ANativeWindow_getWidth(app_->window); - auto new_window_height_ = ANativeWindow_getHeight(app_->window); - if (new_window_width_ != window_width_ || new_window_height_ != window_height_) - { - window_width_ = new_window_width_; - window_height_ = new_window_height_; - return true; - } - else - return false; - } - -protected: - virtual void Initialize() - { - CheckWindowSizeChanged(); - } - - virtual int Resume(ANativeWindow* window) = 0; - - virtual int32_t HandleInput(AInputEvent* event) { return 0; } - - virtual void LoadResources() - { - //renderer_.Init(); - //renderer_.Bind( &tap_camera_ ); - } - - virtual void UnloadResources() - { - //renderer_.Unload(); - } - - ndk_helper::DoubletapDetector doubletap_detector_; - ndk_helper::PinchDetector pinch_detector_; - ndk_helper::DragDetector drag_detector_; - ndk_helper::PerfMonitor monitor_; - - //ndk_helper::TapCamera tap_camera_; - android_app* app_ = nullptr; - std::string native_activity_class_name_; - -private: - void UpdatePosition(AInputEvent* event, int32_t iIndex, float& fX, float& fY); - void SuspendSensors(); - void ResumeSensors(); - void ShowUI(); - void UpdateFPS(float fFPS); - - bool initialized_resources_ = false; - bool has_focus_ = false; - int32_t window_width_ = 0; - int32_t window_height_ = 0; - - ASensorManager* sensor_manager_ = nullptr; - const ASensor* accelerometer_sensor_ = nullptr; - ASensorEventQueue* sensor_event_queue_ = nullptr; -}; - -} // namespace Diligent diff --git a/NativeApp/include/Android/AndroidAppBase.hpp b/NativeApp/include/Android/AndroidAppBase.hpp new file mode 100644 index 0000000..fa42798 --- /dev/null +++ b/NativeApp/include/Android/AndroidAppBase.hpp @@ -0,0 +1,113 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include + +#include +#include "AppBase.hpp" + +#include "NDKHelper.h" + +struct android_app; + +namespace Diligent +{ + +class AndroidAppBase : public AppBase +{ +public: + int InitDisplay(); + void SetState(android_app* state, const char* native_activity_class_name); + void InitSensors(); + void ProcessSensors(int32_t id); + void DrawFrame(); + bool IsReady(); + virtual void TrimMemory() = 0; + virtual void TermDisplay() = 0; + static int32_t HandleInput(android_app* app, AInputEvent* event); + static void HandleCmd(android_app* app, int32_t cmd); + + bool CheckWindowSizeChanged() + { + auto new_window_width_ = ANativeWindow_getWidth(app_->window); + auto new_window_height_ = ANativeWindow_getHeight(app_->window); + if (new_window_width_ != window_width_ || new_window_height_ != window_height_) + { + window_width_ = new_window_width_; + window_height_ = new_window_height_; + return true; + } + else + return false; + } + +protected: + virtual void Initialize() + { + CheckWindowSizeChanged(); + } + + virtual int Resume(ANativeWindow* window) = 0; + + virtual int32_t HandleInput(AInputEvent* event) { return 0; } + + virtual void LoadResources() + { + //renderer_.Init(); + //renderer_.Bind( &tap_camera_ ); + } + + virtual void UnloadResources() + { + //renderer_.Unload(); + } + + ndk_helper::DoubletapDetector doubletap_detector_; + ndk_helper::PinchDetector pinch_detector_; + ndk_helper::DragDetector drag_detector_; + ndk_helper::PerfMonitor monitor_; + + //ndk_helper::TapCamera tap_camera_; + android_app* app_ = nullptr; + std::string native_activity_class_name_; + +private: + void UpdatePosition(AInputEvent* event, int32_t iIndex, float& fX, float& fY); + void SuspendSensors(); + void ResumeSensors(); + void ShowUI(); + void UpdateFPS(float fFPS); + + bool initialized_resources_ = false; + bool has_focus_ = false; + int32_t window_width_ = 0; + int32_t window_height_ = 0; + + ASensorManager* sensor_manager_ = nullptr; + const ASensor* accelerometer_sensor_ = nullptr; + ASensorEventQueue* sensor_event_queue_ = nullptr; +}; + +} // namespace Diligent diff --git a/NativeApp/include/AppBase.h b/NativeApp/include/AppBase.h deleted file mode 100644 index 4f7414b..0000000 --- a/NativeApp/include/AppBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -namespace Diligent -{ - -class AppBase -{ -public: - enum class GoldenImageMode - { - None = 0, - Capture, - Compare - }; - - virtual ~AppBase() {} - - virtual void ProcessCommandLine(const char* CmdLine) = 0; - virtual const char* GetAppTitle() const = 0; - virtual void Update(double CurrTime, double ElapsedTime){}; - virtual void Render() = 0; - virtual void Present() = 0; - virtual void WindowResize(int width, int height) = 0; - virtual void GetDesiredInitialWindowSize(int& width, int& height) - { - width = 0; - height = 0; - } - - virtual GoldenImageMode GetGoldenImageMode() const - { - return GoldenImageMode::None; - } - - virtual int GetExitCode() const - { - return 0; - } -}; - -} // namespace Diligent diff --git a/NativeApp/include/AppBase.hpp b/NativeApp/include/AppBase.hpp new file mode 100644 index 0000000..4f7414b --- /dev/null +++ b/NativeApp/include/AppBase.hpp @@ -0,0 +1,68 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +namespace Diligent +{ + +class AppBase +{ +public: + enum class GoldenImageMode + { + None = 0, + Capture, + Compare + }; + + virtual ~AppBase() {} + + virtual void ProcessCommandLine(const char* CmdLine) = 0; + virtual const char* GetAppTitle() const = 0; + virtual void Update(double CurrTime, double ElapsedTime){}; + virtual void Render() = 0; + virtual void Present() = 0; + virtual void WindowResize(int width, int height) = 0; + virtual void GetDesiredInitialWindowSize(int& width, int& height) + { + width = 0; + height = 0; + } + + virtual GoldenImageMode GetGoldenImageMode() const + { + return GoldenImageMode::None; + } + + virtual int GetExitCode() const + { + return 0; + } +}; + +} // namespace Diligent diff --git a/NativeApp/include/IOS/IOSAppBase.h b/NativeApp/include/IOS/IOSAppBase.h deleted file mode 100644 index c7def32..0000000 --- a/NativeApp/include/IOS/IOSAppBase.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "AppBase.h" -#include "Timer.hpp" - -namespace Diligent -{ - -class IOSAppBase : public AppBase -{ -public: - using AppBase::Update; - void Update(); - virtual void Initialize(int deviceType, void* layer) = 0; - virtual void OnTouchBegan(float x, float y) {} - virtual void OnTouchMoved(float x, float y) {} - virtual void OnTouchEnded(float x, float y) {} - -protected: - Timer timer; - double PrevTime = 0.0; -}; - -} // namespace Diligent diff --git a/NativeApp/include/IOS/IOSAppBase.hpp b/NativeApp/include/IOS/IOSAppBase.hpp new file mode 100644 index 0000000..61a4f0d --- /dev/null +++ b/NativeApp/include/IOS/IOSAppBase.hpp @@ -0,0 +1,47 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "AppBase.hpp" +#include "Timer.hpp" + +namespace Diligent +{ + +class IOSAppBase : public AppBase +{ +public: + using AppBase::Update; + void Update(); + virtual void Initialize(int deviceType, void* layer) = 0; + virtual void OnTouchBegan(float x, float y) {} + virtual void OnTouchMoved(float x, float y) {} + virtual void OnTouchEnded(float x, float y) {} + +protected: + Timer timer; + double PrevTime = 0.0; +}; + +} // namespace Diligent diff --git a/NativeApp/include/Linux/LinuxAppBase.h b/NativeApp/include/Linux/LinuxAppBase.h deleted file mode 100644 index 3d98606..0000000 --- a/NativeApp/include/Linux/LinuxAppBase.h +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - - -#include -#include - -// Undef symbols defined by XLib -#ifdef Bool -# undef Bool -#endif -#ifdef True -# undef True -#endif -#ifdef False -# undef False -#endif -#ifdef None -# undef None -#endif - -#if VULKAN_SUPPORTED -# include -#endif - -#include "AppBase.h" - -namespace Diligent -{ - -class LinuxAppBase : public AppBase -{ -public: - virtual void OnGLContextCreated(Display* display, Window window) = 0; - virtual int HandleXEvent(XEvent* xev) {} - -#if VULKAN_SUPPORTED - virtual bool InitVulkan(xcb_connection_t* connection, uint32_t window) = 0; - virtual void HandleXCBEvent(xcb_generic_event_t* event) {} -#endif -}; - -} // namespace Diligent diff --git a/NativeApp/include/Linux/LinuxAppBase.hpp b/NativeApp/include/Linux/LinuxAppBase.hpp new file mode 100644 index 0000000..e0bbda7 --- /dev/null +++ b/NativeApp/include/Linux/LinuxAppBase.hpp @@ -0,0 +1,65 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + + +#include +#include + +// Undef symbols defined by XLib +#ifdef Bool +# undef Bool +#endif +#ifdef True +# undef True +#endif +#ifdef False +# undef False +#endif +#ifdef None +# undef None +#endif + +#if VULKAN_SUPPORTED +# include +#endif + +#include "AppBase.hpp" + +namespace Diligent +{ + +class LinuxAppBase : public AppBase +{ +public: + virtual void OnGLContextCreated(Display* display, Window window) = 0; + virtual int HandleXEvent(XEvent* xev) {} + +#if VULKAN_SUPPORTED + virtual bool InitVulkan(xcb_connection_t* connection, uint32_t window) = 0; + virtual void HandleXCBEvent(xcb_generic_event_t* event) {} +#endif +}; + +} // namespace Diligent diff --git a/NativeApp/include/MacOS/MacOSAppBase.h b/NativeApp/include/MacOS/MacOSAppBase.h deleted file mode 100644 index 34bc47c..0000000 --- a/NativeApp/include/MacOS/MacOSAppBase.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#include "AppBase.h" -#include "Timer.hpp" - -namespace Diligent -{ - -class MacOSAppBase : public AppBase -{ -public: - using AppBase::Update; - void Update(); - virtual void Initialize(void* view) = 0; - virtual void HandleOSXEvent(void* event, void* view){}; - -protected: - Timer timer; - double PrevTime = 0.0; -}; - -} // namespace Diligent diff --git a/NativeApp/include/MacOS/MacOSAppBase.hpp b/NativeApp/include/MacOS/MacOSAppBase.hpp new file mode 100644 index 0000000..87f7702 --- /dev/null +++ b/NativeApp/include/MacOS/MacOSAppBase.hpp @@ -0,0 +1,45 @@ +/* Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#include "AppBase.hpp" +#include "Timer.hpp" + +namespace Diligent +{ + +class MacOSAppBase : public AppBase +{ +public: + using AppBase::Update; + void Update(); + virtual void Initialize(void* view) = 0; + virtual void HandleOSXEvent(void* event, void* view){}; + +protected: + Timer timer; + double PrevTime = 0.0; +}; + +} // namespace Diligent diff --git a/NativeApp/include/NativeAppBase.h b/NativeApp/include/NativeAppBase.h deleted file mode 100644 index 3792b04..0000000 --- a/NativeApp/include/NativeAppBase.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ -#pragma once - -// clang-format off - -#if PLATFORM_WIN32 - - #include "Win32AppBase.h" - namespace Diligent - { - using NativeAppBase = Win32AppBase; - } - -#elif PLATFORM_UNIVERSAL_WINDOWS - - #include "UWPAppBase.h" - namespace Diligent - { - using NativeAppBase = UWPAppBase; - } - -#elif PLATFORM_LINUX - - #include "LinuxAppBase.h" - namespace Diligent - { - using NativeAppBase = LinuxAppBase; - } - -#elif PLATFORM_ANDROID - - #include "AndroidAppBase.h" - namespace Diligent - { - using NativeAppBase = AndroidAppBase; - } - -#elif PLATFORM_MACOS - - #include "MacOSAppBase.h" - namespace Diligent - { - using NativeAppBase = MacOSAppBase; - } - -#elif PLATFORM_IOS - - #include "IOSAppBase.h" - namespace Diligent - { - using NativeAppBase = IOSAppBase; - } -#else - -# error Usnupported paltform - -#endif - -namespace Diligent -{ - extern NativeAppBase* CreateApplication(); -} diff --git a/NativeApp/include/NativeAppBase.hpp b/NativeApp/include/NativeAppBase.hpp new file mode 100644 index 0000000..281b85a --- /dev/null +++ b/NativeApp/include/NativeAppBase.hpp @@ -0,0 +1,87 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ +#pragma once + +// clang-format off + +#if PLATFORM_WIN32 + + #include "Win32AppBase.hpp" + namespace Diligent + { + using NativeAppBase = Win32AppBase; + } + +#elif PLATFORM_UNIVERSAL_WINDOWS + + #include "UWPAppBase.hpp" + namespace Diligent + { + using NativeAppBase = UWPAppBase; + } + +#elif PLATFORM_LINUX + + #include "LinuxAppBase.hpp" + namespace Diligent + { + using NativeAppBase = LinuxAppBase; + } + +#elif PLATFORM_ANDROID + + #include "AndroidAppBase.hpp" + namespace Diligent + { + using NativeAppBase = AndroidAppBase; + } + +#elif PLATFORM_MACOS + + #include "MacOSAppBase.hpp" + namespace Diligent + { + using NativeAppBase = MacOSAppBase; + } + +#elif PLATFORM_IOS + + #include "IOSAppBase.hpp" + namespace Diligent + { + using NativeAppBase = IOSAppBase; + } +#else + +# error Usnupported paltform + +#endif + +namespace Diligent +{ + extern NativeAppBase* CreateApplication(); +} diff --git a/NativeApp/include/UWP/UWPAppBase.h b/NativeApp/include/UWP/UWPAppBase.h deleted file mode 100644 index cc0c71e..0000000 --- a/NativeApp/include/UWP/UWPAppBase.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright 2015-2018 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - - -#pragma once - -#include - -#define NOMINIMAX -#include -#include - -#include "AppBase.h" -#include "Common/StepTimer.h" -#include "Common/DeviceResources.h" - -namespace Diligent -{ - -class UWPAppBase : public AppBase -{ -public: - UWPAppBase(); - - virtual void OnSetWindow(Windows::UI::Core::CoreWindow^ window) {} - virtual void OnWindowSizeChanged() = 0; - - using AppBase::Update; - virtual void Update(); - - // Notifies the app that it is being suspended. - virtual void OnSuspending() {} - - // Notifes the app that it is no longer suspended. - virtual void OnResuming() {} - - // Notifies renderers that device resources need to be released. - virtual void OnDeviceRemoved() {} - - bool IsFrameReady()const { return m_bFrameReady; } - - virtual std::shared_ptr InitDeviceResources() = 0; - - virtual void InitWindowSizeDependentResources() = 0; - - virtual void CreateRenderers() = 0; - -protected: - std::shared_ptr m_DeviceResources; - - // Rendering loop timer. - DX::StepTimer m_timer; - bool m_bFrameReady = false; -}; - -} diff --git a/NativeApp/include/UWP/UWPAppBase.hpp b/NativeApp/include/UWP/UWPAppBase.hpp new file mode 100644 index 0000000..c7ef79f --- /dev/null +++ b/NativeApp/include/UWP/UWPAppBase.hpp @@ -0,0 +1,76 @@ +/* Copyright 2015-2018 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + + +#pragma once + +#include + +#define NOMINIMAX +#include +#include + +#include "AppBase.hpp" +#include "Common/StepTimer.h" +#include "Common/DeviceResources.h" + +namespace Diligent +{ + +class UWPAppBase : public AppBase +{ +public: + UWPAppBase(); + + virtual void OnSetWindow(Windows::UI::Core::CoreWindow^ window) {} + virtual void OnWindowSizeChanged() = 0; + + using AppBase::Update; + virtual void Update(); + + // Notifies the app that it is being suspended. + virtual void OnSuspending() {} + + // Notifes the app that it is no longer suspended. + virtual void OnResuming() {} + + // Notifies renderers that device resources need to be released. + virtual void OnDeviceRemoved() {} + + bool IsFrameReady()const { return m_bFrameReady; } + + virtual std::shared_ptr InitDeviceResources() = 0; + + virtual void InitWindowSizeDependentResources() = 0; + + virtual void CreateRenderers() = 0; + +protected: + std::shared_ptr m_DeviceResources; + + // Rendering loop timer. + DX::StepTimer m_timer; + bool m_bFrameReady = false; +}; + +} diff --git a/NativeApp/include/Win32/Win32AppBase.h b/NativeApp/include/Win32/Win32AppBase.h deleted file mode 100644 index 840d9a9..0000000 --- a/NativeApp/include/Win32/Win32AppBase.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -#ifndef NOMINMAX -# define NOMINMAX -#endif -#include - -#include "AppBase.h" - -namespace Diligent -{ - -class Win32AppBase : public AppBase -{ -public: - virtual void OnWindowCreated(HWND hWnd, - LONG WindowWidth, - LONG WindowHeight) = 0; - - virtual LRESULT HandleWin32Message(HWND hWnd, - UINT message, - WPARAM wParam, - LPARAM lParam) - { - return 0; - } -}; - -} // namespace Diligent diff --git a/NativeApp/include/Win32/Win32AppBase.hpp b/NativeApp/include/Win32/Win32AppBase.hpp new file mode 100644 index 0000000..99f7fea --- /dev/null +++ b/NativeApp/include/Win32/Win32AppBase.hpp @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include + +#include "AppBase.hpp" + +namespace Diligent +{ + +class Win32AppBase : public AppBase +{ +public: + virtual void OnWindowCreated(HWND hWnd, + LONG WindowWidth, + LONG WindowHeight) = 0; + + virtual LRESULT HandleWin32Message(HWND hWnd, + UINT message, + WPARAM wParam, + LPARAM lParam) + { + return 0; + } +}; + +} // namespace Diligent -- cgit v1.2.3