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

Remove classes não utilizadas

This commit is contained in:
Danilo 2024-06-25 17:12:34 -03:00
parent 49345ff7df
commit d264df5909
7 changed files with 6 additions and 469 deletions

View File

@ -29,7 +29,7 @@ add_library (Xn65 STATIC
"platform-dx/blendstate.cpp"
"platform-dx/game.cpp"
"platform-dx/gdevicemanager.cpp"
"platform-dx/shader.cpp"
"platform-dx/rasterizerstate.cpp"
"platform-dx/samplerstate.cpp"
"platform-dx/sprite.cpp"
@ -40,7 +40,7 @@ add_library (Xn65 STATIC
"platform-dx/soundeffect.cpp"
"platform-dx/displaymode.cpp"
"platform-dx/init.cpp"
"platform-dx/buffer.cpp"
"platform-dx/audioengine.cpp" "graphics/gresource.cpp" "platform-dx/effect.cpp" "platform-dx/impl.cpp")
if (CMAKE_VERSION VERSION_GREATER 3.12)

View File

@ -1,149 +0,0 @@
#include "xna/graphics/buffer.hpp"
#include "xna/common/numerics.hpp"
#include "xna/platform-dx/dx.hpp"
namespace xna {
ConstantBuffer::ConstantBuffer() : GraphicsResource(nullptr){
impl = unew<PlatformImplementation>();
}
ConstantBuffer::ConstantBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device){
impl = unew<PlatformImplementation>();
}
ConstantBuffer::~ConstantBuffer() {
impl = nullptr;
}
bool ConstantBuffer::Initialize()
{
if (!m_device || !m_device->impl->_device) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->_buffer) {
impl->_buffer = nullptr;
}
const auto hr = m_device->impl->_device->CreateBuffer(
&impl->_description,
&impl->_subResource,
impl->_buffer.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
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() {
if (!m_device || !m_device->impl->_device) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->_blob) {
impl->_blob = nullptr;
}
return true;
}
IndexBuffer::IndexBuffer() : GraphicsResource(nullptr) {
impl = unew<PlatformImplementation>();
}
IndexBuffer::IndexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
impl = unew<PlatformImplementation>();
}
IndexBuffer::~IndexBuffer() {
impl = nullptr;
}
bool IndexBuffer::Apply() {
if (!m_device || !m_device->impl->_context || !impl || !impl->dxBuffer) {
Exception::Throw(ExMessage::ApplyComponent);
}
m_device->impl->_context->IASetIndexBuffer(impl->dxBuffer.Get(), DXGI_FORMAT_R16_UINT, 0);
return true;
}
VertexBuffer::VertexBuffer() : GraphicsResource(nullptr) {
impl = unew<PlatformImplementation>();
}
VertexBuffer::VertexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
impl = unew<PlatformImplementation>();
}
VertexBuffer::~VertexBuffer() {
impl = nullptr;
}
bool VertexBuffer::Apply() {
if (!impl || !m_device || !m_device->impl->_context) {
Exception::Throw(ExMessage::ApplyComponent);
}
if (!impl->dxBuffer) {
Exception::Throw(ExMessage::UnintializedComponent);
}
UINT stride = impl->size;
UINT offset = 0;
m_device->impl->_context->IASetVertexBuffers(0, 1,
impl->dxBuffer.GetAddressOf(), &stride, &offset);
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) {
if (!impl || !m_device || !m_device->impl->_device || !blob.impl->_blob) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->_inputLayout) {
impl->_inputLayout = nullptr;
}
const auto hr = m_device->impl->_device->CreateInputLayout(
impl->_description.data(),
static_cast<UINT>(impl->_description.size()),
blob.impl->_blob->GetBufferPointer(),
blob.impl->_blob->GetBufferSize(),
impl->_inputLayout.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
return true;
}
}

View File

