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

Remove platforminit.hpp

This commit is contained in:
Danilo 2024-07-08 09:40:48 -03:00
parent 29968e422f
commit dbd2495bdb
13 changed files with 115 additions and 136 deletions

View File

@ -40,7 +40,7 @@ add_library (Xn65 STATIC
"platform-dx/audioengine.cpp"
"graphics/gresource.cpp"
"platform-dx/effect.cpp"
"platform-dx/impl.cpp")
)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20)

View File

@ -1,5 +0,0 @@
#include "xna/platform/dx.hpp"
namespace xna {
}

View File

@ -1,4 +1,3 @@
#include "xna/platform/init.hpp"
#include "xna/csharp/type.hpp"
#include "xna/content/readers/graphics.hpp"
#include "xna/content/readers/audio.hpp"

View File

@ -1,4 +1,3 @@
#include "xna/input/mouse.hpp"
#include "xna/platform/dx.hpp"
namespace xna {

View File

@ -1,11 +1,11 @@
#ifndef XNA_GRAPHICS_SPRITE_HPP
#define XNA_GRAPHICS_SPRITE_HPP
#include "../default.hpp"
#include "../common/numerics.hpp"
#include "../common/color.hpp"
#include <optional>
#include "../common/numerics.hpp"
#include "../default.hpp"
#include "../graphics/gresource.hpp"
#include <optional>
namespace xna {
//Enables a group of sprites to be drawn using the same settings.
@ -13,7 +13,47 @@ namespace xna {
public:
SpriteBatch(sptr<GraphicsDevice> const& device);
//Begins a sprite batch operation.
//Begins a sprite batch operation.
void Begin(
std::optional<SpriteSortMode> sortMode,
uptr<BlendState> blendState,
uptr<SamplerState> samplerState,
uptr<DepthStencilState> depthStencil,
uptr<RasterizerState> rasterizerState,
uptr<Effect> effect,
Matrix const& transformMatrix = Matrix::Identity()
) {
Begin(
!sortMode.has_value() ? SpriteSortMode::Deferred : sortMode.value(),
blendState.get(),
samplerState.get(),
depthStencil.get(),
rasterizerState.get(),
effect.get(),
transformMatrix
);
}
void Begin(
std::optional<SpriteSortMode> sortMode,
sptr<BlendState> blendState,
sptr<SamplerState> samplerState,
sptr<DepthStencilState> depthStencil,
sptr<RasterizerState> rasterizerState,
sptr<Effect> effect,
Matrix const& transformMatrix = Matrix::Identity()
) {
Begin(
!sortMode.has_value() ? SpriteSortMode::Deferred : sortMode.value(),
blendState.get(),
samplerState.get(),
depthStencil.get(),
rasterizerState.get(),
effect.get(),
transformMatrix
);
}
void Begin(
SpriteSortMode sortMode = SpriteSortMode::Deferred,
BlendState* blendState = nullptr,

View File

@ -219,16 +219,16 @@ namespace xna {
public:
//Returns the current keyboard or Chatpad state.
static KeyboardState GetState();
static bool IsConnected();
Keyboard() = delete;
Keyboard(Keyboard&) = delete;
Keyboard(Keyboard&&) = delete;
static bool IsConnected();
private:
friend class Game;
static void Initialize();
Keyboard() = default;
Keyboard(Keyboard&) = default;
Keyboard(Keyboard&&) = default;
public:
struct PlatformImplementation;
inline static uptr<PlatformImplementation> impl = nullptr;

View File

@ -24,16 +24,16 @@ namespace xna {
static bool IsConnected();
static bool IsVisible();
static void IsVisible(bool value);
static void ResetScrollWheel();
Mouse() = delete;
Mouse(Mouse&) = delete;
Mouse(Mouse&&) = delete;
static void ResetScrollWheel();
private:
friend class Game;
static void Initialize();
Mouse() = default;
Mouse(Mouse&) = default;
Mouse(Mouse&&) = default;
public:
struct PlatformImplementation;
inline static uptr<PlatformImplementation> impl = nullptr;

View File

@ -1,9 +1,7 @@
#ifndef XNA_PLATFORMDX_DX_HPP
#define XNA_PLATFORMDX_DX_HPP
//--------------------------------//
// DX INCLUDES
//--------------------------------//
//---------------- DX INCLUDES ----------------//
//DirectX
#if defined(_XBOX_ONE) && defined(_TITLE)
@ -48,55 +46,19 @@
#include <wrl\wrappers\corewrappers.h>
#include <wrl\client.h>
//--------------------------------//
// USINGS
//--------------------------------//
//---------------- USINGS ----------------//
template <typename T>
using comptr = Microsoft::WRL::ComPtr<T>;
//--------------------------------//
// OTHERS INCLUDES
//--------------------------------//
//---------------- INCLUDES ----------------//
#include "../default.hpp"
#include "../exception.hpp"
#include "../graphics/blendstate.hpp"
#include "../graphics/adapter.hpp"
#include "../graphics/device.hpp"
#include "../graphics/adapter.hpp"
#include "../graphics/blendstate.hpp"
#include "../graphics/depthstencilstate.hpp"
#include "../graphics/displaymode.hpp"
#include "../graphics/sprite.hpp"
#include "../graphics/effect.hpp"
#include "../graphics/samplerstate.hpp"
#include "../input/gamepad.hpp"
#include "../input/keyboard.hpp"
#include "../input/mouse.hpp"
#include "../graphics/rasterizerstate.hpp"
#include "../graphics/presentparams.hpp"
#include "../graphics/swapchain.hpp"
#include "../graphics/texture.hpp"
#include "../graphics/rendertarget.hpp"
#include "../game/window.hpp"
#include "../audio/audioengine.hpp"
#include "../audio/soundeffect.hpp"
#include "../graphics/viewport.hpp"
#include "../common/color.hpp"
#include "../game/game.hpp"
#include <cmath>
#include <cstdint>
#include <exception>
#include "../xna.hpp"
//--------------------------------//
// CLASSES
//--------------------------------//
//---------------- CLASSES ----------------//
namespace xna {
//==============================================//
//================ DXHELPERS ================//
//==============================================//
//---------------- HELPERS ----------------//
struct DxHelpers {
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
@ -378,12 +340,43 @@ namespace xna {
static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) {
return static_cast<TextureAddressMode>(value - 1);
}
};
struct PlatformInit {
static void Init() {
InitRegisteredTypes();
InitActivadors();
}
static void InitRegisteredTypes();
static void InitActivadors();
private:
template <typename T>
static void insertRegisteredReader(String const& readerName) {
const auto reader = typeof<T>();
//Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader });
Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader });
Type::NameOfRegisteredTypes.insert({ "Microsoft.Xna.Framework.Content." + readerName, reader });
}
template <typename T>
static void insertRegisteredReader(String const& readerName, String const& microsoftNameFullName) {
const auto reader = typeof<T>();
//Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader });
Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader });
Type::NameOfRegisteredTypes.insert({ microsoftNameFullName, reader });
}
template <typename T>
static void insertActivadorReader() {
ContentTypeReaderActivador::SetActivador(typeof<T>(), []() -> sptr<ContentTypeReader> {
auto obj = snew<T>();
return reinterpret_pointer_cast<ContentTypeReader>(obj);
});
}
};
//==============================================//
//================ STEPTIMER ================//
//==============================================//
// Helper class for animation and simulation timing.
class StepTimer
{
@ -561,10 +554,7 @@ namespace xna {
uint64_t m_targetElapsedTicks;
};
//==============================================//
//================ IMPL ================//
//==============================================//
//---------------- IMPL ----------------//
struct SpriteFont::PlatformImplementation {
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };

View File

@ -1,46 +0,0 @@
#ifndef XNA_PLATFORM_INIT_HPP
#define XNA_PLATFORM_INIT_HPP
#include "../default.hpp"
#include "../csharp/type.hpp"
#include "../content/typereadermanager.hpp"
#include "../platforminit.hpp"
namespace xna {
struct PlatformInit {
static void Init() {
InitRegisteredTypes();
InitActivadors();
}
static void InitRegisteredTypes();
static void InitActivadors();
private:
template <typename T>
static void insertRegisteredReader(String const& readerName) {
const auto reader = typeof<T>();
//Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader });
Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader });
Type::NameOfRegisteredTypes.insert({ "Microsoft.Xna.Framework.Content." + readerName, reader });
}
template <typename T>
static void insertRegisteredReader(String const& readerName, String const& microsoftNameFullName) {
const auto reader = typeof<T>();
//Type::NameOfRegisteredTypes.insert({ "xna::" + readerName, reader });
Type::NameOfRegisteredTypes.insert({ reader->FullName(), reader });
Type::NameOfRegisteredTypes.insert({ microsoftNameFullName, reader });
}
template <typename T>
static void insertActivadorReader() {
ContentTypeReaderActivador::SetActivador(typeof<T>(), []() -> sptr<ContentTypeReader> {
auto obj = snew<T>();
return reinterpret_pointer_cast<ContentTypeReader>(obj);
});
}
};
}
#endif

View File

@ -1,13 +0,0 @@
#ifndef XNA_PLATFORMINIT_HPP
#define XNA_PLATFORMINIT_HPP
namespace xna {
//Exposes functions that must be implemented by the platform
struct Platform {
//Initialization function, which must be implemented by the platform,
//and be called before the game is executed
static void Init();
};
}
#endif

View File

@ -1,3 +1,6 @@
#ifndef XNA_XNA_HPP
#define XNA_XNA_HPP
#define NOMINMAX
#include "audio/audioengine.hpp"
#include "audio/soundeffect.hpp"
@ -44,10 +47,20 @@
#include "graphics/texture.hpp"
#include "graphics/vertexposition.hpp"
#include "graphics/viewport.hpp"
#include "graphics/effect.hpp"
#include "helpers.hpp"
#include "input/gamepad.hpp"
#include "input/keyboard.hpp"
#include "input/mouse.hpp"
#include "platforminit.hpp"
#include "types.hpp"
#include "platform/dx.hpp"
namespace xna {
//Exposes functions that must be implemented by the platform
struct Platform {
//Initialization function, which must be implemented by the platform,
//and be called before the game is executed
static void Init();
};
}
#endif

View File

@ -2,6 +2,7 @@
//
#include "xna/xna.hpp"
#include "xna/platform/dx.hpp"
using namespace std;
using namespace xna;

View File

@ -2,6 +2,7 @@
//
#include "xna/xna.hpp"
#include "xna/platform/dx.hpp"
#include "player.hpp"
#include "enemy.hpp"
#include "level.hpp"