| 
									
										
										
										
											2018-10-03 22:02:46 +08:00
										 |  |  | // Copyright (c) 2016-2018 Easy2D - Nomango
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
					
						
							|  |  |  | // of this software and associated documentation files (the "Software"), to deal
 | 
					
						
							|  |  |  | // in the Software without restriction, including without limitation the rights
 | 
					
						
							|  |  |  | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
					
						
							|  |  |  | // copies of the Software, and to permit persons to whom the Software is
 | 
					
						
							|  |  |  | // furnished to do so, subject to the following conditions:
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // The above copyright notice and this permission notice shall be included in
 | 
					
						
							|  |  |  | // all copies or substantial portions of the Software.
 | 
					
						
							|  |  |  | // 
 | 
					
						
							|  |  |  | // 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. IN NO EVENT SHALL THE
 | 
					
						
							|  |  |  | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
					
						
							|  |  |  | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
					
						
							|  |  |  | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 | 
					
						
							|  |  |  | // THE SOFTWARE.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 00:16:26 +08:00
										 |  |  | #ifndef __E2D_MACROS_H__
 | 
					
						
							|  |  |  | #define __E2D_MACROS_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-12 02:44:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-23 00:05:57 +08:00
										 |  |  | #ifndef WINVER
 | 
					
						
							| 
									
										
										
										
											2018-09-11 15:12:25 +08:00
										 |  |  | #	define WINVER 0x0700	   // Allow use of features specific to Windows 7 or later
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-23 00:05:57 +08:00
										 |  |  | #ifndef _WIN32_WINNT
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #	define _WIN32_WINNT 0x0700 // Allow use of features specific to Windows 7 or later
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-19 12:48:58 +08:00
										 |  |  | #ifndef NTDDI_VERSION
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #	define NTDDI_VERSION NTDDI_WIN7
 | 
					
						
							| 
									
										
										
										
											2017-10-19 12:48:58 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | #ifndef UNICODE
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #	define UNICODE
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-23 00:05:57 +08:00
										 |  |  | // Exclude rarely-used items from Windows headers
 | 
					
						
							| 
									
										
										
										
											2017-10-19 12:48:58 +08:00
										 |  |  | #ifndef WIN32_LEAN_AND_MEAN
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #	define WIN32_LEAN_AND_MEAN
 | 
					
						
							| 
									
										
										
										
											2017-10-19 12:48:58 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | #ifndef DIRECTINPUT_VERSION
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #	define DIRECTINPUT_VERSION 0x0800
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-11 20:00:21 +08:00
										 |  |  | #ifndef INITGUID
 | 
					
						
							|  |  |  | #	define INITGUID
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-04-01 23:08:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-23 00:05:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-02 10:06:29 +08:00
										 |  |  | // Windows Header Files
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | #include <windows.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-01 22:07:44 +08:00
										 |  |  | #include <wincodec.h>
 | 
					
						
							|  |  |  | #include <mmsystem.h>
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  | #include <d2d1.h>
 | 
					
						
							|  |  |  | #include <dwrite.h>
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | #include <dinput.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-15 20:16:08 +08:00
										 |  |  | #include <xaudio2.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-11 20:00:21 +08:00
										 |  |  | #include <mfapi.h>
 | 
					
						
							|  |  |  | #include <mfidl.h>
 | 
					
						
							| 
									
										
										
										
											2018-10-15 20:16:08 +08:00
										 |  |  | #include <mfreadwrite.h>
 | 
					
						
							|  |  |  | #include <shlwapi.h>
 | 
					
						
							| 
									
										
										
										
											2018-02-01 22:07:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-15 23:59:58 +08:00
										 |  |  | // C++ RunTime Header Files
 | 
					
						
							| 
									
										
										
										
											2018-07-03 20:19:00 +08:00
										 |  |  | #include <map>
 | 
					
						
							| 
									
										
										
										
											2018-05-15 23:59:58 +08:00
										 |  |  | #include <set>
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  | #include <list>
 | 
					
						
							| 
									
										
										
										
											2018-05-15 23:59:58 +08:00
										 |  |  | #include <stack>
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <random>
 | 
					
						
							|  |  |  | #include <utility>
 | 
					
						
							| 
									
										
										
										
											2018-07-03 18:42:00 +08:00
										 |  |  | #include <chrono>
 | 
					
						
							|  |  |  | #include <sstream>
 | 
					
						
							|  |  |  | #include <functional>
 | 
					
						
							| 
									
										
										
										
											2018-07-16 22:43:56 +08:00
										 |  |  | #include <algorithm>
 | 
					
						
							| 
									
										
										
										
											2018-02-02 10:06:29 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Import Libraries
 | 
					
						
							| 
									
										
										
										
											2017-10-17 21:22:25 +08:00
										 |  |  | #pragma comment(lib, "d2d1.lib")
 | 
					
						
							|  |  |  | #pragma comment(lib, "dwrite.lib")
 | 
					
						
							|  |  |  | #pragma comment(lib, "windowscodecs.lib")
 | 
					
						
							| 
									
										
										
										
											2018-02-01 22:07:44 +08:00
										 |  |  | #pragma comment(lib, "winmm.lib")
 | 
					
						
							| 
									
										
										
										
											2018-10-03 18:04:04 +08:00
										 |  |  | #pragma comment(lib, "dinput8.lib")
 | 
					
						
							| 
									
										
										
										
											2018-10-15 20:16:08 +08:00
										 |  |  | #pragma comment(lib, "xaudio2.lib")
 | 
					
						
							| 
									
										
										
										
											2018-10-11 20:00:21 +08:00
										 |  |  | #pragma comment(lib, "mfplat.lib")
 | 
					
						
							| 
									
										
										
										
											2018-10-15 20:16:08 +08:00
										 |  |  | #pragma comment(lib, "mfreadwrite.lib")
 | 
					
						
							|  |  |  | #pragma comment(lib, "shlwapi.lib")
 | 
					
						
							| 
									
										
										
										
											2018-04-01 23:08:11 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-13 11:42:36 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | #ifndef HINST_THISCOMPONENT
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | 	EXTERN_C IMAGE_DOS_HEADER __ImageBase; | 
					
						
							|  |  |  | #	define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase)
 | 
					
						
							| 
									
										
										
										
											2018-01-30 16:45:38 +08:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #if _MSC_VER >= 1800
 | 
					
						
							| 
									
										
										
										
											2018-05-27 01:28:01 +08:00
										 |  |  | #	define E2D_OP_EXPLICIT explicit
 | 
					
						
							| 
									
										
										
										
											2018-05-25 00:33:46 +08:00
										 |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2018-07-03 01:49:20 +08:00
										 |  |  | #	define E2D_OP_EXPLICIT
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 12:59:32 +08:00
										 |  |  | #if _MSC_VER >= 1900
 | 
					
						
							|  |  |  | #	define E2D_NOEXCEPT noexcept
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #	define E2D_NOEXCEPT throw()
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-03 18:16:26 +08:00
										 |  |  | #if _MSC_VER >= 1800
 | 
					
						
							|  |  |  | #	define E2D_DISABLE_COPY(Class) \
 | 
					
						
							|  |  |  | 	Class(const Class &) = delete; \ | 
					
						
							|  |  |  | 	Class & operator= (const Class &) = delete | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #	define E2D_DISABLE_COPY(Class) \
 | 
					
						
							|  |  |  | 	Class(const Class &); \ | 
					
						
							|  |  |  | 	Class & operator= (const Class &) | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-07-04 12:49:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef max
 | 
					
						
							|  |  |  | #	undef max
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef min
 | 
					
						
							|  |  |  | #	undef min
 | 
					
						
							| 
									
										
										
										
											2018-07-06 12:59:32 +08:00
										 |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2018-10-16 15:42:15 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef E2D_WARNING
 | 
					
						
							|  |  |  | #	if defined( DEBUG ) || defined( _DEBUG )
 | 
					
						
							| 
									
										
										
										
											2018-10-18 00:17:27 +08:00
										 |  |  | #		define E2D_WARNING(msg) do { ::OutputDebugStringW(L"[easy2d] Warning: " _CRT_WIDE(msg) L"\r\n"); } while(0)
 | 
					
						
							| 
									
										
										
										
											2018-10-16 15:42:15 +08:00
										 |  |  | #	else
 | 
					
						
							| 
									
										
										
										
											2018-10-17 00:16:26 +08:00
										 |  |  | #		define E2D_WARNING(msg) ((void)0)
 | 
					
						
							| 
									
										
										
										
											2018-10-16 15:42:15 +08:00
										 |  |  | #	endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef E2D_WARNING_IF
 | 
					
						
							|  |  |  | #	if defined( DEBUG ) || defined( _DEBUG )
 | 
					
						
							| 
									
										
										
										
											2018-10-18 00:17:27 +08:00
										 |  |  | #		define E2D_WARNING_IF(exp, msg) do { if (exp) { ::OutputDebugStringW(L"[easy2d] Warning: " _CRT_WIDE(msg) L"\r\n"); } } while(0)
 | 
					
						
							| 
									
										
										
										
											2018-10-16 15:42:15 +08:00
										 |  |  | #	else
 | 
					
						
							| 
									
										
										
										
											2018-10-17 00:16:26 +08:00
										 |  |  | #		define E2D_WARNING_IF(exp, msg) ((void)0)
 | 
					
						
							| 
									
										
										
										
											2018-10-16 15:42:15 +08:00
										 |  |  | #	endif
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-17 00:16:26 +08:00
										 |  |  | #endif // __E2D_MACROS_H__
 |