diff --git a/Editor/main.cpp b/Editor/main.cpp index 55401aa37..3b406a22b 100644 --- a/Editor/main.cpp +++ b/Editor/main.cpp @@ -41,6 +41,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, // TODO: Place code here. + wiStartupArguments::Parse(lpCmdLine); // if you wish to use command line arguments, here is a good place to parse them... + // Initialize global strings LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDC_WICKEDENGINEGAME, szWindowClass, MAX_LOADSTRING); diff --git a/Template_Windows/main.cpp b/Template_Windows/main.cpp index 8b5b31532..faad022a5 100644 --- a/Template_Windows/main.cpp +++ b/Template_Windows/main.cpp @@ -28,6 +28,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, // TODO: Place code here. + wiStartupArguments::Parse(lpCmdLine); // if you wish to use command line arguments, here is a good place to parse them... + // Initialize global strings LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDC_TEMPLATEWINDOWS, szWindowClass, MAX_LOADSTRING); @@ -117,8 +119,10 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); + main.SetWindow(hWnd, hInst); // assign window handle (mandatory) + return TRUE; } diff --git a/Tests/main.cpp b/Tests/main.cpp index c855fd926..3fb4468a3 100644 --- a/Tests/main.cpp +++ b/Tests/main.cpp @@ -32,6 +32,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, // TODO: Place code here. + wiStartupArguments::Parse(lpCmdLine); // if you wish to use command line arguments, here is a good place to parse them... + // Initialize global strings LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadStringW(hInstance, IDC_WICKEDENGINETESTS, szWindowClass, MAX_LOADSTRING); diff --git a/WickedEngine/DeferredRenderableComponent.cpp b/WickedEngine/DeferredRenderableComponent.cpp index d9fa4d805..05206ec6e 100644 --- a/WickedEngine/DeferredRenderableComponent.cpp +++ b/WickedEngine/DeferredRenderableComponent.cpp @@ -24,7 +24,7 @@ void DeferredRenderableComponent::ResizeBuffers() { Renderable3DComponent::ResizeBuffers(); - FORMAT defaultTextureFormat = GraphicsDevice::GetBackBufferFormat(); + FORMAT defaultTextureFormat = wiRenderer::GetDevice()->GetBackBufferFormat(); // Protect against multiple buffer resizes when there is no change! static UINT lastBufferResWidth = 0, lastBufferResHeight = 0, lastBufferMSAA = 0; diff --git a/WickedEngine/ForwardRenderableComponent.cpp b/WickedEngine/ForwardRenderableComponent.cpp index f761df218..f77c53ffd 100644 --- a/WickedEngine/ForwardRenderableComponent.cpp +++ b/WickedEngine/ForwardRenderableComponent.cpp @@ -27,7 +27,7 @@ void ForwardRenderableComponent::ResizeBuffers() { Renderable3DComponent::ResizeBuffers(); - FORMAT defaultTextureFormat = GraphicsDevice::GetBackBufferFormat(); + FORMAT defaultTextureFormat = wiRenderer::GetDevice()->GetBackBufferFormat(); // Protect against multiple buffer resizes when there is no change! static UINT lastBufferResWidth = 0, lastBufferResHeight = 0, lastBufferMSAA = 0; diff --git a/WickedEngine/MainComponent.cpp b/WickedEngine/MainComponent.cpp index 02d755efb..c409079bc 100644 --- a/WickedEngine/MainComponent.cpp +++ b/WickedEngine/MainComponent.cpp @@ -13,8 +13,15 @@ #include "wiFrameRate.h" #include "wiProfiler.h" #include "wiInitializer.h" +#include "wiStartupArguments.h" + +#include "wiGraphicsDevice_DX11.h" +#include "wiGraphicsDevice_DX12.h" +#include "wiGraphicsDevice_Vulkan.h" + using namespace std; +using namespace wiGraphicsTypes; MainComponent::MainComponent() { @@ -50,6 +57,38 @@ MainComponent::~MainComponent() void MainComponent::Initialize() { + + // User can also create a graphics device if custom logic is desired, but he must do before this function! + if (wiRenderer::graphicsDevice == nullptr) + { + + bool debugdevice = wiStartupArguments::HasArgument("debugdevice"); + + if (wiStartupArguments::HasArgument("vulkan")) + { +#ifdef WICKEDENGINE_BUILD_VULKAN + wiRenderer::SHADERPATH += "spirv/"; + wiRenderer::graphicsDevice = new GraphicsDevice_Vulkan(window, fullscreen, debugdevice); +#else + wiHelper::messageBox("Vulkan SDK not found during building the application! Vulkan API disabled!", "Error"); +#endif + } + else if (wiStartupArguments::HasArgument("dx12")) + { + if (wiStartupArguments::HasArgument("hlsl6")) + { + wiRenderer::SHADERPATH += "hlsl6/"; + } + wiRenderer::graphicsDevice = new GraphicsDevice_DX12(window, fullscreen, debugdevice); + } + else + { + wiRenderer::graphicsDevice = new GraphicsDevice_DX11(window, fullscreen, debugdevice); + } + + } + + wiInitializer::InitializeComponents(); wiLua::GetGlobal()->RegisterObject(MainComponent_BindLua::className, "main", new MainComponent_BindLua(this)); @@ -192,9 +231,25 @@ void MainComponent::Compose() stringstream ss(""); if (infoDisplay.watermark) { - ss << string("Wicked Engine ") + wiVersion::GetVersionString(); + ss << string("Wicked Engine ") + wiVersion::GetVersionString() + " "; + + if (dynamic_cast(wiRenderer::GetDevice())) + { + ss << "[DX11]"; + } + else if (dynamic_cast(wiRenderer::GetDevice())) + { + ss << "[DX12]"; + } +#ifdef WICKEDENGINE_BUILD_VULKAN + else if (dynamic_cast(wiRenderer::GetDevice())) + { + ss << "[Vulkan]"; + } +#endif + #ifdef _DEBUG - ss << " [DEBUG]"; + ss << "[DEBUG]"; #endif ss << endl; } @@ -252,8 +307,6 @@ bool MainComponent::SetWindow(wiWindowRegistration::window_type window, HINSTANC screenH = rect.bottom - rect.top; } - wiRenderer::InitDevice(window, fullscreen); - wiWindowRegistration::GetInstance()->RegisterWindow(window); return true; @@ -263,7 +316,6 @@ bool MainComponent::SetWindow(wiWindowRegistration::window_type window) { screenW = (int)window->Bounds.Width; screenH = (int)window->Bounds.Height; - wiRenderer::InitDevice(window, fullscreen); this->window = window; diff --git a/WickedEngine/Renderable2DComponent.cpp b/WickedEngine/Renderable2DComponent.cpp index 67385357b..3f7ec5794 100644 --- a/WickedEngine/Renderable2DComponent.cpp +++ b/WickedEngine/Renderable2DComponent.cpp @@ -22,7 +22,7 @@ Renderable2DComponent::~Renderable2DComponent() wiRenderTarget Renderable2DComponent::rtFinal; void Renderable2DComponent::ResizeBuffers() { - FORMAT defaultTextureFormat = GraphicsDevice::GetBackBufferFormat(); + FORMAT defaultTextureFormat = wiRenderer::GetDevice()->GetBackBufferFormat(); // Protect against multiple buffer resizes when there is no change! static UINT lastBufferResWidth = 0, lastBufferResHeight = 0, lastBufferMSAA = 0; diff --git a/WickedEngine/Renderable3DComponent.cpp b/WickedEngine/Renderable3DComponent.cpp index fdef7e2a0..9c57c0a8f 100644 --- a/WickedEngine/Renderable3DComponent.cpp +++ b/WickedEngine/Renderable3DComponent.cpp @@ -41,7 +41,7 @@ void Renderable3DComponent::ResizeBuffers() { Renderable2DComponent::ResizeBuffers(); - FORMAT defaultTextureFormat = GraphicsDevice::GetBackBufferFormat(); + FORMAT defaultTextureFormat = wiRenderer::GetDevice()->GetBackBufferFormat(); // Protect against multiple buffer resizes when there is no change! static UINT lastBufferResWidth = 0, lastBufferResHeight = 0, lastBufferMSAA = 0; diff --git a/WickedEngine/WickedEngine.h b/WickedEngine/WickedEngine.h index 9d147e042..cc9f2ca8b 100644 --- a/WickedEngine/WickedEngine.h +++ b/WickedEngine/WickedEngine.h @@ -57,6 +57,7 @@ #include "wiRectPacker.h" #include "wiProfiler.h" #include "wiOcean.h" +#include "wiStartupArguments.h" #include "RenderableComponent.h" #include "Renderable2DComponent.h" @@ -68,6 +69,10 @@ #include "LoadingScreenComponent.h" #include "MainComponent.h" +#include "wiGraphicsDevice_DX11.h" +#include "wiGraphicsDevice_DX12.h" +#include "wiGraphicsDevice_Vulkan.h" + #ifdef _WIN32 #ifdef WINSTORE_SUPPORT diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems b/WickedEngine/WickedEngine_SHARED.vcxitems index 807e930a1..dc89e54c3 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems +++ b/WickedEngine/WickedEngine_SHARED.vcxitems @@ -369,6 +369,7 @@ + @@ -715,6 +716,7 @@ + diff --git a/WickedEngine/WickedEngine_SHARED.vcxitems.filters b/WickedEngine/WickedEngine_SHARED.vcxitems.filters index 2c00f93c3..29fffe2dc 100644 --- a/WickedEngine/WickedEngine_SHARED.vcxitems.filters +++ b/WickedEngine/WickedEngine_SHARED.vcxitems.filters @@ -1164,6 +1164,9 @@ UTILITY + + ENGINE\Helpers + @@ -1979,6 +1982,9 @@ UTILITY + + ENGINE\Helpers + diff --git a/WickedEngine/wiFont.cpp b/WickedEngine/wiFont.cpp index a176e9e8d..1fa3100b6 100644 --- a/WickedEngine/wiFont.cpp +++ b/WickedEngine/wiFont.cpp @@ -147,7 +147,7 @@ void wiFont::LoadShaders() desc.rs = rasterizerState; desc.dss = depthStencilState; desc.numRTs = 1; - desc.RTFormats[0] = GraphicsDevice::GetBackBufferFormat(); + desc.RTFormats[0] = wiRenderer::GetDevice()->GetBackBufferFormat(); SAFE_DELETE(PSO); PSO = new GraphicsPSO; wiRenderer::GetDevice()->CreateGraphicsPSO(&desc, PSO); diff --git a/WickedEngine/wiGraphicsDevice.cpp b/WickedEngine/wiGraphicsDevice.cpp index 438cdfe9a..07f5d176a 100644 --- a/WickedEngine/wiGraphicsDevice.cpp +++ b/WickedEngine/wiGraphicsDevice.cpp @@ -2,15 +2,6 @@ using namespace wiGraphicsTypes; -//FORMAT GraphicsDevice::BACKBUFFER_FORMAT = FORMAT::FORMAT_R8G8B8A8_UNORM; -//FORMAT GraphicsDevice::BACKBUFFER_FORMAT = FORMAT::FORMAT_B8G8R8A8_UNORM; // this is compliant with vulkan, dx11, dx12 -FORMAT GraphicsDevice::BACKBUFFER_FORMAT = FORMAT::FORMAT_R10G10B10A2_UNORM; - -FORMAT GraphicsDevice::GetBackBufferFormat() -{ - return BACKBUFFER_FORMAT; -} - bool GraphicsDevice::CheckCapability(GRAPHICSDEVICE_CAPABILITY capability) { switch (capability) diff --git a/WickedEngine/wiGraphicsDevice.h b/WickedEngine/wiGraphicsDevice.h index 6b7b045bf..d949abee7 100644 --- a/WickedEngine/wiGraphicsDevice.h +++ b/WickedEngine/wiGraphicsDevice.h @@ -18,12 +18,12 @@ namespace wiGraphicsTypes int SCREENWIDTH, SCREENHEIGHT; bool FULLSCREEN; bool RESOLUTIONCHANGED; - static FORMAT BACKBUFFER_FORMAT; + FORMAT BACKBUFFER_FORMAT; static const UINT BACKBUFFER_COUNT = 2; bool TESSELLATION, MULTITHREADED_RENDERING, CONSERVATIVE_RASTERIZATION, RASTERIZER_ORDERED_VIEWS, UNORDEREDACCESSTEXTURE_LOAD_EXT; public: GraphicsDevice() - :FRAMECOUNT(0), VSYNC(true), SCREENWIDTH(0), SCREENHEIGHT(0), FULLSCREEN(false), RESOLUTIONCHANGED(false), + :FRAMECOUNT(0), VSYNC(true), SCREENWIDTH(0), SCREENHEIGHT(0), FULLSCREEN(false), RESOLUTIONCHANGED(false), BACKBUFFER_FORMAT(FORMAT_R10G10B10A2_UNORM), TESSELLATION(false), MULTITHREADED_RENDERING(false), CONSERVATIVE_RASTERIZATION(false),RASTERIZER_ORDERED_VIEWS(false), UNORDEREDACCESSTEXTURE_LOAD_EXT(false) {} @@ -83,7 +83,7 @@ namespace wiGraphicsTypes { return XMMatrixOrthographicOffCenterLH(0, (float)GetScreenWidth(), (float)GetScreenHeight(), 0, -1, 1); } - static FORMAT GetBackBufferFormat(); + FORMAT GetBackBufferFormat() { return BACKBUFFER_FORMAT; } static UINT GetBackBufferCount() { return BACKBUFFER_COUNT; } diff --git a/WickedEngine/wiGraphicsDevice_DX11.cpp b/WickedEngine/wiGraphicsDevice_DX11.cpp index 5eb8967f2..d42d41384 100644 --- a/WickedEngine/wiGraphicsDevice_DX11.cpp +++ b/WickedEngine/wiGraphicsDevice_DX11.cpp @@ -1382,7 +1382,7 @@ const void* const __nullBlob[1024] = {}; // this is initialized to nullptrs! // Engine functions -GraphicsDevice_DX11::GraphicsDevice_DX11(wiWindowRegistration::window_type window, bool fullscreen) : GraphicsDevice() +GraphicsDevice_DX11::GraphicsDevice_DX11(wiWindowRegistration::window_type window, bool fullscreen, bool debuglayer) : GraphicsDevice() { FULLSCREEN = fullscreen; @@ -1407,7 +1407,11 @@ GraphicsDevice_DX11::GraphicsDevice_DX11(wiWindowRegistration::window_type windo } UINT createDeviceFlags = 0; - //createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; + + if (debuglayer) + { + createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; + } D3D_DRIVER_TYPE driverTypes[] = { diff --git a/WickedEngine/wiGraphicsDevice_DX11.h b/WickedEngine/wiGraphicsDevice_DX11.h index 78ee41664..6d0f54d79 100644 --- a/WickedEngine/wiGraphicsDevice_DX11.h +++ b/WickedEngine/wiGraphicsDevice_DX11.h @@ -48,7 +48,7 @@ namespace wiGraphicsTypes PRIMITIVETOPOLOGY prev_pt[GRAPHICSTHREAD_COUNT] = {}; public: - GraphicsDevice_DX11(wiWindowRegistration::window_type window, bool fullscreen = false); + GraphicsDevice_DX11(wiWindowRegistration::window_type window, bool fullscreen = false, bool debuglayer = false); ~GraphicsDevice_DX11(); diff --git a/WickedEngine/wiGraphicsDevice_DX12.cpp b/WickedEngine/wiGraphicsDevice_DX12.cpp index 47d5bda2d..2868f7fbc 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.cpp +++ b/WickedEngine/wiGraphicsDevice_DX12.cpp @@ -1452,7 +1452,7 @@ namespace wiGraphicsTypes // Engine functions ID3D12GraphicsCommandList* GraphicsDevice_DX12::GetDirectCommandList(GRAPHICSTHREAD threadID) { return static_cast(GetFrameResources().commandLists[threadID]); } - GraphicsDevice_DX12::GraphicsDevice_DX12(wiWindowRegistration::window_type window, bool fullscreen) : GraphicsDevice() + GraphicsDevice_DX12::GraphicsDevice_DX12(wiWindowRegistration::window_type window, bool fullscreen, bool debuglayer) : GraphicsDevice() { FULLSCREEN = fullscreen; @@ -1468,20 +1468,23 @@ namespace wiGraphicsTypes HRESULT hr = E_FAIL; -#if defined(_DEBUG) && !defined(WINSTORE_SUPPORT) - // Enable the debug layer. - HMODULE dx12 = LoadLibraryEx(L"d3d12.dll", - nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); - auto pD3D12GetDebugInterface = - reinterpret_cast( - GetProcAddress(dx12, "D3D12GetDebugInterface")); - if (pD3D12GetDebugInterface) +#if !defined(WINSTORE_SUPPORT) + if (debuglayer) { - ID3D12Debug* debugController; - if (SUCCEEDED(pD3D12GetDebugInterface( - IID_PPV_ARGS(&debugController)))) + // Enable the debug layer. + HMODULE dx12 = LoadLibraryEx(L"d3d12.dll", + nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32); + auto pD3D12GetDebugInterface = + reinterpret_cast( + GetProcAddress(dx12, "D3D12GetDebugInterface")); + if (pD3D12GetDebugInterface) { - debugController->EnableDebugLayer(); + ID3D12Debug* debugController; + if (SUCCEEDED(pD3D12GetDebugInterface( + IID_PPV_ARGS(&debugController)))) + { + debugController->EnableDebugLayer(); + } } } #endif diff --git a/WickedEngine/wiGraphicsDevice_DX12.h b/WickedEngine/wiGraphicsDevice_DX12.h index c92b249a2..aa9a2f400 100644 --- a/WickedEngine/wiGraphicsDevice_DX12.h +++ b/WickedEngine/wiGraphicsDevice_DX12.h @@ -140,7 +140,7 @@ namespace wiGraphicsTypes public: - GraphicsDevice_DX12(wiWindowRegistration::window_type window, bool fullscreen = false); + GraphicsDevice_DX12(wiWindowRegistration::window_type window, bool fullscreen = false, bool debuglayer = false); ~GraphicsDevice_DX12(); diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index 718724afd..162d868f0 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -25,11 +25,6 @@ namespace wiGraphicsTypes const std::vector validationLayers = { "VK_LAYER_LUNARG_standard_validation" }; -#ifdef NDEBUG - bool enableValidationLayers = false; -#else - bool enableValidationLayers = true; -#endif bool checkValidationLayerSupport() { uint32_t layerCount; vkEnumerateInstanceLayerProperties(&layerCount, nullptr); @@ -1384,8 +1379,10 @@ namespace wiGraphicsTypes // Engine functions VkCommandBuffer GraphicsDevice_Vulkan::GetDirectCommandList(GRAPHICSTHREAD threadID) { return GetFrameResources().commandBuffers[threadID]; } - GraphicsDevice_Vulkan::GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen) : GraphicsDevice() + GraphicsDevice_Vulkan::GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen, bool debuglayer) : GraphicsDevice() { + BACKBUFFER_FORMAT = FORMAT::FORMAT_B8G8R8A8_UNORM; + FULLSCREEN = fullscreen; RECT rect = RECT(); @@ -1417,6 +1414,9 @@ namespace wiGraphicsTypes //} extensionNames.push_back(VK_KHR_SURFACE_EXTENSION_NAME); extensionNames.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME); + + + bool enableValidationLayers = debuglayer; if (enableValidationLayers && !checkValidationLayerSupport()) { //throw std::runtime_error("validation layers requested, but not available!"); diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.h b/WickedEngine/wiGraphicsDevice_Vulkan.h index fd95dd404..3e9340b04 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.h +++ b/WickedEngine/wiGraphicsDevice_Vulkan.h @@ -162,7 +162,7 @@ namespace wiGraphicsTypes public: - GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen = false); + GraphicsDevice_Vulkan(wiWindowRegistration::window_type window, bool fullscreen = false, bool debuglayer = false); ~GraphicsDevice_Vulkan(); diff --git a/WickedEngine/wiImage.cpp b/WickedEngine/wiImage.cpp index d48eab2c0..4205976b2 100644 --- a/WickedEngine/wiImage.cpp +++ b/WickedEngine/wiImage.cpp @@ -129,7 +129,7 @@ void wiImage::LoadShaders() desc.numRTs = 1; - desc.RTFormats[0] = GraphicsDevice::GetBackBufferFormat(); + desc.RTFormats[0] = wiRenderer::GetDevice()->GetBackBufferFormat(); device->CreateGraphicsPSO(&desc, &imagePSO[i][j][k][0]); desc.RTFormats[0] = wiRenderer::RTFormat_hdr; @@ -176,13 +176,13 @@ void wiImage::LoadShaders() else if (i == POSTPROCESS_TONEMAP) { desc.numRTs = 1; - desc.RTFormats[0] = GraphicsDevice::GetBackBufferFormat(); + desc.RTFormats[0] = wiRenderer::GetDevice()->GetBackBufferFormat(); } else if (i == POSTPROCESS_BLOOMSEPARATE || i == POSTPROCESS_BLUR_H || POSTPROCESS_BLUR_V) { // todo: bloom and DoF blur should really be HDR lol... desc.numRTs = 1; - desc.RTFormats[0] = GraphicsDevice::GetBackBufferFormat(); + desc.RTFormats[0] = wiRenderer::GetDevice()->GetBackBufferFormat(); } else { diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index 8d35a4373..80527b600 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -19,9 +19,6 @@ #include "wiEnums.h" #include "wiRandom.h" #include "wiFont.h" -#include "wiGraphicsDevice_DX11.h" -#include "wiGraphicsDevice_DX12.h" -#include "wiGraphicsDevice_Vulkan.h" #include "wiTranslator.h" #include "wiRectPacker.h" #include "wiBackLog.h" @@ -124,17 +121,6 @@ wiRenderer::wiRenderer() { } -void wiRenderer::InitDevice(wiWindowRegistration::window_type window, bool fullscreen) -{ - SAFE_DELETE(graphicsDevice); -#ifdef WICKEDENGINE_BUILD_VULKAN - graphicsDevice = new GraphicsDevice_Vulkan(window, fullscreen); -#else - graphicsDevice = new GraphicsDevice_DX11(window, fullscreen); - //graphicsDevice = new GraphicsDevice_DX12(window, fullscreen); -#endif -} - void wiRenderer::Present(function drawToScreen1,function drawToScreen2,function drawToScreen3) { GetDevice()->PresentBegin(); diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 5196197cc..710f96bf5 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -52,10 +52,9 @@ class wiRenderer { public: static wiGraphicsTypes::GraphicsDevice* graphicsDevice; - static wiGraphicsTypes::GraphicsDevice* GetDevice() { return graphicsDevice; } + static wiGraphicsTypes::GraphicsDevice* GetDevice() { assert(graphicsDevice != nullptr); return graphicsDevice; } - static void InitDevice(wiWindowRegistration::window_type window, bool fullscreen = false); static void Present(std::function drawToScreen1=nullptr, std::function drawToScreen2=nullptr, std::function drawToScreen3=nullptr); diff --git a/WickedEngine/wiStartupArguments.cpp b/WickedEngine/wiStartupArguments.cpp new file mode 100644 index 000000000..ed846cb12 --- /dev/null +++ b/WickedEngine/wiStartupArguments.cpp @@ -0,0 +1,29 @@ +#include "wiStartupArguments.h" + +#include +#include +#include + +using namespace std; + +set wiStartupArguments::params; + +void wiStartupArguments::Parse(const wchar_t* args) +{ + wstring tmp = args; + string tmp1(tmp.begin(), tmp.end()); + + istringstream iss(tmp1); + + params = + { + istream_iterator{iss}, + istream_iterator{} + }; + +} + +bool wiStartupArguments::HasArgument(const std::string& value) +{ + return params.find(value) != params.end(); +} diff --git a/WickedEngine/wiStartupArguments.h b/WickedEngine/wiStartupArguments.h new file mode 100644 index 000000000..6d7b6bbb6 --- /dev/null +++ b/WickedEngine/wiStartupArguments.h @@ -0,0 +1,14 @@ +#pragma once + +#include +#include + +class wiStartupArguments +{ +public: + static std::set params; + + static void Parse(const wchar_t* args); + static bool HasArgument(const std::string& value); +}; + diff --git a/WickedEngine/wiWidget.cpp b/WickedEngine/wiWidget.cpp index d797b24dc..f019af8f9 100644 --- a/WickedEngine/wiWidget.cpp +++ b/WickedEngine/wiWidget.cpp @@ -216,7 +216,7 @@ void wiWidget::LoadShaders() desc.bs = wiRenderer::blendStates[BSTYPE_OPAQUE]; desc.rs = wiRenderer::rasterizers[RSTYPE_DOUBLESIDED]; desc.numRTs = 1; - desc.RTFormats[0] = GraphicsDevice::GetBackBufferFormat(); + desc.RTFormats[0] = wiRenderer::GetDevice()->GetBackBufferFormat(); desc.pt = TRIANGLESTRIP; RECREATE(PSO_colorpicker); HRESULT hr = wiRenderer::GetDevice()->CreateGraphicsPSO(&desc, PSO_colorpicker);