mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa comentários e remove New e uNew
This commit is contained in:
parent
663777a713
commit
2b3f686d19
@ -3,7 +3,7 @@
|
|||||||
namespace xna {
|
namespace xna {
|
||||||
sptr<Stream> ContentManager::OpenStream(String const& assetName) const {
|
sptr<Stream> ContentManager::OpenStream(String const& assetName) const {
|
||||||
const String filePath = _rootDirectory + "\\" + assetName + contentExtension;
|
const String filePath = _rootDirectory + "\\" + assetName + contentExtension;
|
||||||
const auto stream = New<FileStream>(filePath, FileMode::Open);
|
const auto stream = snew<FileStream>(filePath, FileMode::Open);
|
||||||
|
|
||||||
if (stream->IsClosed())
|
if (stream->IsClosed())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -157,7 +157,7 @@ namespace xna {
|
|||||||
void ContentTypeReaderManager::initMaps()
|
void ContentTypeReaderManager::initMaps()
|
||||||
{
|
{
|
||||||
if (targetTypeToReader.empty() && readerTypeToReader.empty()) {
|
if (targetTypeToReader.empty() && readerTypeToReader.empty()) {
|
||||||
auto typeReader = New<ObjectReader>();
|
auto typeReader = snew<ObjectReader>();
|
||||||
auto contentTypeReader = reinterpret_pointer_cast<ContentTypeReader>(typeReader);
|
auto contentTypeReader = reinterpret_pointer_cast<ContentTypeReader>(typeReader);
|
||||||
|
|
||||||
targetTypeToReader.insert({ typeof<Object>(), contentTypeReader});
|
targetTypeToReader.insert({ typeof<Object>(), contentTypeReader});
|
||||||
|
@ -8,7 +8,7 @@ namespace xna {
|
|||||||
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source);
|
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source);
|
||||||
|
|
||||||
GraphicsAdapter::GraphicsAdapter() {
|
GraphicsAdapter::GraphicsAdapter() {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsAdapter::~GraphicsAdapter() {
|
GraphicsAdapter::~GraphicsAdapter() {
|
||||||
@ -24,7 +24,7 @@ namespace xna {
|
|||||||
IDXGIAdapter1* pAdapter = nullptr;
|
IDXGIAdapter1* pAdapter = nullptr;
|
||||||
|
|
||||||
if (pFactory->EnumAdapters1(0, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
|
if (pFactory->EnumAdapters1(0, &pAdapter) != DXGI_ERROR_NOT_FOUND) {
|
||||||
auto adp = uNew<GraphicsAdapter>();
|
auto adp = unew<GraphicsAdapter>();
|
||||||
|
|
||||||
adp->impl->_index = 0;
|
adp->impl->_index = 0;
|
||||||
adp->impl->dxadapter = pAdapter;
|
adp->impl->dxadapter = pAdapter;
|
||||||
@ -48,7 +48,7 @@ namespace xna {
|
|||||||
UINT count = 0;
|
UINT count = 0;
|
||||||
|
|
||||||
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
|
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
|
||||||
auto adp = New<GraphicsAdapter>();
|
auto adp = snew<GraphicsAdapter>();
|
||||||
|
|
||||||
adp->impl->_index = count;
|
adp->impl->_index = count;
|
||||||
adp->impl->dxadapter = pAdapter;
|
adp->impl->dxadapter = pAdapter;
|
||||||
@ -70,7 +70,7 @@ namespace xna {
|
|||||||
UINT count = 0;
|
UINT count = 0;
|
||||||
|
|
||||||
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
|
for (; pFactory->EnumAdapters1(count, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++count) {
|
||||||
auto adp = uNew<GraphicsAdapter>();
|
auto adp = unew<GraphicsAdapter>();
|
||||||
|
|
||||||
adp->impl->_index = count;
|
adp->impl->_index = count;
|
||||||
adp->impl->dxadapter = pAdapter;
|
adp->impl->dxadapter = pAdapter;
|
||||||
@ -218,7 +218,7 @@ namespace xna {
|
|||||||
pOutput->GetDisplayModeList(format, 0, &numModes, nullptr);
|
pOutput->GetDisplayModeList(format, 0, &numModes, nullptr);
|
||||||
|
|
||||||
if (numModes == 0)
|
if (numModes == 0)
|
||||||
return uNew<DisplayModeCollection>();
|
return unew<DisplayModeCollection>();
|
||||||
|
|
||||||
std::vector<DXGI_MODE_DESC> buffer(numModes);
|
std::vector<DXGI_MODE_DESC> buffer(numModes);
|
||||||
pOutput->GetDisplayModeList(format, 0, &numModes, buffer.data());
|
pOutput->GetDisplayModeList(format, 0, &numModes, buffer.data());
|
||||||
@ -229,7 +229,7 @@ namespace xna {
|
|||||||
return createDisplayModeCollection(buffer);
|
return createDisplayModeCollection(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return uNew<DisplayModeCollection>();
|
return unew<DisplayModeCollection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr<DisplayMode> GraphicsAdapter::CurrentDisplayMode() {
|
sptr<DisplayMode> GraphicsAdapter::CurrentDisplayMode() {
|
||||||
@ -289,7 +289,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source) {
|
static uptr<DisplayModeCollection> createDisplayModeCollection(std::vector<DXGI_MODE_DESC> const& source) {
|
||||||
auto collection = uNew<DisplayModeCollection>();
|
auto collection = unew<DisplayModeCollection>();
|
||||||
DisplayMode currentDisplayMode;
|
DisplayMode currentDisplayMode;
|
||||||
std::vector<sptr<DisplayMode>> displayList;
|
std::vector<sptr<DisplayMode>> displayList;
|
||||||
sptr<DisplayMode> pDisplay = nullptr;
|
sptr<DisplayMode> pDisplay = nullptr;
|
||||||
@ -306,7 +306,7 @@ namespace xna {
|
|||||||
pDisplay->impl->Descriptions.push_back(description);
|
pDisplay->impl->Descriptions.push_back(description);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pDisplay = New<DisplayMode>();
|
pDisplay = snew<DisplayMode>();
|
||||||
pDisplay->Width = modedesc.Width;
|
pDisplay->Width = modedesc.Width;
|
||||||
pDisplay->Height = modedesc.Height;
|
pDisplay->Height = modedesc.Height;
|
||||||
pDisplay->Format = DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format);
|
pDisplay->Format = DxHelpers::ConvertDXGIFORMATToSurface(modedesc.Format);
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
BlendState::BlendState() : GraphicsResource(nullptr) {
|
BlendState::BlendState() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendState::BlendState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
BlendState::BlendState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
BlendState::~BlendState() {
|
BlendState::~BlendState() {
|
||||||
@ -76,7 +76,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uptr<BlendState> BlendState::Opaque() {
|
uptr<BlendState> BlendState::Opaque() {
|
||||||
auto blendState = uNew<BlendState>();
|
auto blendState = unew<BlendState>();
|
||||||
blendState->impl->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
blendState->impl->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||||
blendState->impl->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
blendState->impl->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendState->impl->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
blendState->impl->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
ConstantBuffer::ConstantBuffer() : GraphicsResource(nullptr){
|
ConstantBuffer::ConstantBuffer() : GraphicsResource(nullptr){
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantBuffer::ConstantBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device){
|
ConstantBuffer::ConstantBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device){
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantBuffer::~ConstantBuffer() {
|
ConstantBuffer::~ConstantBuffer() {
|
||||||
@ -39,11 +39,11 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataBuffer::DataBuffer() : GraphicsResource(nullptr) {
|
DataBuffer::DataBuffer() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBuffer::DataBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
DataBuffer::DataBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
DataBuffer::~DataBuffer() {
|
DataBuffer::~DataBuffer() {
|
||||||
@ -64,11 +64,11 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IndexBuffer::IndexBuffer() : GraphicsResource(nullptr) {
|
IndexBuffer::IndexBuffer() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexBuffer::IndexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
IndexBuffer::IndexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexBuffer::~IndexBuffer() {
|
IndexBuffer::~IndexBuffer() {
|
||||||
@ -86,11 +86,11 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VertexBuffer::VertexBuffer() : GraphicsResource(nullptr) {
|
VertexBuffer::VertexBuffer() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBuffer::VertexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
VertexBuffer::VertexBuffer(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexBuffer::~VertexBuffer() {
|
VertexBuffer::~VertexBuffer() {
|
||||||
@ -115,11 +115,11 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
VertexInputLayout::VertexInputLayout() : GraphicsResource(nullptr) {
|
VertexInputLayout::VertexInputLayout() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexInputLayout::VertexInputLayout(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
VertexInputLayout::VertexInputLayout(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
VertexInputLayout::~VertexInputLayout() {
|
VertexInputLayout::~VertexInputLayout() {
|
||||||
|
@ -26,12 +26,12 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DepthStencilState::DepthStencilState() : GraphicsResource(nullptr) {
|
DepthStencilState::DepthStencilState() : GraphicsResource(nullptr) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->dxDescription = defaultDesc();
|
impl->dxDescription = defaultDesc();
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthStencilState::DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
DepthStencilState::DepthStencilState(sptr<GraphicsDevice> const& device) : GraphicsResource(device) {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->dxDescription = defaultDesc();
|
impl->dxDescription = defaultDesc();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::None() {
|
uptr<DepthStencilState> DepthStencilState::None() {
|
||||||
auto stencil = uNew<DepthStencilState>();
|
auto stencil = unew<DepthStencilState>();
|
||||||
stencil->impl->dxDescription.DepthEnable = false;
|
stencil->impl->dxDescription.DepthEnable = false;
|
||||||
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::Default() {
|
uptr<DepthStencilState> DepthStencilState::Default() {
|
||||||
auto stencil = uNew<DepthStencilState>();
|
auto stencil = unew<DepthStencilState>();
|
||||||
stencil->impl->dxDescription.DepthEnable = true;
|
stencil->impl->dxDescription.DepthEnable = true;
|
||||||
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uptr<DepthStencilState> DepthStencilState::DepthRead() {
|
uptr<DepthStencilState> DepthStencilState::DepthRead() {
|
||||||
auto stencil = uNew<DepthStencilState>();
|
auto stencil = unew<DepthStencilState>();
|
||||||
stencil->impl->dxDescription.DepthEnable = true;
|
stencil->impl->dxDescription.DepthEnable = true;
|
||||||
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->impl->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ namespace xna {
|
|||||||
impl->_backgroundColor[2] = GetBValue(color) / 255.0f;
|
impl->_backgroundColor[2] = GetBValue(color) / 255.0f;
|
||||||
impl->_backgroundColor[3] = 1.0f;
|
impl->_backgroundColor[3] = 1.0f;
|
||||||
|
|
||||||
impl->_swapChain = New<xna::SwapChain>(_this);
|
impl->_swapChain = snew<xna::SwapChain>(_this);
|
||||||
impl->_swapChain->Initialize();
|
impl->_swapChain->Initialize();
|
||||||
|
|
||||||
hr = impl->_factory->MakeWindowAssociation(impl->_gameWindow->impl->WindowHandle(), DXGI_MWA_NO_ALT_ENTER);
|
hr = impl->_factory->MakeWindowAssociation(impl->_gameWindow->impl->WindowHandle(), DXGI_MWA_NO_ALT_ENTER);
|
||||||
@ -122,7 +122,7 @@ namespace xna {
|
|||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Exception::Throw(ExMessage::MakeWindowAssociation);
|
Exception::Throw(ExMessage::MakeWindowAssociation);
|
||||||
|
|
||||||
impl->_renderTarget2D = New<RenderTarget2D>(_this);
|
impl->_renderTarget2D = snew<RenderTarget2D>(_this);
|
||||||
|
|
||||||
if (!impl->_renderTarget2D->Initialize())
|
if (!impl->_renderTarget2D->Initialize())
|
||||||
return false;
|
return false;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
DisplayMode::DisplayMode() {
|
DisplayMode::DisplayMode() {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayMode::~DisplayMode() {
|
DisplayMode::~DisplayMode() {
|
||||||
|
@ -9,19 +9,19 @@
|
|||||||
namespace xna {
|
namespace xna {
|
||||||
Game::Game() {
|
Game::Game() {
|
||||||
impl = unew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
services = New<GameServiceContainer>();
|
services = snew<GameServiceContainer>();
|
||||||
auto iservice = reinterpret_pointer_cast<IServiceProvider>(services);
|
auto iservice = reinterpret_pointer_cast<IServiceProvider>(services);
|
||||||
_contentManager = New<ContentManager>(services, "");
|
_contentManager = snew<ContentManager>(services, "");
|
||||||
_contentManager->_gameServices = iservice;
|
_contentManager->_gameServices = iservice;
|
||||||
|
|
||||||
_gameWindow = New<GameWindow>();
|
_gameWindow = snew<GameWindow>();
|
||||||
_gameWindow->impl->Color(146, 150, 154);
|
_gameWindow->impl->Color(146, 150, 154);
|
||||||
_gameWindow->Title("XN65");
|
_gameWindow->Title("XN65");
|
||||||
_gameWindow->impl->Size(
|
_gameWindow->impl->Size(
|
||||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||||
GraphicsDeviceManager::DefaultBackBufferHeight, false);
|
GraphicsDeviceManager::DefaultBackBufferHeight, false);
|
||||||
|
|
||||||
_gameComponents = New<GameComponentCollection>();
|
_gameComponents = snew<GameComponentCollection>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game() {
|
Game::~Game() {
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
void GamePad::Initialize() {
|
void GamePad::Initialize() {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxGamePad = uNew<DirectX::GamePad>();
|
impl->_dxGamePad = unew<DirectX::GamePad>();
|
||||||
}
|
}
|
||||||
|
|
||||||
GamePadState GamePad::GetState(PlayerIndex index) {
|
GamePadState GamePad::GetState(PlayerIndex index) {
|
||||||
|
@ -84,7 +84,7 @@ namespace xna {
|
|||||||
|
|
||||||
bool initDevice(GraphicsDeviceInformation& info, Game& game, sptr<GraphicsDevice>& device)
|
bool initDevice(GraphicsDeviceInformation& info, Game& game, sptr<GraphicsDevice>& device)
|
||||||
{
|
{
|
||||||
device = New<GraphicsDevice>(info);
|
device = snew<GraphicsDevice>(info);
|
||||||
|
|
||||||
if (!device->Initialize()) {
|
if (!device->Initialize()) {
|
||||||
MessageBox(info.Window->impl->WindowHandle(), "Falha na inicialização do dispositivo gráfico", "XN65", MB_OK);
|
MessageBox(info.Window->impl->WindowHandle(), "Falha na inicialização do dispositivo gráfico", "XN65", MB_OK);
|
||||||
|
@ -14,8 +14,8 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Keyboard::Initialize() {
|
void Keyboard::Initialize() {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxKeyboard = uNew<DirectX::Keyboard>();
|
impl->_dxKeyboard = unew<DirectX::Keyboard>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Keyboard::IsConnected() {
|
bool Keyboard::IsConnected() {
|
||||||
|
@ -49,7 +49,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mouse::Initialize() {
|
void Mouse::Initialize() {
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxMouse = uNew<DirectX::Mouse>();
|
impl->_dxMouse = unew<DirectX::Mouse>();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ namespace xna {
|
|||||||
|
|
||||||
uptr<RasterizerState> RasterizerState::CullNone()
|
uptr<RasterizerState> RasterizerState::CullNone()
|
||||||
{
|
{
|
||||||
auto raster = uNew<RasterizerState>();
|
auto raster = unew<RasterizerState>();
|
||||||
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_NONE;
|
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_NONE;
|
||||||
raster->impl->dxDescription.DepthClipEnable = true;
|
raster->impl->dxDescription.DepthClipEnable = true;
|
||||||
@ -63,7 +63,7 @@ namespace xna {
|
|||||||
|
|
||||||
uptr<RasterizerState> RasterizerState::CullClockwise()
|
uptr<RasterizerState> RasterizerState::CullClockwise()
|
||||||
{
|
{
|
||||||
auto raster = uNew<RasterizerState>();
|
auto raster = unew<RasterizerState>();
|
||||||
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_FRONT;
|
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_FRONT;
|
||||||
raster->impl->dxDescription.DepthClipEnable = true;
|
raster->impl->dxDescription.DepthClipEnable = true;
|
||||||
@ -72,7 +72,7 @@ namespace xna {
|
|||||||
|
|
||||||
uptr<RasterizerState> RasterizerState::CullCounterClockwise()
|
uptr<RasterizerState> RasterizerState::CullCounterClockwise()
|
||||||
{
|
{
|
||||||
auto raster = uNew<RasterizerState>();
|
auto raster = unew<RasterizerState>();
|
||||||
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
raster->impl->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_BACK;
|
raster->impl->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_BACK;
|
||||||
raster->impl->dxDescription.DepthClipEnable = true;
|
raster->impl->dxDescription.DepthClipEnable = true;
|
||||||
|
@ -60,7 +60,7 @@ namespace xna {
|
|||||||
dxGlyps[i] = g;
|
dxGlyps[i] = g;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl = uNew<PlatformImplementation>();
|
impl = unew<PlatformImplementation>();
|
||||||
impl->_dxSpriteFont = unew<DxSpriteFont>(
|
impl->_dxSpriteFont = unew<DxSpriteFont>(
|
||||||
//ID3D11ShaderResourceView* texture
|
//ID3D11ShaderResourceView* texture
|
||||||
texture->impl->dxShaderResource,
|
texture->impl->dxShaderResource,
|
||||||
@ -127,8 +127,8 @@ namespace xna {
|
|||||||
if (!device->impl->_context)
|
if (!device->impl->_context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
implementation = uNew<PlatformImplementation>();
|
implementation = unew<PlatformImplementation>();
|
||||||
implementation->_dxspriteBatch = New<DxSpriteBatch>(
|
implementation->_dxspriteBatch = snew<DxSpriteBatch>(
|
||||||
//ID3D11DeviceContext* deviceContext
|
//ID3D11DeviceContext* deviceContext
|
||||||
device->impl->_context
|
device->impl->_context
|
||||||
);
|
);
|
||||||
|
@ -8,7 +8,7 @@ namespace xna {
|
|||||||
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName)
|
sptr<Texture2D> Texture2D::FromStream(GraphicsDevice& device, String const& fileName)
|
||||||
{
|
{
|
||||||
auto _this = device.shared_from_this();
|
auto _this = device.shared_from_this();
|
||||||
auto texture2d = New<Texture2D>(_this);
|
auto texture2d = snew<Texture2D>(_this);
|
||||||
ID3D11Resource* resource = nullptr;
|
ID3D11Resource* resource = nullptr;
|
||||||
auto wstr = XnaHelper::ToWString(fileName);
|
auto wstr = XnaHelper::ToWString(fileName);
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ namespace xna {
|
|||||||
sptr<Texture2D> Texture2D::FromMemory(GraphicsDevice& device, std::vector<Byte> const& data)
|
sptr<Texture2D> Texture2D::FromMemory(GraphicsDevice& device, std::vector<Byte> const& data)
|
||||||
{
|
{
|
||||||
auto _this = device.shared_from_this();
|
auto _this = device.shared_from_this();
|
||||||
auto texture2d = New<Texture2D>(_this);
|
auto texture2d = snew<Texture2D>(_this);
|
||||||
ID3D11Resource* resource = nullptr;
|
ID3D11Resource* resource = nullptr;
|
||||||
|
|
||||||
auto hr = DirectX::CreateWICTextureFromMemory(
|
auto hr = DirectX::CreateWICTextureFromMemory(
|
||||||
|
@ -28,7 +28,7 @@ namespace xna {
|
|||||||
if (a_device.has_value())
|
if (a_device.has_value())
|
||||||
device = std::any_cast<sptr<GraphicsDevice>>(a_device);
|
device = std::any_cast<sptr<GraphicsDevice>>(a_device);
|
||||||
|
|
||||||
auto texture2D = New<Texture2D>(device, width, height, mipMaps, format);
|
auto texture2D = snew<Texture2D>(device, width, height, mipMaps, format);
|
||||||
|
|
||||||
for (size_t level = 0; level < mipMaps; ++level) {
|
for (size_t level = 0; level < mipMaps; ++level) {
|
||||||
auto elementCount = input.ReadInt32();
|
auto elementCount = input.ReadInt32();
|
||||||
|
@ -51,7 +51,7 @@ namespace xna {
|
|||||||
template <class T>
|
template <class T>
|
||||||
inline sptr<Type> typeof() {
|
inline sptr<Type> typeof() {
|
||||||
if (std::is_arithmetic<T>::value) {
|
if (std::is_arithmetic<T>::value) {
|
||||||
auto primitiveType = New<Type>();
|
auto primitiveType = snew<Type>();
|
||||||
primitiveType->fullName = typeid(T).name();
|
primitiveType->fullName = typeid(T).name();
|
||||||
primitiveType->isPrimitive = true;
|
primitiveType->isPrimitive = true;
|
||||||
primitiveType->isValueType = true;
|
primitiveType->isValueType = true;
|
||||||
@ -59,7 +59,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (std::is_enum<T>::value) {
|
if (std::is_enum<T>::value) {
|
||||||
auto enumType = New<Type>();
|
auto enumType = snew<Type>();
|
||||||
enumType->fullName = typeid(T).name();
|
enumType->fullName = typeid(T).name();
|
||||||
enumType->isValueType = true;
|
enumType->isValueType = true;
|
||||||
enumType->isEnum = true;
|
enumType->isEnum = true;
|
||||||
@ -67,14 +67,14 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (std::is_pointer<T>::value) {
|
if (std::is_pointer<T>::value) {
|
||||||
auto pointerType = New<Type>();
|
auto pointerType = snew<Type>();
|
||||||
pointerType->fullName = typeid(T).name();
|
pointerType->fullName = typeid(T).name();
|
||||||
pointerType->isPointer = true;
|
pointerType->isPointer = true;
|
||||||
return pointerType;
|
return pointerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::is_class<T>::value) {
|
if (std::is_class<T>::value) {
|
||||||
auto classType = New<Type>();
|
auto classType = snew<Type>();
|
||||||
classType->fullName = typeid(T).name();
|
classType->fullName = typeid(T).name();
|
||||||
classType->isClass = true;
|
classType->isClass = true;
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "types.hpp"
|
#include "types.hpp"
|
||||||
#include "forward.hpp"
|
#include "forward.hpp"
|
||||||
#include "enums.hpp"
|
#include "enums.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
|
#include "exception.hpp"
|
@ -6,6 +6,8 @@
|
|||||||
#include <source_location>
|
#include <source_location>
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
|
||||||
|
//A list of standard exceptions
|
||||||
struct ExMessage {
|
struct ExMessage {
|
||||||
inline static const std::string InvalidOperation = "An invalid operation occurred.";
|
inline static const std::string InvalidOperation = "An invalid operation occurred.";
|
||||||
inline static const std::string InitializeComponent = "Unable to initialize component";
|
inline static const std::string InitializeComponent = "Unable to initialize component";
|
||||||
@ -13,9 +15,13 @@ namespace xna {
|
|||||||
inline static const std::string ApplyComponent = "Failed to apply component";
|
inline static const std::string ApplyComponent = "Failed to apply component";
|
||||||
inline static const std::string UnintializedComponent = "Component is not initialized";
|
inline static const std::string UnintializedComponent = "Component is not initialized";
|
||||||
inline static const std::string MakeWindowAssociation = "Failed to create association with window";
|
inline static const std::string MakeWindowAssociation = "Failed to create association with window";
|
||||||
|
inline static const std::string BuildObject = "Unable to build object";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Structure for throwing exceptions with a message and information from the source file
|
||||||
struct Exception {
|
struct Exception {
|
||||||
|
|
||||||
|
//Raises an exception with a message. Source file information is automatically captured.
|
||||||
static void Throw(std::string const& message, const std::source_location location = std::source_location::current()) {
|
static void Throw(std::string const& message, const std::source_location location = std::source_location::current()) {
|
||||||
std::string error;
|
std::string error;
|
||||||
|
|
||||||
|
@ -3,13 +3,20 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <stdexcept>
|
#include "exception.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Class for helper functions
|
||||||
struct XnaHelper {
|
struct XnaHelper {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Smart Pointer Comparator
|
||||||
|
//
|
||||||
|
|
||||||
template<typename T> struct is_shared_ptr : std::false_type {};
|
template<typename T> struct is_shared_ptr : std::false_type {};
|
||||||
template<typename T> struct is_shared_ptr<std::shared_ptr<T>> : std::true_type {};
|
template<typename T> struct is_shared_ptr<std::shared_ptr<T>> : std::true_type {};
|
||||||
|
|
||||||
|
//Convert a string to wstring
|
||||||
static inline std::wstring ToWString(const std::string& str)
|
static inline std::wstring ToWString(const std::string& str)
|
||||||
{
|
{
|
||||||
std::wstring wstr;
|
std::wstring wstr;
|
||||||
@ -19,6 +26,7 @@ namespace xna {
|
|||||||
return wstr;
|
return wstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Convert a wstring to string
|
||||||
static inline std::string ToString(const std::wstring& wstr)
|
static inline std::string ToString(const std::wstring& wstr)
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
@ -28,20 +36,23 @@ namespace xna {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns a hash reporting input values
|
||||||
template <class T>
|
template <class T>
|
||||||
static constexpr void HashCombine(std::size_t& seed, const T& v) {
|
static constexpr void HashCombine(std::size_t& seed, const T& v) {
|
||||||
std::hash<T> hasher;
|
std::hash<T> hasher;
|
||||||
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Returns null if the type is a smart pointer or default value if the type has a default constructor.
|
||||||
|
//Throws an exception if the object cannot be created
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline auto ReturnDefaultOrNull() {
|
static inline auto ReturnDefaultOrNull(const std::source_location location = std::source_location::current()) {
|
||||||
if constexpr (is_shared_ptr<T>::value)
|
if constexpr (is_shared_ptr<T>::value)
|
||||||
return (T)nullptr;
|
return (T)nullptr;
|
||||||
else if (std::is_default_constructible<T>::value)
|
else if (std::is_default_constructible<T>::value)
|
||||||
return T();
|
return T();
|
||||||
else
|
else
|
||||||
throw std::runtime_error("Unable to build object");
|
Exception::Throw(ExMessage::BuildObject, location);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace xna {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
static void insertActivadorReader() {
|
static void insertActivadorReader() {
|
||||||
ContentTypeReaderActivador::SetActivador(typeof<T>(), []() -> sptr<ContentTypeReader> {
|
ContentTypeReaderActivador::SetActivador(typeof<T>(), []() -> sptr<ContentTypeReader> {
|
||||||
auto obj = New <T>();
|
auto obj = snew<T>();
|
||||||
return reinterpret_pointer_cast<ContentTypeReader>(obj);
|
return reinterpret_pointer_cast<ContentTypeReader>(obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,10 @@
|
|||||||
#define XNA_PLATFORMINIT_HPP
|
#define XNA_PLATFORMINIT_HPP
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
//Exposes functions that must be implemented by the platform
|
||||||
struct Platform {
|
struct Platform {
|
||||||
|
//Initialization function, which must be implemented by the platform,
|
||||||
|
//and be called before the game is executed
|
||||||
static void Init();
|
static void Init();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
|
||||||
|
//
|
||||||
|
// C# standard types
|
||||||
|
//
|
||||||
|
|
||||||
using Sbyte = int8_t;
|
using Sbyte = int8_t;
|
||||||
using Byte = uint8_t;
|
using Byte = uint8_t;
|
||||||
using Short = int16_t;
|
using Short = int16_t;
|
||||||
@ -21,6 +26,10 @@ namespace xna {
|
|||||||
using Ulong = uint64_t;
|
using Ulong = uint64_t;
|
||||||
using Char = char16_t;
|
using Char = char16_t;
|
||||||
|
|
||||||
|
//
|
||||||
|
// C# Min and Max Value
|
||||||
|
//
|
||||||
|
|
||||||
constexpr Sbyte SbyteMaxValue = (std::numeric_limits<Sbyte>::max)();
|
constexpr Sbyte SbyteMaxValue = (std::numeric_limits<Sbyte>::max)();
|
||||||
constexpr Sbyte SbyteMinValue = (std::numeric_limits<Sbyte>::min)();
|
constexpr Sbyte SbyteMinValue = (std::numeric_limits<Sbyte>::min)();
|
||||||
constexpr Byte ByteMaxValue = (std::numeric_limits<Byte>::max)();
|
constexpr Byte ByteMaxValue = (std::numeric_limits<Byte>::max)();
|
||||||
@ -48,29 +57,27 @@ namespace xna {
|
|||||||
// About strings: https://stackoverflow.com/questions/402283/stdwstring-vs-stdstring
|
// About strings: https://stackoverflow.com/questions/402283/stdwstring-vs-stdstring
|
||||||
//
|
//
|
||||||
|
|
||||||
|
//Same as std::string
|
||||||
using String = std::string;
|
using String = std::string;
|
||||||
|
|
||||||
|
//Same as std::wstring
|
||||||
using WString = std::wstring;
|
using WString = std::wstring;
|
||||||
|
|
||||||
|
//Same as std::shared_ptr
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using sptr = std::shared_ptr<T>;
|
using sptr = std::shared_ptr<T>;
|
||||||
|
|
||||||
|
//Same as std::unique_ptr
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using uptr = std::unique_ptr<T>;
|
using uptr = std::unique_ptr<T>;
|
||||||
|
|
||||||
template <class _Ty, class... _Types>
|
//Same as std::make_shared
|
||||||
inline std::shared_ptr<_Ty> New(_Types&&... _Args) {
|
|
||||||
return std::make_shared<_Ty>(std::forward<_Types>(_Args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class _Ty, class... _Types>
|
|
||||||
inline std::unique_ptr<_Ty> uNew(_Types&&... _Args) {
|
|
||||||
return std::make_unique<_Ty>(std::forward<_Types>(_Args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class _Ty, class... _Types>
|
template <class _Ty, class... _Types>
|
||||||
inline std::shared_ptr<_Ty> snew(_Types&&... _Args) {
|
inline std::shared_ptr<_Ty> snew(_Types&&... _Args) {
|
||||||
return std::make_shared<_Ty>(std::forward<_Types>(_Args)...);
|
return std::make_shared<_Ty>(std::forward<_Types>(_Args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Same as std::make_unique
|
||||||
template <class _Ty, class... _Types>
|
template <class _Ty, class... _Types>
|
||||||
inline std::unique_ptr<_Ty> unew(_Types&&... _Args) {
|
inline std::unique_ptr<_Ty> unew(_Types&&... _Args) {
|
||||||
return std::make_unique<_Ty>(std::forward<_Types>(_Args)...);
|
return std::make_unique<_Ty>(std::forward<_Types>(_Args)...);
|
||||||
|
@ -15,7 +15,7 @@ namespace xna {
|
|||||||
|
|
||||||
void Initialize() override {
|
void Initialize() override {
|
||||||
auto game = reinterpret_cast<Game*>(this);
|
auto game = reinterpret_cast<Game*>(this);
|
||||||
graphics = New<GraphicsDeviceManager>(game->shared_from_this());
|
graphics = snew<GraphicsDeviceManager>(game->shared_from_this());
|
||||||
graphics->Initialize();
|
graphics->Initialize();
|
||||||
|
|
||||||
std::any device = graphicsDevice;
|
std::any device = graphicsDevice;
|
||||||
@ -25,7 +25,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadContent() override {
|
void LoadContent() override {
|
||||||
spriteBatch = New<SpriteBatch>(graphicsDevice);
|
spriteBatch = snew<SpriteBatch>(graphicsDevice);
|
||||||
auto texture = Content()->Load<PTexture2D>("Idle");
|
auto texture = Content()->Load<PTexture2D>("Idle");
|
||||||
Game::LoadContent();
|
Game::LoadContent();
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace PlatformerStarterKit {
|
|||||||
|
|
||||||
void Initialize() override {
|
void Initialize() override {
|
||||||
auto game = reinterpret_cast<Game*>(this);
|
auto game = reinterpret_cast<Game*>(this);
|
||||||
graphics = New<GraphicsDeviceManager>(game->shared_from_this());
|
graphics = snew<GraphicsDeviceManager>(game->shared_from_this());
|
||||||
graphics->Initialize();
|
graphics->Initialize();
|
||||||
|
|
||||||
std::any device = graphicsDevice;
|
std::any device = graphicsDevice;
|
||||||
@ -31,7 +31,7 @@ namespace PlatformerStarterKit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LoadContent() override {
|
void LoadContent() override {
|
||||||
spriteBatch = New<SpriteBatch>(graphicsDevice);
|
spriteBatch = snew<SpriteBatch>(graphicsDevice);
|
||||||
|
|
||||||
// Load fonts
|
// Load fonts
|
||||||
hudFont = Content()->Load<PSpriteFont>("Fonts/Hud");
|
hudFont = Content()->Load<PSpriteFont>("Fonts/Hud");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user