1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

renomeia m_device para BaseGraphicsDevice

This commit is contained in:
Danilo 2024-11-14 21:44:46 -03:00
parent 18f487a5e4
commit 28f4575206
10 changed files with 40 additions and 40 deletions

View File

@ -17,7 +17,7 @@ namespace xna {
sptr<xna::GraphicsDevice> Device() const; sptr<xna::GraphicsDevice> Device() const;
protected: protected:
sptr<GraphicsDevice> m_device = nullptr; sptr<GraphicsDevice> BaseGraphicsDevice = nullptr;
}; };
} }

View File

@ -97,7 +97,7 @@ namespace xna {
bool BlendState::Initialize() bool BlendState::Initialize()
{ {
if (!m_device || !m_device->Implementation->Device) { if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -105,7 +105,7 @@ namespace xna {
Implementation->BlendState = nullptr; Implementation->BlendState = nullptr;
} }
const auto hr = m_device->Implementation->Device->CreateBlendState( const auto hr = BaseGraphicsDevice->Implementation->Device->CreateBlendState(
&Implementation->Description, &Implementation->Description,
Implementation->BlendState.GetAddressOf()); Implementation->BlendState.GetAddressOf());
@ -117,7 +117,7 @@ namespace xna {
} }
bool BlendState::Apply() { bool BlendState::Apply() {
if (!m_device || !m_device->Implementation->Context) { if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) {
Exception::Throw(Exception::FAILED_TO_APPLY); Exception::Throw(Exception::FAILED_TO_APPLY);
} }
@ -125,7 +125,7 @@ namespace xna {
Initialize(); Initialize();
} }
m_device->Implementation->Context->OMSetBlendState( BaseGraphicsDevice->Implementation->Context->OMSetBlendState(
Implementation->BlendState.Get(), Implementation->BlendState.Get(),
Implementation->BlendFactor, Implementation->BlendFactor,
Implementation->SampleMask); Implementation->SampleMask);

View File

@ -37,7 +37,7 @@ namespace xna {
bool DepthStencilState::Initialize() bool DepthStencilState::Initialize()
{ {
if (!m_device || !m_device->Implementation->Device) { if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -45,7 +45,7 @@ namespace xna {
Implementation->DepthStencil = nullptr; Implementation->DepthStencil = nullptr;
} }
const auto hr = m_device->Implementation->Device->CreateDepthStencilState( const auto hr = BaseGraphicsDevice->Implementation->Device->CreateDepthStencilState(
&Implementation->Description, &Implementation->Description,
Implementation->DepthStencil.GetAddressOf()); Implementation->DepthStencil.GetAddressOf());
@ -58,7 +58,7 @@ namespace xna {
bool DepthStencilState::Apply() bool DepthStencilState::Apply()
{ {
if (!m_device || !m_device->Implementation->Context) { if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) {
Exception::Throw(Exception::INVALID_OPERATION); Exception::Throw(Exception::INVALID_OPERATION);
} }
@ -66,7 +66,7 @@ namespace xna {
Initialize(); Initialize();
} }
m_device->Implementation->Context->OMSetDepthStencilState(Implementation->DepthStencil.Get(), 0); BaseGraphicsDevice->Implementation->Context->OMSetDepthStencilState(Implementation->DepthStencil.Get(), 0);
return true; return true;
} }

View File

@ -17,7 +17,7 @@ namespace xna {
bool RasterizerState::Initialize() bool RasterizerState::Initialize()
{ {
if (!impl || !m_device || !m_device->Implementation->Device) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -25,7 +25,7 @@ namespace xna {
impl->dxRasterizerState = nullptr; impl->dxRasterizerState = nullptr;
} }
const auto hr = m_device->Implementation->Device->CreateRasterizerState( const auto hr = BaseGraphicsDevice->Implementation->Device->CreateRasterizerState(
&impl->dxDescription, &impl->dxDescription,
impl->dxRasterizerState.GetAddressOf()); impl->dxRasterizerState.GetAddressOf());
@ -38,7 +38,7 @@ namespace xna {
bool RasterizerState::Apply() bool RasterizerState::Apply()
{ {
if (!impl || !m_device || !m_device->Implementation->Context) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -46,7 +46,7 @@ namespace xna {
Exception::Throw(Exception::INVALID_OPERATION); Exception::Throw(Exception::INVALID_OPERATION);
} }
m_device->Implementation->Context->RSSetState(impl->dxRasterizerState.Get()); BaseGraphicsDevice->Implementation->Context->RSSetState(impl->dxRasterizerState.Get());
return true; return true;
} }

View File

@ -26,7 +26,7 @@ namespace xna {
} }
void RenderTarget2D::Initialize() { void RenderTarget2D::Initialize() {
if (!impl || !m_device || !m_device->Implementation->Device) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -39,7 +39,7 @@ namespace xna {
Texture2D::Initialize(); Texture2D::Initialize();
auto& dxdevice = m_device->Implementation->Device; auto& dxdevice = BaseGraphicsDevice->Implementation->Device;
const auto hr = dxdevice->CreateRenderTargetView( const auto hr = dxdevice->CreateRenderTargetView(
impl->dxTexture2D.Get(), impl->dxTexture2D.Get(),

View File

@ -11,7 +11,7 @@ namespace xna {
bool SamplerState::Initialize() bool SamplerState::Initialize()
{ {
if (!impl || !m_device || !m_device->Implementation->Device) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
@ -19,7 +19,7 @@ namespace xna {
impl->_samplerState = nullptr; impl->_samplerState = nullptr;
} }
const auto hr = m_device->Implementation->Device->CreateSamplerState( const auto hr = BaseGraphicsDevice->Implementation->Device->CreateSamplerState(
&impl->_description, &impl->_description,
impl->_samplerState.GetAddressOf()); impl->_samplerState.GetAddressOf());
@ -32,7 +32,7 @@ namespace xna {
bool SamplerState::Apply() bool SamplerState::Apply()
{ {
if (!impl || !m_device || !m_device->Implementation->Context) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Context) {
Exception::Throw(Exception::INVALID_OPERATION); Exception::Throw(Exception::INVALID_OPERATION);
} }
@ -40,7 +40,7 @@ namespace xna {
Exception::Throw(Exception::INVALID_OPERATION); 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; return true;
} }

View File

@ -139,14 +139,14 @@ namespace xna {
effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength); effect->impl->dxEffect->GetVertexShaderBytecode(&shaderByteCode, &byteCodeLength);
m_device->Implementation->Device->CreateInputLayout( BaseGraphicsDevice->Implementation->Device->CreateInputLayout(
DirectX::VertexPositionColorTexture::InputElements, DirectX::VertexPositionColorTexture::InputElements,
DirectX::VertexPositionColorTexture::InputElementCount, DirectX::VertexPositionColorTexture::InputElementCount,
shaderByteCode, byteCodeLength, shaderByteCode, byteCodeLength,
impl->dxInputLayout.GetAddressOf()); impl->dxInputLayout.GetAddressOf());
} }
auto& context = m_device->Implementation->Context; auto& context = BaseGraphicsDevice->Implementation->Context;
effectFunc = [=] { effectFunc = [=] {
impl->dxEffectBuffer->Apply(context.Get()); impl->dxEffectBuffer->Apply(context.Get());

View File

@ -44,11 +44,11 @@ namespace xna {
} }
bool SwapChain::Initialize() { bool SwapChain::Initialize() {
if (!impl || !m_device || !m_device->Implementation->Device) { if (!impl || !BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
const auto parameters = m_device->PresentParameters(); const auto parameters = BaseGraphicsDevice->PresentParameters();
impl->dxDescription.Width = static_cast<UINT>(parameters->BackBufferWidth); impl->dxDescription.Width = static_cast<UINT>(parameters->BackBufferWidth);
impl->dxDescription.Height = static_cast<UINT>(parameters->BackBufferHeight); impl->dxDescription.Height = static_cast<UINT>(parameters->BackBufferHeight);
@ -67,7 +67,7 @@ namespace xna {
impl->dxFullScreenDescription.Windowed = !parameters->IsFullscreen; impl->dxFullScreenDescription.Windowed = !parameters->IsFullscreen;
HWND hwnd = reinterpret_cast<HWND>(parameters->DeviceWindowHandle); HWND hwnd = reinterpret_cast<HWND>(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) { bool SwapChain::GetBackBuffer(Texture2D& texture2D) {

View File

@ -33,11 +33,11 @@ namespace xna {
void Texture2D::Initialize() void Texture2D::Initialize()
{ {
if (!m_device || !m_device->Implementation->Device) { if (!BaseGraphicsDevice || !BaseGraphicsDevice->Implementation->Device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE); Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
} }
auto& deviceImpl = m_device->Implementation; auto& deviceImpl = BaseGraphicsDevice->Implementation;
HRESULT hr = 0; HRESULT hr = 0;
@ -81,16 +81,16 @@ namespace xna {
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount) void Texture2D::SetData(std::vector<Uint> 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); Exception::Throw(Exception::INVALID_OPERATION);
} }
internalTexture2DSetData(*impl, *m_device, data.data()); internalTexture2DSetData(*impl, *BaseGraphicsDevice, data.data());
} }
void Texture2D::SetData(std::vector<Byte> const& data, size_t startIndex, size_t elementCount) void Texture2D::SetData(std::vector<Byte> 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); Exception::Throw(Exception::INVALID_OPERATION);
} }
@ -106,12 +106,12 @@ namespace xna {
++fIndex; ++fIndex;
} }
internalTexture2DSetData(*impl, *m_device, finalData.data()); internalTexture2DSetData(*impl, *BaseGraphicsDevice, finalData.data());
} }
void Texture2D::SetData(Int level, Rectangle* rect, std::vector<Byte> const& data, size_t startIndex, size_t elementCount) void Texture2D::SetData(Int level, Rectangle* rect, std::vector<Byte> 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); Exception::Throw(Exception::INVALID_OPERATION);
} }
@ -128,7 +128,7 @@ namespace xna {
} }
if (!impl->dxTexture2D) { 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)) { if (FAILED(hr)) {
Exception::Throw(Exception::FAILED_TO_CREATE); Exception::Throw(Exception::FAILED_TO_CREATE);
@ -154,11 +154,11 @@ namespace xna {
} }
constexpr int R8G8B8A8U_BYTE_SIZE = 4; 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.Format = impl->dxDescription.Format;
impl->dxShaderDescription.Texture2D.MipLevels = impl->dxDescription.MipLevels; 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)) { if (FAILED(hr)) {
Exception::Throw(Exception::FAILED_TO_CREATE); Exception::Throw(Exception::FAILED_TO_CREATE);
@ -169,7 +169,7 @@ namespace xna {
void Texture2D::SetData(std::vector<Color> const& data, size_t startIndex, size_t elementCount) void Texture2D::SetData(std::vector<Color> 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); Exception::Throw(Exception::INVALID_OPERATION);
} }
@ -181,7 +181,7 @@ namespace xna {
++finalDataIndex; ++finalDataIndex;
} }
internalTexture2DSetData(*impl, *m_device, finalData.data()); internalTexture2DSetData(*impl, *BaseGraphicsDevice, finalData.data());
} }
P_Texture2D Texture2D::FromStream(GraphicsDevice& device, P_Stream const& stream) P_Texture2D Texture2D::FromStream(GraphicsDevice& device, P_Stream const& stream)

View File

@ -1,17 +1,17 @@
#include "xna/graphics/gresource.hpp" #include "xna/graphics/gresource.hpp"
namespace xna { namespace xna {
GraphicsResource::GraphicsResource(sptr<GraphicsDevice> const& device) : m_device(device) {} GraphicsResource::GraphicsResource(sptr<GraphicsDevice> const& device) : BaseGraphicsDevice(device) {}
sptr<GraphicsDevice> GraphicsResource::Device() const { sptr<GraphicsDevice> GraphicsResource::Device() const {
return m_device; return BaseGraphicsDevice;
} }
bool GraphicsResource::Bind(sptr<GraphicsDevice> const& device) { bool GraphicsResource::Bind(sptr<GraphicsDevice> const& device) {
if (!device || device == m_device) if (!device || device == BaseGraphicsDevice)
return false; return false;
m_device = device; BaseGraphicsDevice = device;
return true; return true;
} }