@ -1,109 +0,0 @@
#include "xna/graphics/buffer.hpp"
#include "xna/platform-dx/dx.hpp"
#include "xna/graphics/shader.hpp"
namespace xna {
static HRESULT shaderCompileFromFile(_In_ LPCWSTR srcFile, _In_ LPCSTR entryPoint, _In_ LPCSTR profile, _Outptr_ ID3DBlob** blob)
{
//https://learn.microsoft.com/en-us/windows/win32/direct3d11/how-to--compile-a-shader
if (!srcFile || !entryPoint || !profile || !blob)
return E_INVALIDARG;
*blob = nullptr;
UINT flags = D3DCOMPILE_ENABLE_STRICTNESS;
#if defined( DEBUG ) || defined( _DEBUG )
flags |= D3DCOMPILE_DEBUG;
#endif
const D3D_SHADER_MACRO defines[] =
{
"EXAMPLE_DEFINE", "1",
NULL, NULL
};
ID3DBlob* shaderBlob = nullptr;
ID3DBlob* errorBlob = nullptr;
HRESULT hr = D3DCompileFromFile(srcFile, defines, D3D_COMPILE_STANDARD_FILE_INCLUDE,
entryPoint, profile,
flags, 0, &shaderBlob, &errorBlob);
if (FAILED(hr))
{
if (errorBlob)
{
OutputDebugStringA((char*)errorBlob->GetBufferPointer());
errorBlob->Release();
}
if (shaderBlob)
shaderBlob->Release();
return hr;
}
*blob = shaderBlob;
return hr;
}
bool Shader::CompileFromFile(WString srcFile, String entryPoint, String profile, DataBuffer& blob) {
const auto hr = shaderCompileFromFile(srcFile.c_str(), entryPoint.c_str(), profile.c_str(), &blob.impl->_blob);
return SUCCEEDED(hr);
}
VertexShader::~VertexShader() {
impl = nullptr;
}
PixelShader::~PixelShader() {
impl = nullptr;
}
bool VertexShader::Initialize(DataBuffer& buffer)
{
if (!impl || !m_device || !m_device->impl->_device || !buffer.impl->_blob) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->_vertexShader) {
impl->_vertexShader.ReleaseAndGetAddressOf();
}
const auto hr = m_device->impl->_device->CreateVertexShader(
buffer.impl->_blob->GetBufferPointer(),
buffer.impl->_blob->GetBufferSize(),
NULL,
impl->_vertexShader.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
return true;
}
bool PixelShader::Initialize(DataBuffer& buffer)
{
if (!impl || !m_device || !m_device->impl->_device || !buffer.impl->_blob) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->_pixelShader) {
impl->_pixelShader.ReleaseAndGetAddressOf();
}
const auto hr = m_device->impl->_device->CreatePixelShader(
buffer.impl->_blob->GetBufferPointer(),
buffer.impl->_blob->GetBufferSize(),
NULL,
impl->_pixelShader.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
return true;
}
}

View File

