mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige DataBuffer
This commit is contained in:
parent
908403ac7b
commit
1ca0bf2ffb
@ -22,7 +22,7 @@ add_executable (xna WIN32
|
||||
"platform/vertexbuffer-dx.cpp"
|
||||
"platform/indexbuffer-dx.cpp"
|
||||
|
||||
"platform/databuffer-dx.cpp"
|
||||
|
||||
"platform/samplerstate-dx.cpp"
|
||||
"platform/sprite-dx.cpp"
|
||||
|
||||
|
@ -5,8 +5,13 @@
|
||||
#include "platform-dx/implementations.hpp"
|
||||
|
||||
namespace xna {
|
||||
ConstantBuffer::ConstantBuffer() : GraphicsResource(nullptr){}
|
||||
ConstantBuffer::ConstantBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device){}
|
||||
ConstantBuffer::ConstantBuffer() : GraphicsResource(nullptr){
|
||||
impl = uNew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
ConstantBuffer::ConstantBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device){
|
||||
impl = uNew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
ConstantBuffer::~ConstantBuffer() {
|
||||
impl = nullptr;
|
||||
@ -36,4 +41,30 @@ namespace xna {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DataBuffer::DataBuffer() : GraphicsResource(nullptr) {
|
||||
impl = uNew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
DataBuffer::DataBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||
impl = uNew<PlatformImplementation>();
|
||||
}
|
||||
|
||||
DataBuffer::~DataBuffer() {
|
||||
impl = nullptr;
|
||||
}
|
||||
|
||||
bool DataBuffer::Initialize(xna_error_ptr_arg) {
|
||||
if (!m_device || !m_device->_device) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (impl->_blob) {
|
||||
impl->_blob->Release();
|
||||
impl->_blob = nullptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#include "platform-dx/databuffer-dx.hpp"
|
||||
|
||||
namespace xna {
|
||||
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#include "platform-dx/shader-dx.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "platform-dx/databuffer-dx.hpp"
|
||||
#include "graphics/buffer.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
|
||||
namespace xna {
|
||||
HRESULT Shader::CompileFromFile(_In_ LPCWSTR srcFile, _In_ LPCSTR entryPoint, _In_ LPCSTR profile, _Outptr_ ID3DBlob** blob)
|
||||
@ -49,7 +50,7 @@ namespace xna {
|
||||
|
||||
bool VertexShader::Initialize(DataBuffer& buffer, xna_error_ptr_arg)
|
||||
{
|
||||
if (!m_device || !m_device->_device || !buffer._blob) {
|
||||
if (!m_device || !m_device->_device || !buffer.impl->_blob) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
@ -60,8 +61,8 @@ namespace xna {
|
||||
}
|
||||
|
||||
const auto hr = m_device->_device->CreateVertexShader(
|
||||
buffer._blob->GetBufferPointer(),
|
||||
buffer._blob->GetBufferSize(),
|
||||
buffer.impl->_blob->GetBufferPointer(),
|
||||
buffer.impl->_blob->GetBufferSize(),
|
||||
NULL,
|
||||
&_vertexShader);
|
||||
|
||||
@ -75,7 +76,7 @@ namespace xna {
|
||||
|
||||
bool PixelShader::Initialize(DataBuffer& buffer, xna_error_ptr_arg)
|
||||
{
|
||||
if (!m_device || !m_device->_device || !buffer._blob) {
|
||||
if (!m_device || !m_device->_device || !buffer.impl->_blob) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
@ -86,8 +87,8 @@ namespace xna {
|
||||
}
|
||||
|
||||
const auto hr = m_device->_device->CreatePixelShader(
|
||||
buffer._blob->GetBufferPointer(),
|
||||
buffer._blob->GetBufferSize(),
|
||||
buffer.impl->_blob->GetBufferPointer(),
|
||||
buffer.impl->_blob->GetBufferSize(),
|
||||
NULL,
|
||||
&_pixelShader);
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "platform-dx/vertexinput-dx.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "platform-dx/dxheaders.hpp"
|
||||
#include "platform-dx/databuffer-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
|
||||
namespace xna {
|
||||
bool VertexInputLayout::Initialize(GraphicsDevice& device, DataBuffer& blob, xna_error_ptr_arg){
|
||||
if (!device._device || !blob._blob) {
|
||||
if (!device._device || !blob.impl->_blob) {
|
||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||
return false;
|
||||
}
|
||||
@ -18,8 +18,8 @@ namespace xna {
|
||||
const auto hr = device._device->CreateInputLayout(
|
||||
_description.data(),
|
||||
static_cast<UINT>(_description.size()),
|
||||
blob._blob->GetBufferPointer(),
|
||||
blob._blob->GetBufferSize(),
|
||||
blob.impl->_blob->GetBufferPointer(),
|
||||
blob.impl->_blob->GetBufferSize(),
|
||||
&_inputLayout);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
|
@ -44,7 +44,10 @@ namespace xna {
|
||||
graphicsDevice->Clear(Colors::CornflowerBlue);
|
||||
|
||||
spriteBatch->Begin();
|
||||
spriteBatch->Draw(*texture, Vector2(), Colors::White);
|
||||
|
||||
if(texture)
|
||||
spriteBatch->Draw(*texture, Vector2(), Colors::White);
|
||||
|
||||
spriteBatch->End();
|
||||
|
||||
Game::Draw(gameTime);
|
||||
|
@ -16,6 +16,18 @@ namespace xna {
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
|
||||
class DataBuffer : public GraphicsResource {
|
||||
public:
|
||||
DataBuffer();
|
||||
DataBuffer(sptr<GraphicsDevice> const&);
|
||||
~DataBuffer();
|
||||
bool Initialize(xna_error_nullarg);
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
#ifndef XNA_GRAPHICS_DATABUFFER_HPP
|
||||
#define XNA_GRAPHICS_DATABUFFER_HPP
|
||||
|
||||
#include "../default.hpp"
|
||||
|
||||
namespace xna {
|
||||
class IDataBuffer {
|
||||
public:
|
||||
virtual ~IDataBuffer(){}
|
||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,26 +0,0 @@
|
||||
#ifndef XNA_PLATFORM_DATABUFFER_DX_HPP
|
||||
#define XNA_PLATFORM_DATABUFFER_DX_HPP
|
||||
|
||||
#include "../graphics/databuffer.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
|
||||
namespace xna {
|
||||
class DataBuffer : public IDataBuffer {
|
||||
public:
|
||||
virtual ~DataBuffer() override {
|
||||
if (_blob) {
|
||||
_blob->Release();
|
||||
_blob = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override {
|
||||
return false;
|
||||
}
|
||||
|
||||
public:
|
||||
ID3DBlob* _blob = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -233,4 +233,19 @@ namespace xna {
|
||||
ID3D11Buffer* _buffer = nullptr;
|
||||
DirectX::XMMATRIX _worldViewProjection;
|
||||
};
|
||||
|
||||
struct DataBuffer::PlatformImplementation {
|
||||
~PlatformImplementation() {
|
||||
if (_blob) {
|
||||
_blob->Release();
|
||||
_blob = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ID3DBlob* _blob = nullptr;
|
||||
|
||||
void Set(ID3DBlob*& blob) {
|
||||
_blob = blob;
|
||||
}
|
||||
};
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "../graphics/shader.hpp"
|
||||
#include "../graphics/gresource.hpp"
|
||||
#include "graphics/buffer.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
|
||||
namespace xna {
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "audioengine-dx.hpp"
|
||||
#include "databuffer-dx.hpp"
|
||||
#include "depthstencilstate-dx.hpp"
|
||||
#include "device-dx.hpp"
|
||||
#include "displaymode-dx.hpp"
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "game/window.hpp"
|
||||
#include "graphics/adapter.hpp"
|
||||
#include "graphics/blendstate.hpp"
|
||||
#include "graphics/databuffer.hpp"
|
||||
#include "graphics/depthstencilstate.hpp"
|
||||
#include "graphics/device.hpp"
|
||||
#include "graphics/displaymode.hpp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user