mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige VertexInputLayout
This commit is contained in:
parent
110e56aacb
commit
2addc59a42
@ -16,7 +16,7 @@ add_executable (xna WIN32
|
|||||||
|
|
||||||
"csharp/stream.cpp"
|
"csharp/stream.cpp"
|
||||||
"platform/gdevicemanager-dx.cpp"
|
"platform/gdevicemanager-dx.cpp"
|
||||||
"platform/vertexinput-dx.cpp"
|
|
||||||
"platform/shader-dx.cpp"
|
"platform/shader-dx.cpp"
|
||||||
"platform/rasterizerstate-dx.cpp"
|
"platform/rasterizerstate-dx.cpp"
|
||||||
|
|
||||||
|
@ -121,4 +121,42 @@ namespace xna {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VertexInputLayout::VertexInputLayout() : GraphicsResource(nullptr) {
|
||||||
|
impl = uNew<PlatformImplementation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexInputLayout::VertexInputLayout(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
|
impl = uNew<PlatformImplementation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
VertexInputLayout::~VertexInputLayout() {
|
||||||
|
impl = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VertexInputLayout::Initialize(DataBuffer& blob, xna_error_ptr_arg) {
|
||||||
|
if (!impl || !m_device || !m_device->_device || !blob.impl->_blob) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (impl->_inputLayout) {
|
||||||
|
impl->_inputLayout->Release();
|
||||||
|
impl->_inputLayout = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto hr = m_device->_device->CreateInputLayout(
|
||||||
|
impl->_description.data(),
|
||||||
|
static_cast<UINT>(impl->_description.size()),
|
||||||
|
blob.impl->_blob->GetBufferPointer(),
|
||||||
|
blob.impl->_blob->GetBufferSize(),
|
||||||
|
&impl->_inputLayout);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,32 +0,0 @@
|
|||||||
#include "platform-dx/vertexinput-dx.hpp"
|
|
||||||
#include "platform-dx/device-dx.hpp"
|
|
||||||
#include "platform-dx/dxheaders.hpp"
|
|
||||||
#include "platform-dx/implementations.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
bool VertexInputLayout::Initialize(GraphicsDevice& device, DataBuffer& blob, xna_error_ptr_arg){
|
|
||||||
if (!device._device || !blob.impl->_blob) {
|
|
||||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_inputLayout) {
|
|
||||||
_inputLayout->Release();
|
|
||||||
_inputLayout = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto hr = device._device->CreateInputLayout(
|
|
||||||
_description.data(),
|
|
||||||
static_cast<UINT>(_description.size()),
|
|
||||||
blob.impl->_blob->GetBufferPointer(),
|
|
||||||
blob.impl->_blob->GetBufferSize(),
|
|
||||||
&_inputLayout);
|
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -285,7 +285,7 @@ namespace xna {
|
|||||||
if (num < 0.0)
|
if (num < 0.0)
|
||||||
--num;
|
--num;
|
||||||
|
|
||||||
return static_cast<Int>(num);
|
return static_cast<float>(static_cast<Int>(num));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr float FindSegment(float t, CurveKey& k0, CurveKey& k1) {
|
constexpr float FindSegment(float t, CurveKey& k0, CurveKey& k1) {
|
||||||
|
@ -57,6 +57,19 @@ namespace xna {
|
|||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
uptr<PlatformImplementation> impl = nullptr;
|
uptr<PlatformImplementation> impl = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VertexInputLayout : public GraphicsResource {
|
||||||
|
public:
|
||||||
|
VertexInputLayout();
|
||||||
|
VertexInputLayout(sptr<GraphicsDevice> const&);
|
||||||
|
~VertexInputLayout();
|
||||||
|
|
||||||
|
bool Initialize(DataBuffer& blob, xna_error_nullarg);
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct PlatformImplementation;
|
||||||
|
uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,14 +0,0 @@
|
|||||||
#ifndef XNA_GRAPHICS_VERTEXINPUT_HPP
|
|
||||||
#define XNA_GRAPHICS_VERTEXINPUT_HPP
|
|
||||||
|
|
||||||
#include "../default.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
class IVertexInputLayout {
|
|
||||||
public:
|
|
||||||
virtual ~IVertexInputLayout(){}
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& blob, xna_error_nullarg) = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -86,7 +86,7 @@ namespace xna {
|
|||||||
D3D11_BUFFER_DESC _description{};
|
D3D11_BUFFER_DESC _description{};
|
||||||
D3D11_SUBRESOURCE_DATA _subResource{};
|
D3D11_SUBRESOURCE_DATA _subResource{};
|
||||||
ID3D11Buffer* _buffer = nullptr;
|
ID3D11Buffer* _buffer = nullptr;
|
||||||
DirectX::XMMATRIX _worldViewProjection;
|
DirectX::XMMATRIX _worldViewProjection{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DataBuffer::PlatformImplementation {
|
struct DataBuffer::PlatformImplementation {
|
||||||
@ -333,6 +333,18 @@ namespace xna {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct VertexInputLayout::PlatformImplementation {
|
||||||
|
~PlatformImplementation() {
|
||||||
|
if (_inputLayout) {
|
||||||
|
_inputLayout->Release();
|
||||||
|
_inputLayout = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11InputLayout* _inputLayout{ nullptr };
|
||||||
|
std::vector<D3D11_INPUT_ELEMENT_DESC> _description{};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,32 +0,0 @@
|
|||||||
#ifndef XNA_PLATFORM_VERTEXINPUT_DX_HPP
|
|
||||||
#define XNA_PLATFORM_VERTEXINPUT_DX_HPP
|
|
||||||
|
|
||||||
#include "../graphics/vertexinput.hpp"
|
|
||||||
#include "dxgi.h"
|
|
||||||
#include "d3d11.h"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
class VertexInputLayout : public IVertexInputLayout {
|
|
||||||
public:
|
|
||||||
VertexInputLayout() = default;
|
|
||||||
|
|
||||||
VertexInputLayout(
|
|
||||||
std::vector<D3D11_INPUT_ELEMENT_DESC> const& description) :
|
|
||||||
_description(description){}
|
|
||||||
|
|
||||||
virtual ~VertexInputLayout() override{
|
|
||||||
if (_inputLayout) {
|
|
||||||
_inputLayout->Release();
|
|
||||||
_inputLayout = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& blob, xna_error_nullarg);
|
|
||||||
|
|
||||||
public:
|
|
||||||
ID3D11InputLayout* _inputLayout{ nullptr };
|
|
||||||
std::vector<D3D11_INPUT_ELEMENT_DESC> _description{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -8,6 +8,5 @@
|
|||||||
#include "gdevicemanager-dx.hpp"
|
#include "gdevicemanager-dx.hpp"
|
||||||
#include "init-dx.hpp"
|
#include "init-dx.hpp"
|
||||||
#include "soundeffect-dx.hpp"
|
#include "soundeffect-dx.hpp"
|
||||||
#include "vertexinput-dx.hpp"
|
|
||||||
#include "window-dx.hpp"
|
#include "window-dx.hpp"
|
||||||
#include "implementations.hpp"
|
#include "implementations.hpp"
|
@ -45,7 +45,6 @@
|
|||||||
#include "graphics/sprite.hpp"
|
#include "graphics/sprite.hpp"
|
||||||
#include "graphics/swapchain.hpp"
|
#include "graphics/swapchain.hpp"
|
||||||
#include "graphics/texture.hpp"
|
#include "graphics/texture.hpp"
|
||||||
#include "graphics/vertexinput.hpp"
|
|
||||||
#include "graphics/vertexposition.hpp"
|
#include "graphics/vertexposition.hpp"
|
||||||
#include "graphics/viewport.hpp"
|
#include "graphics/viewport.hpp"
|
||||||
#include "input/gamepad.hpp"
|
#include "input/gamepad.hpp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user