@ -1,75 +0,0 @@
#ifndef XNA_GRAPHICS_BUFFER_HPP
#define XNA_GRAPHICS_BUFFER_HPP
#include "../default.hpp"
#include "gresource.hpp"
namespace xna {
class ConstantBuffer : public GraphicsResource {
public:
ConstantBuffer();
ConstantBuffer(sptr<GraphicsDevice> const&);
~ConstantBuffer() override;
bool Initialize();
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
class DataBuffer : public GraphicsResource {
public:
DataBuffer();
DataBuffer(sptr<GraphicsDevice> const&);
~DataBuffer() override;
bool Initialize();
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
class IndexBuffer : public GraphicsResource {
public:
IndexBuffer();
IndexBuffer(sptr<GraphicsDevice> const&);
~IndexBuffer() override;
template <typename T>
bool Initialize(std::vector<T> const& data);
bool Apply();
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
class VertexBuffer : public GraphicsResource {
public:
VertexBuffer();
VertexBuffer(sptr<GraphicsDevice> const&);
~VertexBuffer();
template <typename T>
bool Initialize(std::vector<T> const& data);
bool Apply();
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
class VertexInputLayout : public GraphicsResource {
public:
VertexInputLayout();
VertexInputLayout(sptr<GraphicsDevice> const&);
~VertexInputLayout();
bool Initialize(DataBuffer& blob);
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
}
#endif

View File

@ -1,42 +0,0 @@
#ifndef XNA_GRAPHICS_SHADER_HPP
#define XNA_GRAPHICS_SHADER_HPP
#include "../default.hpp"
#include "gresource.hpp"
namespace xna {
class Shader : public GraphicsResource {
public:
Shader();
Shader(sptr<GraphicsDevice> const& device);
~Shader() override {}
bool Initialize(DataBuffer& buffer);
static bool CompileFromFile(WString srcFile, String entryPoint, String profile, DataBuffer& blob);
};
class VertexShader : public Shader {
public:
VertexShader();
VertexShader(sptr<GraphicsDevice> const& device);
~VertexShader() override;
bool Initialize(DataBuffer& buffer);
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
class PixelShader : public Shader {
public:
PixelShader();
PixelShader(sptr<GraphicsDevice> const& device);
~PixelShader() override;
bool Initialize(DataBuffer& buffer);
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
};
}
#endif

View File

@ -66,7 +66,6 @@ using comptr = Microsoft::WRL::ComPtr<T>;
#include "../graphics/device.hpp"
#include "../graphics/adapter.hpp"
#include "../graphics/blendstate.hpp"
#include "../graphics/buffer.hpp"
#include "../graphics/depthstencilstate.hpp"
#include "../graphics/displaymode.hpp"
#include "../graphics/sprite.hpp"
@ -77,7 +76,6 @@ using comptr = Microsoft::WRL::ComPtr<T>;
#include "../input/mouse.hpp"
#include "../graphics/rasterizerstate.hpp"
#include "../graphics/presentparams.hpp"
#include "../graphics/shader.hpp"
#include "../graphics/swapchain.hpp"
#include "../graphics/texture.hpp"
#include "../graphics/rendertarget.hpp"
@ -541,22 +539,7 @@ namespace xna {
D3D11_BLEND_DESC dxDescription{};
float blendFactor[4]{ 1.0F, 1.0F, 1.0F, 1.0F };
UINT sampleMask{ 0xffffffff };
};
struct ConstantBuffer::PlatformImplementation {
D3D11_BUFFER_DESC _description{};
D3D11_SUBRESOURCE_DATA _subResource{};
comptr<ID3D11Buffer> _buffer = nullptr;
DirectX::XMMATRIX _worldViewProjection{};
};
struct DataBuffer::PlatformImplementation {
comptr<ID3DBlob> _blob = nullptr;
void Set(comptr<ID3DBlob> const& blob) {
_blob = blob;
}
};
};
struct DepthStencilState::PlatformImplementation {
comptr<ID3D11DepthStencilState> dxDepthStencil = nullptr;
@ -611,10 +594,6 @@ namespace xna {
}
};
struct IndexBuffer::PlatformImplementation {
comptr<ID3D11Buffer> dxBuffer = nullptr;
};
struct Keyboard::PlatformImplementation {
uptr<DirectX::Keyboard> _dxKeyboard = unew<DirectX::Keyboard>();
@ -641,15 +620,7 @@ namespace xna {
struct SamplerState::PlatformImplementation {
comptr<ID3D11SamplerState> _samplerState = nullptr;
D3D11_SAMPLER_DESC _description{};
};
struct VertexShader::PlatformImplementation {
comptr<ID3D11VertexShader> _vertexShader = nullptr;
};
struct PixelShader::PlatformImplementation {
comptr<ID3D11PixelShader> _pixelShader = nullptr;
};
};
struct SwapChain::PlatformImplementation {
comptr<IDXGISwapChain1> dxSwapChain{ nullptr };
@ -677,17 +648,7 @@ namespace xna {
struct RenderTarget2D::PlatformImplementation {
comptr<ID3D11RenderTargetView> _renderTargetView = nullptr;
D3D11_RENDER_TARGET_VIEW_DESC _renderTargetDesc{};
};
struct VertexBuffer::PlatformImplementation {
comptr<ID3D11Buffer> dxBuffer = nullptr;
UINT size{ 0 };
};
struct VertexInputLayout::PlatformImplementation {
comptr<ID3D11InputLayout> _inputLayout{ nullptr };
std::vector<D3D11_INPUT_ELEMENT_DESC> _description{};
};
};
enum class GameWindowMode : UINT {
Fullscreen = WS_POPUP | WS_VISIBLE,
@ -887,54 +848,6 @@ namespace xna {
struct EffectParameter::PlatformImplementation {
comptr<ID3DX11EffectVariable> dxVariable = nullptr;
};
template <typename T>
inline bool IndexBuffer::Initialize(std::vector<T> const& data) {
if (!impl || !m_device || !m_device->impl->_device || data.empty()) {
Exception::Throw(ExMessage::InitializeComponent);
}
if (impl->dxBuffer) {
impl->dxBuffer = nullptr;
}
const auto hr = DirectX::CreateStaticBuffer(
m_device->impl->_device.Get(),
data.data(),
data.size(),
sizeof(T),
D3D11_BIND_INDEX_BUFFER,
impl->dxBuffer.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
return true;
}
template <typename T>
inline bool VertexBuffer::Initialize(std::vector<T> const& data) {
if (!impl || !m_device || !m_device->impl->_device || data.empty()) {
Exception::Throw(ExMessage::InitializeComponent);
}
const auto hr = DirectX::CreateStaticBuffer(
m_device->impl->_device.Get(),
data.data(),
data.size(),
sizeof(T),
D3D11_BIND_VERTEX_BUFFER,
impl->dxBuffer.GetAddressOf());
if (FAILED(hr)) {
Exception::Throw(ExMessage::CreateComponent);
}
impl->size = sizeof(T);
return true;
}
};
}
#endif

View File

@ -43,7 +43,6 @@
#include "graphics/rasterizerstate.hpp"
#include "graphics/rendertarget.hpp"
#include "graphics/samplerstate.hpp"
#include "graphics/shader.hpp"
#include "graphics/sprite.hpp"
#include "graphics/swapchain.hpp"
#include "graphics/texture.hpp"