#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License // If the library is compiled as a DLL, this ensures symbols are exported #define NUCLEX_GRAPHICS_SOURCE 1 #include "Direct3D11RasterizerSettings.h" #include namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // #if defined(NUCLEX_GRAPHICS_DIRECT3D11_1) bool Direct3D11RasterizerSettings::IsVerticalSynchronizationEnabled() const { const IDXGIDeviceNPtr &dxgiDevice = this->device; UINT latency; HRESULT resultHandle = dxgiDevice->GetMaximumFrameLatency(&latency); if(FAILED(resultHandle)) { throw std::runtime_error("Could not query maximum frame latency from Direct3D 11"); } // If the latency is set to anything but 0, vsync is enabled return (latency > 0); } #endif // defined(NUCLEX_GRAPHICS_DIRECT3D11_1) // ------------------------------------------------------------------------------------------- // #if !defined(NUCLEX_GRAPHICS_DIRECT3D11_1) bool Direct3D11RasterizerSettings::IsVerticalSynchronizationEnabled() const { return this->isVerticalSynchronizationEnabled; } #endif // !defined(NUCLEX_GRAPHICS_DIRECT3D11_1) // ------------------------------------------------------------------------------------------- // #if defined(NUCLEX_GRAPHICS_DIRECT3D11_1) void Direct3D11RasterizerSettings::EnableVerticalSynchronization(bool wait /* = true */) { const IDXGIDeviceNPtr &dxgiDevice = this->device; // Allow 1 frame of latency if vsync is enabled UINT latency = wait ? 1 : 0; HRESULT resultHandle = dxgiDevice->SetMaximumFrameLatency(latency); if(FAILED(resultHandle)) { throw std::runtime_error("Could not set maximum frame latency in Direct3D 11"); } } #endif // defined(NUCLEX_GRAPHICS_DIRECT3D11_1) // ------------------------------------------------------------------------------------------- // #if !defined(NUCLEX_GRAPHICS_DIRECT3D11_1) void Direct3D11RasterizerSettings::EnableVerticalSynchronization(bool wait /* = true */) { this->isVerticalSynchronizationEnabled = wait; } #endif // !defined(NUCLEX_GRAPHICS_DIRECT3D11_1) // ------------------------------------------------------------------------------------------- // //CullMode::Enum Direct3D11RasterizerSettings::GetCullMode() const {} // ------------------------------------------------------------------------------------------- // //void Direct3D11RasterizerSettings::SetCullMode(CullMode::Enum cullMode) {} // ------------------------------------------------------------------------------------------- // std::size_t Direct3D11RasterizerSettings::CountSupportedResolutions() const { throw std::runtime_error("Not implemented yet"); } // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization