summaryrefslogtreecommitdiffstats
path: root/Common/NativeApp/include
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-02-09 06:08:14 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-02-09 06:08:14 +0000
commit1a3598a88a30608f5f918397ae6ac37ef8c7ad2a (patch)
tree2dc1af3f10b2e4a909679a00452da73c2cae0e23 /Common/NativeApp/include
parentUpdated Win32 app implementation (diff)
downloadDiligentEngine-1a3598a88a30608f5f918397ae6ac37ef8c7ad2a.tar.gz
DiligentEngine-1a3598a88a30608f5f918397ae6ac37ef8c7ad2a.zip
Reworked UWP app implementation
Diffstat (limited to 'Common/NativeApp/include')
-rw-r--r--Common/NativeApp/include/AppBase.h38
-rw-r--r--Common/NativeApp/include/NativeAppBase.h37
-rw-r--r--Common/NativeApp/include/UWP/UWPAppBase.h71
-rw-r--r--Common/NativeApp/include/Win32/Win32AppBase.h (renamed from Common/NativeApp/include/NativeAppData.h)16
4 files changed, 130 insertions, 32 deletions
diff --git a/Common/NativeApp/include/AppBase.h b/Common/NativeApp/include/AppBase.h
new file mode 100644
index 0000000..e6641b1
--- /dev/null
+++ b/Common/NativeApp/include/AppBase.h
@@ -0,0 +1,38 @@
+/* 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
+
+class AppBase
+{
+public:
+ 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 Resize(int width, int height) = 0;
+};
+
diff --git a/Common/NativeApp/include/NativeAppBase.h b/Common/NativeApp/include/NativeAppBase.h
index 590b6c9..6ffbb74 100644
--- a/Common/NativeApp/include/NativeAppBase.h
+++ b/Common/NativeApp/include/NativeAppBase.h
@@ -20,31 +20,22 @@
* all other commercial damages or losses), even if such Contributor has been advised
* of the possibility of such damages.
*/
-
#pragma once
-struct NativeAppAttributes
-{
-#ifdef PLATFORM_WIN32
- // * HWND on Win32
- void* NativeWindowHandle = nullptr;
+#if defined(PLATFORM_WIN32)
+
+ #include "Win32AppBase.h"
+ using NativeAppBase = Win32AppBase;
+
+#elif defined(PLATFORM_UNIVERSAL_WINDOWS)
+
+ #include "UWPAppBase.h"
+ using NativeAppBase = UWPAppBase;
+
+#else
+
+# error Usnupported paltform
+
#endif
- int WindowWidth = 0;
- int WindowHeight = 0;
-};
-
-class NativeAppBase
-{
-public:
- virtual ~NativeAppBase() {}
-
- virtual void ProcessCommandLine(const char *CmdLine) = 0;
- virtual const char* GetAppTitle()const = 0;
- virtual void Initialize(const struct NativeAppAttributes &NativeAppAttribs) = 0;
- virtual void Update(double CurrTime, double ElapsedTime) {};
- virtual void PlatformRender() = 0;
- virtual bool HandleNativeMessage(struct NativeMessage &msg) = 0;
- virtual void Resize(int width, int height) = 0;
-};
extern NativeAppBase* CreateApplication();
diff --git a/Common/NativeApp/include/UWP/UWPAppBase.h b/Common/NativeApp/include/UWP/UWPAppBase.h
new file mode 100644
index 0000000..dc56b80
--- /dev/null
+++ b/Common/NativeApp/include/UWP/UWPAppBase.h
@@ -0,0 +1,71 @@
+/* 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 <memory>
+
+#define NOMINIMAX
+#include <wrl.h>
+#include <wrl/client.h>
+
+#include "AppBase.h"
+#include "Common/StepTimer.h"
+#include "Common/DeviceResources.h"
+
+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<DX::DeviceResources> InitDeviceResources() = 0;
+
+ virtual void InitWindowSizeDependentResources() = 0;
+
+ virtual void CreateRenderers() = 0;
+
+protected:
+ std::shared_ptr<DX::DeviceResources> m_DeviceResources;
+
+ // Rendering loop timer.
+ DX::StepTimer m_timer;
+ bool m_bFrameReady = false;
+};
diff --git a/Common/NativeApp/include/NativeAppData.h b/Common/NativeApp/include/Win32/Win32AppBase.h
index ac8c55f..abfdcff 100644
--- a/Common/NativeApp/include/NativeAppData.h
+++ b/Common/NativeApp/include/Win32/Win32AppBase.h
@@ -23,16 +23,14 @@
#pragma once
-#ifdef PLATFORM_WIN32
+#define NOMINMAX
#include <Windows.h>
-#endif
-struct NativeMessage
+#include "AppBase.h"
+
+class Win32AppBase : public AppBase
{
-#ifdef PLATFORM_WIN32
- HWND hWnd;
- UINT message;
- WPARAM wParam;
- LPARAM lParam;
-#endif
+public:
+ virtual void OnWindowCreated(HWND hWnd, LONG WindowWidth, LONG WindowHeight) = 0;
+ virtual LRESULT HandleWin32Message(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { return 0; }
};