mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Remove platforminit.hpp
This commit is contained in:
parent
29968e422f
commit
dbd2495bdb
@ -40,7 +40,7 @@ add_library (Xn65 STATIC
|
|||||||
"platform-dx/audioengine.cpp"
|
"platform-dx/audioengine.cpp"
|
||||||
"graphics/gresource.cpp"
|
"graphics/gresource.cpp"
|
||||||
"platform-dx/effect.cpp"
|
"platform-dx/effect.cpp"
|
||||||
"platform-dx/impl.cpp")
|
)
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||||
set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20)
|
set_property(TARGET Xn65 PROPERTY CXX_STANDARD 20)
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#include "xna/platform/dx.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +1,3 @@
|
|||||||
#include "xna/platform/init.hpp"
|
|
||||||
#include "xna/csharp/type.hpp"
|
#include "xna/csharp/type.hpp"
|
||||||
#include "xna/content/readers/graphics.hpp"
|
#include "xna/content/readers/graphics.hpp"
|
||||||
#include "xna/content/readers/audio.hpp"
|
#include "xna/content/readers/audio.hpp"
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
#include "xna/input/mouse.hpp"
|
|
||||||
#include "xna/platform/dx.hpp"
|
#include "xna/platform/dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef XNA_GRAPHICS_SPRITE_HPP
|
#ifndef XNA_GRAPHICS_SPRITE_HPP
|
||||||
#define XNA_GRAPHICS_SPRITE_HPP
|
#define XNA_GRAPHICS_SPRITE_HPP
|
||||||
|
|
||||||
#include "../default.hpp"
|
|
||||||
#include "../common/numerics.hpp"
|
|
||||||
#include "../common/color.hpp"
|
#include "../common/color.hpp"
|
||||||
#include <optional>
|
#include "../common/numerics.hpp"
|
||||||
|
#include "../default.hpp"
|
||||||
#include "../graphics/gresource.hpp"
|
#include "../graphics/gresource.hpp"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//Enables a group of sprites to be drawn using the same settings.
|
//Enables a group of sprites to be drawn using the same settings.
|
||||||
@ -13,7 +13,47 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
SpriteBatch(sptr<GraphicsDevice> const& device);
|
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(
|
void Begin(
|
||||||
SpriteSortMode sortMode = SpriteSortMode::Deferred,
|
SpriteSortMode sortMode = SpriteSortMode::Deferred,
|
||||||
BlendState* blendState = nullptr,
|
BlendState* blendState = nullptr,
|
||||||
|
@ -219,16 +219,16 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
//Returns the current keyboard or Chatpad state.
|
//Returns the current keyboard or Chatpad state.
|
||||||
static KeyboardState GetState();
|
static KeyboardState GetState();
|
||||||
static bool IsConnected();
|
static bool IsConnected();
|
||||||
|
|
||||||
Keyboard() = delete;
|
|
||||||
Keyboard(Keyboard&) = delete;
|
|
||||||
Keyboard(Keyboard&&) = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Game;
|
friend class Game;
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
||||||
|
Keyboard() = default;
|
||||||
|
Keyboard(Keyboard&) = default;
|
||||||
|
Keyboard(Keyboard&&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
@ -24,16 +24,16 @@ namespace xna {
|
|||||||
static bool IsConnected();
|
static bool IsConnected();
|
||||||
static bool IsVisible();
|
static bool IsVisible();
|
||||||
static void IsVisible(bool value);
|
static void IsVisible(bool value);
|
||||||
static void ResetScrollWheel();
|
static void ResetScrollWheel();
|
||||||
|
|
||||||
Mouse() = delete;
|
|
||||||
Mouse(Mouse&) = delete;
|
|
||||||
Mouse(Mouse&&) = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Game;
|
friend class Game;
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
||||||
|
Mouse() = default;
|
||||||
|
Mouse(Mouse&) = default;
|
||||||
|
Mouse(Mouse&&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = nullptr;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#ifndef XNA_PLATFORMDX_DX_HPP
|
#ifndef XNA_PLATFORMDX_DX_HPP
|
||||||
#define XNA_PLATFORMDX_DX_HPP
|
#define XNA_PLATFORMDX_DX_HPP
|
||||||
|
|
||||||
//--------------------------------//
|
//---------------- DX INCLUDES ----------------//
|
||||||
// DX INCLUDES
|
|
||||||
//--------------------------------//
|
|
||||||
|
|
||||||
//DirectX
|
//DirectX
|
||||||
#if defined(_XBOX_ONE) && defined(_TITLE)
|
#if defined(_XBOX_ONE) && defined(_TITLE)
|
||||||
@ -48,55 +46,19 @@
|
|||||||
#include <wrl\wrappers\corewrappers.h>
|
#include <wrl\wrappers\corewrappers.h>
|
||||||
#include <wrl\client.h>
|
#include <wrl\client.h>
|
||||||
|
|
||||||
//--------------------------------//
|
//---------------- USINGS ----------------//
|
||||||
// USINGS
|
|
||||||
//--------------------------------//
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using comptr = Microsoft::WRL::ComPtr<T>;
|
using comptr = Microsoft::WRL::ComPtr<T>;
|
||||||
|
|
||||||
//--------------------------------//
|
//---------------- INCLUDES ----------------//
|
||||||
// OTHERS INCLUDES
|
|
||||||
//--------------------------------//
|
|
||||||
|
|
||||||
#include "../default.hpp"
|
#include "../xna.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>
|
|
||||||
|
|
||||||
//--------------------------------//
|
//---------------- CLASSES ----------------//
|
||||||
// CLASSES
|
|
||||||
//--------------------------------//
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//==============================================//
|
//---------------- HELPERS ----------------//
|
||||||
//================ DXHELPERS ================//
|
|
||||||
//==============================================//
|
|
||||||
|
|
||||||
struct DxHelpers {
|
struct DxHelpers {
|
||||||
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
|
static constexpr DirectX::XMVECTOR VectorToDx(Vector2 const& value) {
|
||||||
@ -378,12 +340,43 @@ namespace xna {
|
|||||||
static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) {
|
static constexpr TextureAddressMode TextureAddresModeToXna(D3D11_TEXTURE_ADDRESS_MODE value) {
|
||||||
return static_cast<TextureAddressMode>(value - 1);
|
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.
|
// Helper class for animation and simulation timing.
|
||||||
class StepTimer
|
class StepTimer
|
||||||
{
|
{
|
||||||
@ -561,10 +554,7 @@ namespace xna {
|
|||||||
uint64_t m_targetElapsedTicks;
|
uint64_t m_targetElapsedTicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//---------------- IMPL ----------------//
|
||||||
//==============================================//
|
|
||||||
//================ IMPL ================//
|
|
||||||
//==============================================//
|
|
||||||
|
|
||||||
struct SpriteFont::PlatformImplementation {
|
struct SpriteFont::PlatformImplementation {
|
||||||
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };
|
uptr<DirectX::SpriteFont> _dxSpriteFont{ nullptr };
|
||||||
|
@ -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
|
|
@ -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
|
|
@ -1,3 +1,6 @@
|
|||||||
|
#ifndef XNA_XNA_HPP
|
||||||
|
#define XNA_XNA_HPP
|
||||||
|
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#include "audio/audioengine.hpp"
|
#include "audio/audioengine.hpp"
|
||||||
#include "audio/soundeffect.hpp"
|
#include "audio/soundeffect.hpp"
|
||||||
@ -44,10 +47,20 @@
|
|||||||
#include "graphics/texture.hpp"
|
#include "graphics/texture.hpp"
|
||||||
#include "graphics/vertexposition.hpp"
|
#include "graphics/vertexposition.hpp"
|
||||||
#include "graphics/viewport.hpp"
|
#include "graphics/viewport.hpp"
|
||||||
|
#include "graphics/effect.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "input/gamepad.hpp"
|
#include "input/gamepad.hpp"
|
||||||
#include "input/keyboard.hpp"
|
#include "input/keyboard.hpp"
|
||||||
#include "input/mouse.hpp"
|
#include "input/mouse.hpp"
|
||||||
#include "platforminit.hpp"
|
|
||||||
#include "types.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
|
@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "xna/xna.hpp"
|
||||||
|
#include "xna/platform/dx.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace xna;
|
using namespace xna;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "xna/xna.hpp"
|
||||||
|
#include "xna/platform/dx.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "enemy.hpp"
|
#include "enemy.hpp"
|
||||||
#include "level.hpp"
|
#include "level.hpp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user