From fedb773b3112adea2d0d48dc2579a095b6926ede Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 15:42:56 -0300 Subject: [PATCH 1/6] Implementa RenderTarget::FromBackBuffer --- framework/platform-dx/device.cpp | 3 +- framework/platform-dx/rendertarget.cpp | 43 +++++++++----- framework/platform-dx/texture.cpp | 81 ++++++++++++++------------ inc/xna/default.hpp | 1 + inc/xna/graphics/rendertarget.hpp | 15 +---- samples/CMakeLists.txt | 2 +- 6 files changed, 81 insertions(+), 64 deletions(-) diff --git a/framework/platform-dx/device.cpp b/framework/platform-dx/device.cpp index 5f440ff..ffff87b 100644 --- a/framework/platform-dx/device.cpp +++ b/framework/platform-dx/device.cpp @@ -54,8 +54,7 @@ namespace xna { if (FAILED(hr)) Exception::Throw(Exception::FAILED_TO_MAKE_WINDOW_ASSOCIATION); - impl->_renderTarget2D = snew(_this); - impl->_renderTarget2D->Initialize(); + impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this); impl->_renderTarget2D->Apply(); D3D11_VIEWPORT view = DxHelpers::ViewportToDx(viewport); diff --git a/framework/platform-dx/rendertarget.cpp b/framework/platform-dx/rendertarget.cpp index ddd6b4a..6bc26cb 100644 --- a/framework/platform-dx/rendertarget.cpp +++ b/framework/platform-dx/rendertarget.cpp @@ -1,36 +1,53 @@ #include "xna/xna-dx.hpp" namespace xna { + RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) { + impl2 = unew(); + } + RenderTarget2D::RenderTarget2D(sptr const& device) : Texture2D(device) { impl2 = unew(); } - void RenderTarget2D::Initialize() { - if (!impl || !m_device || !m_device->impl->_device) { - Exception::Throw(Exception::UNABLE_TO_INITIALIZE); - } + P_RenderTarget2D RenderTarget2D::FromBackBuffer(P_GraphicsDevice const& device) { + auto& swapChain = device->impl->_swapChain; + auto rt = snew(device); + auto& implementation = rt->impl; + auto& implementation2 = rt->impl2; - auto& swapChain = m_device->impl->_swapChain; - - if (!swapChain->impl->GetBackBuffer(impl->dxTexture2D)) + if (!swapChain->impl->GetBackBuffer(implementation->dxTexture2D)) { Exception::Throw(Exception::FAILED_TO_CREATE); } - impl->dxTexture2D->GetDesc(&impl->dxDescription); + rt->Initialize(); + + return rt; + } + + void RenderTarget2D::Initialize() { + if (!impl || !m_device || !m_device->impl->_device) { + Exception::Throw(Exception::UNABLE_TO_INITIALIZE); + } + + impl->dxDescription.Width = width; + impl->dxDescription.Height = height; + impl->dxDescription.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET; + + Texture2D::Initialize(); + auto& dxdevice = m_device->impl->_device; - const auto hr = dxdevice->CreateRenderTargetView(impl->dxTexture2D.Get(), NULL, impl2->_renderTargetView.ReleaseAndGetAddressOf()); + const auto hr = dxdevice->CreateRenderTargetView( + impl->dxTexture2D.Get(), + NULL, + impl2->_renderTargetView.ReleaseAndGetAddressOf()); if (FAILED(hr)) { Exception::Throw(Exception::FAILED_TO_CREATE); } impl2->_renderTargetView->GetDesc(&impl2->_renderTargetDesc); - - //depthStencilFormat = DepthFormat::None; - multiSampleCount = impl->dxDescription.SampleDesc.Count; - //targetUsage = RenderTargetUsage::DiscardContent; } void RenderTarget2D::Apply() { diff --git a/framework/platform-dx/texture.cpp b/framework/platform-dx/texture.cpp index 38219e1..1dde906 100644 --- a/framework/platform-dx/texture.cpp +++ b/framework/platform-dx/texture.cpp @@ -4,16 +4,50 @@ namespace xna { static void setDefaultTexture2DDesc(Texture2D::PlatformImplementation& impl); static HRESULT internalTexture2DSetData(Texture2D::PlatformImplementation& impl, GraphicsDevice& device, UINT const* data); + Texture2D::Texture2D() : Texture(nullptr) { + impl = unew(); + setDefaultTexture2DDesc(*impl); + } + + Texture2D::Texture2D(sptr const& device, size_t width, size_t height) : Texture(device), width(width), height(height) { + impl = unew(); + setDefaultTexture2DDesc(*impl); + impl->dxDescription.Width = static_cast(this->width); + impl->dxDescription.Height = static_cast(this->height); + } + + Texture2D::Texture2D(sptr const& device) : Texture(device) { + impl = unew(); + setDefaultTexture2DDesc(*impl); + } + + Texture2D::Texture2D(sptr const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format) + : Texture(device), width(width), height(height), levelCount(mipMap) { + impl = unew(); + setDefaultTexture2DDesc(*impl); + impl->dxDescription.Width = static_cast(this->width); + impl->dxDescription.Height = static_cast(this->height); + impl->dxDescription.MipLevels = static_cast(this->levelCount); + impl->dxDescription.Format = DxHelpers::SurfaceFormatToDx(format); + } + void Texture2D::Initialize() { if (!m_device || !m_device->impl->_device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } - auto hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.ReleaseAndGetAddressOf()); + HRESULT hr = 0; - if (FAILED(hr)) { - Exception::Throw(Exception::FAILED_TO_CREATE); + if (!impl->dxTexture2D) { + hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.ReleaseAndGetAddressOf()); + + if (FAILED(hr)) { + Exception::Throw(Exception::FAILED_TO_CREATE); + } + } + else { + impl->dxTexture2D->GetDesc(&impl->dxDescription); } comptr resource = nullptr; @@ -22,45 +56,20 @@ namespace xna { if (FAILED(hr)) { Exception::Throw(Exception::INVALID_OPERATION); } + + if (impl->dxDescription.BindFlags & D3D11_BIND_SHADER_RESOURCE) { + hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf()); - hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, &impl->dxShaderResource); - - if (FAILED(hr)) { - Exception::Throw(Exception::FAILED_TO_CREATE); - } + if (FAILED(hr)) { + Exception::Throw(Exception::FAILED_TO_CREATE); + } + } surfaceFormat = DxHelpers::SurfaceFormatToXna(impl->dxDescription.Format); levelCount = static_cast(impl->dxShaderDescription.Texture2D.MipLevels); width = static_cast(impl->dxDescription.Width); height = static_cast(impl->dxDescription.Height); - } - - Texture2D::Texture2D() : Texture(nullptr) { - impl = unew(); - setDefaultTexture2DDesc(*impl); - } - - Texture2D::Texture2D(sptr const& device, size_t width, size_t height) : Texture(device) { - impl = unew(); - setDefaultTexture2DDesc(*impl); - impl->dxDescription.Width = static_cast(width); - impl->dxDescription.Height = static_cast(height); - } - - Texture2D::Texture2D(sptr const& device) : Texture(device) { - impl = unew(); - setDefaultTexture2DDesc(*impl); - } - - Texture2D::Texture2D(sptr const& device, size_t width, size_t height, size_t mipMap, SurfaceFormat format) : Texture(device) - { - impl = unew(); - setDefaultTexture2DDesc(*impl); - impl->dxDescription.Width = static_cast(width); - impl->dxDescription.Height = static_cast(height); - impl->dxDescription.MipLevels = static_cast(mipMap); - impl->dxDescription.Format = DxHelpers::SurfaceFormatToDx(format); - } + } void Texture2D::SetData(std::vector const& data, size_t startIndex, size_t elementCount) { diff --git a/inc/xna/default.hpp b/inc/xna/default.hpp index b6a4602..a1ed6e5 100644 --- a/inc/xna/default.hpp +++ b/inc/xna/default.hpp @@ -207,6 +207,7 @@ namespace xna { using P_FileStream = sptr; using P_Texture = sptr; using P_Texture2D = sptr; + using P_RenderTarget2D = sptr; } diff --git a/inc/xna/graphics/rendertarget.hpp b/inc/xna/graphics/rendertarget.hpp index ae49df5..ee91904 100644 --- a/inc/xna/graphics/rendertarget.hpp +++ b/inc/xna/graphics/rendertarget.hpp @@ -8,22 +8,13 @@ namespace xna { class RenderTarget2D : public Texture2D { public: RenderTarget2D(); - RenderTarget2D(sptr const& device); + RenderTarget2D(sptr const& device); - //Gets the data format for the depth stencil data. - constexpr DepthFormat DepthStencilFormat() const { return depthStencilFormat; } - //Gets the number of sample locations during multisampling. - constexpr Int MultiSampleCount() const { return multiSampleCount; } - //Gets or sets the render target usage. - constexpr RenderTargetUsage TargetUsage() const { return targetUsage; } + + static P_RenderTarget2D FromBackBuffer(P_GraphicsDevice const& device); void Initialize(); void Apply(); - private: - DepthFormat depthStencilFormat{ DepthFormat::None }; - Int multiSampleCount{ 0 }; - RenderTargetUsage targetUsage{ RenderTargetUsage::DiscardContents }; - public: struct PlatformImplementation; uptr impl2 = nullptr; diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 24ef843..45257e9 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -4,4 +4,4 @@ # Add source to this project's executable. add_subdirectory ("01_blank") -#add_subdirectory ("02_PlatfformerStarterKit") +add_subdirectory ("02_PlatfformerStarterKit") From c21871a9519a10b0a0569c4827e8b455eee8435f Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 16:12:53 -0300 Subject: [PATCH 2/6] =?UTF-8?q?Pequenas=20corre=C3=A7=C3=B5es=20em=20Textu?= =?UTF-8?q?re2D::Initialize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/platform-dx/texture.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/framework/platform-dx/texture.cpp b/framework/platform-dx/texture.cpp index 1dde906..a4955d1 100644 --- a/framework/platform-dx/texture.cpp +++ b/framework/platform-dx/texture.cpp @@ -35,34 +35,42 @@ namespace xna { { if (!m_device || !m_device->impl->_device) { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); - } + } + + auto& deviceImpl = m_device->impl; HRESULT hr = 0; - + if (!impl->dxTexture2D) { - hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.ReleaseAndGetAddressOf()); + hr = deviceImpl->_device->CreateTexture2D( + &impl->dxDescription, + nullptr, + impl->dxTexture2D.ReleaseAndGetAddressOf()); - if (FAILED(hr)) { + if FAILED(hr) Exception::Throw(Exception::FAILED_TO_CREATE); - } } else { + //Updates description if texture is not null impl->dxTexture2D->GetDesc(&impl->dxDescription); } comptr resource = nullptr; hr = impl->dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf()); - if (FAILED(hr)) { + if FAILED(hr) Exception::Throw(Exception::INVALID_OPERATION); - } + //Only initializes if it is a ShaderResource if (impl->dxDescription.BindFlags & D3D11_BIND_SHADER_RESOURCE) { - hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf()); + hr = deviceImpl->_device->CreateShaderResourceView( + resource.Get(), + &impl->dxShaderDescription, + impl->dxShaderResource.ReleaseAndGetAddressOf()); - if (FAILED(hr)) { + if FAILED(hr) Exception::Throw(Exception::FAILED_TO_CREATE); - } + } surfaceFormat = DxHelpers::SurfaceFormatToXna(impl->dxDescription.Format); From 491626d654aaf73012ab6b106ba164098d1e9038 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 16:47:00 -0300 Subject: [PATCH 3/6] =?UTF-8?q?Corre=C3=A7=C3=B5es=20em=20GraphicsDevice::?= =?UTF-8?q?Initialize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/platform-dx/device.cpp | 64 ++++++++++++++++++-------- framework/platform-dx/rendertarget.cpp | 14 ------ inc/xna/graphics/rendertarget.hpp | 5 +- 3 files changed, 47 insertions(+), 36 deletions(-) diff --git a/framework/platform-dx/device.cpp b/framework/platform-dx/device.cpp index ffff87b..3d525b7 100644 --- a/framework/platform-dx/device.cpp +++ b/framework/platform-dx/device.cpp @@ -22,46 +22,61 @@ namespace xna { } void GraphicsDevice::Initialize() { - auto _this = shared_from_this(); - - reset(*impl); - createDevice(*impl, *adapter); - - auto hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&impl->_factory); + reset(*impl); - if FAILED(hr) - Exception::Throw(Exception::FAILED_TO_CREATE); - - viewport = xna::Viewport(0.0F, 0.0F, - presentationParameters->BackBufferWidth, - presentationParameters->BackBufferHeight, - 0.0F, 1.F); + auto _this = shared_from_this(); + + createDevice(*impl, *adapter); + // + // Background + // + const auto backColor = Colors::CornflowerBlue; const auto backColorV3 = backColor.ToVector3(); impl->_backgroundColor[0] = backColorV3.X; impl->_backgroundColor[1] = backColorV3.Y; impl->_backgroundColor[2] = backColorV3.Z; - impl->_backgroundColor[3] = 1.0f; + impl->_backgroundColor[3] = 1.0f; - impl->_swapChain = snew(_this); - impl->_swapChain->Initialize(); + // + // Window Association + // + + auto hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&impl->_factory); + + if FAILED(hr) + Exception::Throw(Exception::FAILED_TO_CREATE); auto hwnd = reinterpret_cast(presentationParameters->DeviceWindowHandle); hr = impl->_factory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER); if (FAILED(hr)) Exception::Throw(Exception::FAILED_TO_MAKE_WINDOW_ASSOCIATION); - - impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this); - impl->_renderTarget2D->Apply(); + + // + // Viewport + // + + viewport = xna::Viewport(0.0F, 0.0F, + presentationParameters->BackBufferWidth, + presentationParameters->BackBufferHeight, + 0.0F, 1.F); D3D11_VIEWPORT view = DxHelpers::ViewportToDx(viewport); impl->_context->RSSetViewports(1, &view); + // + // States + // + initAndApplyState(blendState, rasterizerState, depthStencilState, samplerStateCollection, _this); + // + // Presentation + // + const auto currentPresenInterval = presentationParameters->PresentationInterval; switch (currentPresenInterval) @@ -78,6 +93,17 @@ namespace xna { impl->vSyncValue = 1; break; } + + impl->_swapChain = snew(_this); + impl->_swapChain->Initialize(); + + // + //Render Target + // + + impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this); + const auto& renderView = impl->_renderTarget2D->impl2->_renderTargetView; + impl->_context->OMSetRenderTargets(1, renderView.GetAddressOf(), nullptr); } bool GraphicsDevice::Present() const { diff --git a/framework/platform-dx/rendertarget.cpp b/framework/platform-dx/rendertarget.cpp index 6bc26cb..3c0aafa 100644 --- a/framework/platform-dx/rendertarget.cpp +++ b/framework/platform-dx/rendertarget.cpp @@ -49,18 +49,4 @@ namespace xna { impl2->_renderTargetView->GetDesc(&impl2->_renderTargetDesc); } - - void RenderTarget2D::Apply() { - if (!m_device || !m_device->impl->_context) { - Exception::Throw(Exception::FAILED_TO_APPLY); - } - - if (!impl2->_renderTargetView) - { - Initialize(); - } - - auto& context = m_device->impl->_context; - context->OMSetRenderTargets(1, impl2->_renderTargetView.GetAddressOf(), nullptr); - } } \ No newline at end of file diff --git a/inc/xna/graphics/rendertarget.hpp b/inc/xna/graphics/rendertarget.hpp index ee91904..168fd6c 100644 --- a/inc/xna/graphics/rendertarget.hpp +++ b/inc/xna/graphics/rendertarget.hpp @@ -5,16 +5,15 @@ #include "texture.hpp" namespace xna { + //Contains a 2D texture that can be used as a render target. class RenderTarget2D : public Texture2D { public: RenderTarget2D(); - RenderTarget2D(sptr const& device); - + RenderTarget2D(sptr const& device); static P_RenderTarget2D FromBackBuffer(P_GraphicsDevice const& device); void Initialize(); - void Apply(); public: struct PlatformImplementation; uptr impl2 = nullptr; From b27b04388a5b13f6ca3b7e22372efc625c7e38ac Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 17:32:28 -0300 Subject: [PATCH 4/6] Implementa GraphicsDevice::SetRenderTarget --- framework/platform-dx/device.cpp | 10 ++++++++-- framework/platform-dx/rendertarget.cpp | 3 +++ inc/xna/graphics/device.hpp | 5 ++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/framework/platform-dx/device.cpp b/framework/platform-dx/device.cpp index 3d525b7..018dca0 100644 --- a/framework/platform-dx/device.cpp +++ b/framework/platform-dx/device.cpp @@ -101,13 +101,19 @@ namespace xna { //Render Target // - impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this); + if (renderTarget) { + renderTarget->Initialize(); + impl->_renderTarget2D = renderTarget; + } + else { + impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this); + } + const auto& renderView = impl->_renderTarget2D->impl2->_renderTargetView; impl->_context->OMSetRenderTargets(1, renderView.GetAddressOf(), nullptr); } bool GraphicsDevice::Present() const { - const auto currentPresenInterval = presentationParameters->PresentationInterval; bool result = impl->_swapChain->Present(impl->vSyncValue != 0); impl->_context->OMSetRenderTargets( diff --git a/framework/platform-dx/rendertarget.cpp b/framework/platform-dx/rendertarget.cpp index 3c0aafa..08a83ca 100644 --- a/framework/platform-dx/rendertarget.cpp +++ b/framework/platform-dx/rendertarget.cpp @@ -30,6 +30,9 @@ namespace xna { Exception::Throw(Exception::UNABLE_TO_INITIALIZE); } + if (impl2->_renderTargetView) + return; + impl->dxDescription.Width = width; impl->dxDescription.Height = height; impl->dxDescription.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET; diff --git a/inc/xna/graphics/device.hpp b/inc/xna/graphics/device.hpp index 08f259e..0cb6f4c 100644 --- a/inc/xna/graphics/device.hpp +++ b/inc/xna/graphics/device.hpp @@ -45,7 +45,9 @@ namespace xna { constexpr xna::Viewport Viewport() const { return viewport; } //Gets or sets a viewport identifying the portion of the render target to receive draw calls. void Viewport(xna::Viewport const& viewport); - + //Sets a new render target for this GraphicsDevice. + void SetRenderTarget(P_RenderTarget2D const& renderTarget) { this->renderTarget = renderTarget; } + void Initialize(); private: @@ -55,6 +57,7 @@ namespace xna { P_RasterizerState rasterizerState{ nullptr }; P_SamplerStateCollection samplerStateCollection{ nullptr }; P_PresentationParameters presentationParameters{ nullptr }; + P_RenderTarget2D renderTarget{ nullptr }; GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef }; xna::Viewport viewport{}; From 275233589343684b785c9c666bbd6fdba39d4c1a Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 17:38:35 -0300 Subject: [PATCH 5/6] =?UTF-8?q?Coment=C3=A1rios=20em=20PresentationParamet?= =?UTF-8?q?ers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/xna/graphics/presentparams.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/xna/graphics/presentparams.hpp b/inc/xna/graphics/presentparams.hpp index 2306f12..982d9d3 100644 --- a/inc/xna/graphics/presentparams.hpp +++ b/inc/xna/graphics/presentparams.hpp @@ -4,17 +4,24 @@ #include "../default.hpp" namespace xna { + //Contains presentation parameters. struct PresentationParameters { - constexpr PresentationParameters() = default; - + //Gets or sets a value indicating the width of the new swap chain's back buffer. Int BackBufferWidth{ 0 }; + //Gets or sets a value indicating the height of the new swap chain's back buffer. Int BackBufferHeight{ 0 }; + //Gets or sets the format of the back buffer. SurfaceFormat BackBufferFormat{ SurfaceFormat::Color }; SwapEffect PresentationSwapEffect{ SwapEffect::FlipDiscard }; + //Gets or sets the handle to the device window. intptr_t DeviceWindowHandle{ 0 }; + //Gets or sets a value indicating whether the application is in full screen mode. bool IsFullscreen{ false }; + //Gets or sets a value indicating the number of sample locations during multisampling. Int MultiSampleCount{ 0 }; + //Gets or sets the maximum rate at which the swap chain's back buffers can be presented to the front buffer. PresentInterval PresentationInterval{ PresentInterval::Default }; + //Gets or sets the depth stencil data format. DepthFormat DepthStencilFormat{ DepthFormat::None }; }; } From fe6c1fd1b7b1aebf254807a84f84f1b30a3ba4f6 Mon Sep 17 00:00:00 2001 From: Danilo Date: Mon, 5 Aug 2024 17:52:51 -0300 Subject: [PATCH 6/6] =?UTF-8?q?Coment=C3=A1rios=20em=20VertexPosition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/xna/graphics/vertexposition.hpp | 54 ++++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/inc/xna/graphics/vertexposition.hpp b/inc/xna/graphics/vertexposition.hpp index f8ef31f..e3048f9 100644 --- a/inc/xna/graphics/vertexposition.hpp +++ b/inc/xna/graphics/vertexposition.hpp @@ -6,70 +6,74 @@ #include "../default.hpp" namespace xna { + //Describes a custom vertex format structure that contains position and color information. struct VertexPositionColor { - Vector3 position{}; - Color color{}; + Vector3 Position{}; + xna::Color Color{}; constexpr VertexPositionColor() = default; - constexpr VertexPositionColor(Vector3 const& position, Color const& color): - position(position), color(color){} + constexpr VertexPositionColor(Vector3 const& position, xna::Color const& color): + Position(position), Color(color){} constexpr bool operator==(const VertexPositionColor& other) const { - return position == other.position && color == other.color; + return Position == other.Position && Color == other.Color; } }; + //Describes a custom vertex format structure that contains position and one set of texture coordinates. struct VertexPositionTexture { - Vector3 position{}; - Vector2 textureCoordinate{}; + Vector3 Position{}; + Vector2 TextureCoordinate{}; constexpr VertexPositionTexture() = default; constexpr bool operator==(const VertexPositionTexture& other) const { - return position == other.position - && textureCoordinate == other.textureCoordinate; + return Position == other.Position + && TextureCoordinate == other.TextureCoordinate; } constexpr VertexPositionTexture(const Vector3& position, const Vector2& textureCoordinate) - : position(position), textureCoordinate(textureCoordinate) + : Position(position), TextureCoordinate(textureCoordinate) { } }; + //Describes a custom vertex format structure that contains position, color, and one set of texture coordinates. struct VertexPositionColorTexture { - Vector3 position{}; - Vector2 textureCoodinate{}; - Color color{}; + Vector3 Position{}; + Vector2 TextureCoodinate{}; + xna::Color Color{}; constexpr VertexPositionColorTexture() = default; constexpr bool operator==(const VertexPositionColorTexture& other) const { - return position == other.position - && textureCoodinate == other.textureCoodinate - && color == other.color; + return Position == other.Position + && TextureCoodinate == other.TextureCoodinate + && Color == other.Color; } - constexpr VertexPositionColorTexture(const Vector3& position, const Vector2& textureCoodinate, const Color& color) - : position(position), textureCoodinate(textureCoodinate), color(color) + constexpr VertexPositionColorTexture(const Vector3& position, const Vector2& textureCoodinate, const xna::Color& color) + : Position(position), TextureCoodinate(textureCoodinate), Color(color) { } }; + //Describes a custom vertex format structure that contains position, normal data, and one set of texture coordinates. struct VertexPositionNormalTexture { - Vector3 position{}; - Vector3 normal{}; - Vector2 textureCoodinate{}; + Vector3 Position{}; + Vector3 Normal{}; + Vector2 TextureCoodinate{}; constexpr VertexPositionNormalTexture() = default; bool operator==(const VertexPositionNormalTexture& other) const { - return position == other.position - && normal == other.normal - && textureCoodinate == other.textureCoodinate; + return Position == other.Position + && Normal == other.Normal + && TextureCoodinate == other.TextureCoodinate; } constexpr VertexPositionNormalTexture(const Vector3& position, const Vector3& normal, const Vector2& textureCoodinate) - : position(position), normal(normal), textureCoodinate(textureCoodinate) + : Position(position), Normal(normal), TextureCoodinate(textureCoodinate) { } };