diff --git a/includes/xna/graphics/gresource.hpp b/includes/xna/graphics/gresource.hpp index 0c02ab5..6877284 100644 --- a/includes/xna/graphics/gresource.hpp +++ b/includes/xna/graphics/gresource.hpp @@ -17,7 +17,7 @@ namespace xna { sptr Device() const; protected: - sptr m_device = nullptr; + sptr BaseGraphicsDevice = nullptr; }; } diff --git a/sources/framework-dx/blendstate.cpp b/sources/framework-dx/blendstate.cpp index d730505..5f2d2c5 100644 --- a/sources/framework-dx/blendstate.cpp +++ b/sources/framework-dx/blendstate.cpp @@ -97,7 +97,7 @@ namespace xna { bool BlendState::Initialize() { - if (!m_device || !m_device->Implementation->Device) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -105,7 +105,7 @@ namespace xna { Implementation->BlendState = nullptr; } - const auto hr = m_device->Implementation->Device->CreateBlendState( + const auto hr = BaseGraphicsDevice->Implementation->Device->CreateBlendState( &Implementation->Description, Implementation->BlendState.GetAddressOf()); @@ -117,7 +117,7 @@ namespace xna { } bool BlendState::Apply() { - if (!m_device || !m_device->Implementation->Context) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::FAILED_TO_APPLY); } @@ -125,7 +125,7 @@ namespace xna { Initialize(); } - m_device->Implementation->Context->OMSetBlendState( + BaseGraphicsDevice->Implementation->Context->OMSetBlendState( Implementation->BlendState.Get(), Implementation->BlendFactor, Implementation->SampleMask); diff --git a/sources/framework-dx/depthstencilstate.cpp b/sources/framework-dx/depthstencilstate.cpp index 17c48c0..d4667b5 100644 --- a/sources/framework-dx/depthstencilstate.cpp +++ b/sources/framework-dx/depthstencilstate.cpp @@ -37,7 +37,7 @@ namespace xna { bool DepthStencilState::Initialize() { - if (!m_device || !m_device->Implementation->Device) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -45,7 +45,7 @@ namespace xna { Implementation->DepthStencil = nullptr; } - const auto hr = m_device->Implementation->Device->CreateDepthStencilState( + const auto hr = BaseGraphicsDevice->Implementation->Device->CreateDepthStencilState( &Implementation->Description, Implementation->DepthStencil.GetAddressOf()); @@ -58,7 +58,7 @@ namespace xna { bool DepthStencilState::Apply() { - if (!m_device || !m_device->Implementation->Context) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } @@ -66,7 +66,7 @@ namespace xna { Initialize(); } - m_device->Implementation->Context->OMSetDepthStencilState(Implementation->DepthStencil.Get(), 0); + BaseGraphicsDevice->Implementation->Context->OMSetDepthStencilState(Implementation->DepthStencil.Get(), 0); return true; } diff --git a/sources/framework-dx/rasterizerstate.cpp b/sources/framework-dx/rasterizerstate.cpp index 644d08b..77f7d64 100644 --- a/sources/framework-dx/rasterizerstate.cpp +++ b/sources/framework-dx/rasterizerstate.cpp @@ -17,7 +17,7 @@ namespace xna { bool RasterizerState::Initialize() { - if (!impl || !m_device || !m_device->Implementation->Device) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -25,7 +25,7 @@ namespace xna { impl->dxRasterizerState = nullptr; } - const auto hr = m_device->Implementation->Device->CreateRasterizerState( + const auto hr = BaseGraphicsDevice->Implementation->Device->CreateRasterizerState( &impl->dxDescription, impl->dxRasterizerState.GetAddressOf()); @@ -38,7 +38,7 @@ namespace xna { bool RasterizerState::Apply() { - if (!impl || !m_device || !m_device->Implementation->Context) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -46,7 +46,7 @@ namespace xna { Exception::Throw(Exception::INVALID_OPERATION); } - m_device->Implementation->Context->RSSetState(impl->dxRasterizerState.Get()); + BaseGraphicsDevice->Implementation->Context->RSSetState(impl->dxRasterizerState.Get()); return true; } diff --git a/sources/framework-dx/rendertarget.cpp b/sources/framework-dx/rendertarget.cpp index b53aa65..1bc3a9d 100644 --- a/sources/framework-dx/rendertarget.cpp +++ b/sources/framework-dx/rendertarget.cpp @@ -26,7 +26,7 @@ namespace xna { } void RenderTarget2D::Initialize() { - if (!impl || !m_device || !m_device->Implementation->Device) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -39,7 +39,7 @@ namespace xna { Texture2D::Initialize(); - auto& dxdevice = m_device->Implementation->Device; + auto& dxdevice = BaseGraphicsDevice->Implementation->Device; const auto hr = dxdevice->CreateRenderTargetView( impl->dxTexture2D.Get(), diff --git a/sources/framework-dx/samplerstate.cpp b/sources/framework-dx/samplerstate.cpp index d29158d..e91d9c2 100644 --- a/sources/framework-dx/samplerstate.cpp +++ b/sources/framework-dx/samplerstate.cpp @@ -11,7 +11,7 @@ namespace xna { bool SamplerState::Initialize() { - if (!impl || !m_device || !m_device->Implementation->Device) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } @@ -19,7 +19,7 @@ namespace xna { impl->_samplerState = nullptr; } - const auto hr = m_device->Implementation->Device->CreateSamplerState( + const auto hr = BaseGraphicsDevice->Implementation->Device->CreateSamplerState( &impl->_description, impl->_samplerState.GetAddressOf()); @@ -32,7 +32,7 @@ namespace xna { bool SamplerState::Apply() { - if (!impl || !m_device || !m_device->Implementation->Context) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } @@ -40,7 +40,7 @@ namespace xna { Exception::Throw(Exception::INVALID_OPERATION); } - m_device->Implementation->Context->PSSetSamplers(0, 1, impl->_samplerState.GetAddressOf()); + BaseGraphicsDevice->Implementation->Context->PSSetSamplers(0, 1, impl->_samplerState.GetAddressOf()); return true; } diff --git a/sources/framework-dx/sprite.cpp b/sources/framework-dx/sprite.cpp index 5b6d4ad..b29831d 100644 --- a/sources/framework-dx/sprite.cpp +++ b/sources/framework-dx/sprite.cpp @@ -139,14 +139,14 @@ namespace xna { effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); - m_device->Implementation->Device->CreateInputLayout( + BaseGraphicsDevice->Implementation->Device->CreateInputLayout( DirectX::VertexPositionColorTexture::InputElements, DirectX::VertexPositionColorTexture::InputElementCount, shaderByteCode, byteCodeLength, impl->dxInputLayout.GetAddressOf()); } - auto& context = m_device->Implementation->Context; + auto& context = BaseGraphicsDevice->Implementation->Context; effectFunc = [=] { impl->dxEffectBuffer->Apply(context.Get()); diff --git a/sources/framework-dx/swapchain.cpp b/sources/framework-dx/swapchain.cpp index d4ffcfe..5ae5700 100644 --- a/sources/framework-dx/swapchain.cpp +++ b/sources/framework-dx/swapchain.cpp @@ -44,11 +44,11 @@ namespace xna { } bool SwapChain::Initialize() { - if (!impl || !m_device || !m_device->Implementation->Device) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } - const auto parameters = m_device->PresentParameters(); + const auto parameters = BaseGraphicsDevice->PresentParameters(); impl->dxDescription.Width = static_cast(parameters->BackBufferWidth); impl->dxDescription.Height = static_cast(parameters->BackBufferHeight); @@ -67,7 +67,7 @@ namespace xna { impl->dxFullScreenDescription.Windowed = !parameters->IsFullscreen; HWND hwnd = reinterpret_cast(parameters->DeviceWindowHandle); - return internalInit(*m_device, hwnd, impl->dxSwapChain, impl->dxDescription, impl->dxFullScreenDescription); + return internalInit(*BaseGraphicsDevice, hwnd, impl->dxSwapChain, impl->dxDescription, impl->dxFullScreenDescription); } bool SwapChain::GetBackBuffer(Texture2D& texture2D) { diff --git a/sources/framework-dx/texture.cpp b/sources/framework-dx/texture.cpp index 7990535..3322e87 100644 --- a/sources/framework-dx/texture.cpp +++ b/sources/framework-dx/texture.cpp @@ -33,11 +33,11 @@ namespace xna { void Texture2D::Initialize() { - if (!m_device || !m_device->Implementation->Device) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } - auto& deviceImpl = m_device->Implementation; + auto& deviceImpl = BaseGraphicsDevice->Implementation; HRESULT hr = 0; @@ -81,16 +81,16 @@ namespace xna { void Texture2D::SetData(std::vector const& data, size_t startIndex, size_t elementCount) { - if (!impl || !m_device || !m_device->Implementation->Device || !m_device->Implementation->Context) { + if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } - internalTexture2DSetData(*impl, *m_device, data.data()); + internalTexture2DSetData(*impl, *BaseGraphicsDevice, data.data()); } void Texture2D::SetData(std::vector const& data, size_t startIndex, size_t elementCount) { - if (!m_device || !m_device->Implementation->Device || !m_device->Implementation->Context) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } @@ -106,12 +106,12 @@ namespace xna { ++fIndex; } - internalTexture2DSetData(*impl, *m_device, finalData.data()); + internalTexture2DSetData(*impl, *BaseGraphicsDevice, finalData.data()); } void Texture2D::SetData(Int level, Rectangle* rect, std::vector const& data, size_t startIndex, size_t elementCount) { - if (!m_device || !m_device->Implementation->Device || !m_device->Implementation->Context) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } @@ -128,7 +128,7 @@ namespace xna { } if (!impl->dxTexture2D) { - auto hr = m_device->Implementation->Device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.GetAddressOf()); + auto hr = BaseGraphicsDevice->Implementation->Device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.GetAddressOf()); if (FAILED(hr)) { Exception::Throw(Exception::FAILED_TO_CREATE); @@ -154,11 +154,11 @@ namespace xna { } constexpr int R8G8B8A8U_BYTE_SIZE = 4; - m_device->Implementation->Context->UpdateSubresource(resource.Get(), 0, rect ? &box : nullptr, finalData.data(), impl->dxDescription.Width * R8G8B8A8U_BYTE_SIZE, 0); + BaseGraphicsDevice->Implementation->Context->UpdateSubresource(resource.Get(), 0, rect ? &box : nullptr, finalData.data(), impl->dxDescription.Width * R8G8B8A8U_BYTE_SIZE, 0); impl->dxShaderDescription.Format = impl->dxDescription.Format; impl->dxShaderDescription.Texture2D.MipLevels = impl->dxDescription.MipLevels; - hr = m_device->Implementation->Device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf()); + hr = BaseGraphicsDevice->Implementation->Device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf()); if (FAILED(hr)) { Exception::Throw(Exception::FAILED_TO_CREATE); @@ -169,7 +169,7 @@ namespace xna { void Texture2D::SetData(std::vector const& data, size_t startIndex, size_t elementCount) { - if (!m_device || !m_device->Implementation->Device || !m_device->Implementation->Context) { + if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device || !BaseGraphicsDevice->Implementation->Context) { Exception::Throw(Exception::INVALID_OPERATION); } @@ -181,7 +181,7 @@ namespace xna { ++finalDataIndex; } - internalTexture2DSetData(*impl, *m_device, finalData.data()); + internalTexture2DSetData(*impl, *BaseGraphicsDevice, finalData.data()); } P_Texture2D Texture2D::FromStream(GraphicsDevice& device, P_Stream const& stream) diff --git a/sources/framework/graphics/gresource.cpp b/sources/framework/graphics/gresource.cpp index 5219809..9be7a35 100644 --- a/sources/framework/graphics/gresource.cpp +++ b/sources/framework/graphics/gresource.cpp @@ -1,17 +1,17 @@ #include "xna/graphics/gresource.hpp" namespace xna { - GraphicsResource::GraphicsResource(sptr const& device) : m_device(device) {} + GraphicsResource::GraphicsResource(sptr const& device) : BaseGraphicsDevice(device) {} sptr GraphicsResource::Device() const { - return m_device; + return BaseGraphicsDevice; } bool GraphicsResource::Bind(sptr const& device) { - if (!device || device == m_device) + if (!device || device == BaseGraphicsDevice) return false; - m_device = device; + BaseGraphicsDevice = device; return true; }