mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
commit
0ce4255e10
@ -5,16 +5,14 @@
|
|||||||
# Add source to this project's executable.
|
# Add source to this project's executable.
|
||||||
add_library (Xn65 STATIC
|
add_library (Xn65 STATIC
|
||||||
"csharp/stream.cpp"
|
"csharp/stream.cpp"
|
||||||
|
"csharp/binary.cpp"
|
||||||
|
"csharp/type.cpp"
|
||||||
"game/component.cpp"
|
"game/component.cpp"
|
||||||
|
"game/servicecontainer.cpp"
|
||||||
"content/manager.cpp"
|
"content/manager.cpp"
|
||||||
"content/reader.cpp"
|
"content/reader.cpp"
|
||||||
"csharp/binary.cpp"
|
|
||||||
"content/lzx/decoder.cpp"
|
"content/lzx/decoder.cpp"
|
||||||
|
|
||||||
"content/typereadermanager.cpp"
|
"content/typereadermanager.cpp"
|
||||||
"csharp/object.cpp"
|
|
||||||
"csharp/type.cpp"
|
|
||||||
"game/servicecontainer.cpp"
|
|
||||||
"common/color.cpp"
|
"common/color.cpp"
|
||||||
"common/collision.cpp"
|
"common/collision.cpp"
|
||||||
"common/gjk.cpp"
|
"common/gjk.cpp"
|
||||||
@ -29,7 +27,6 @@ add_library (Xn65 STATIC
|
|||||||
"platform-dx/blendstate.cpp"
|
"platform-dx/blendstate.cpp"
|
||||||
"platform-dx/game.cpp"
|
"platform-dx/game.cpp"
|
||||||
"platform-dx/gdevicemanager.cpp"
|
"platform-dx/gdevicemanager.cpp"
|
||||||
|
|
||||||
"platform-dx/rasterizerstate.cpp"
|
"platform-dx/rasterizerstate.cpp"
|
||||||
"platform-dx/samplerstate.cpp"
|
"platform-dx/samplerstate.cpp"
|
||||||
"platform-dx/sprite.cpp"
|
"platform-dx/sprite.cpp"
|
||||||
@ -40,8 +37,10 @@ add_library (Xn65 STATIC
|
|||||||
"platform-dx/soundeffect.cpp"
|
"platform-dx/soundeffect.cpp"
|
||||||
"platform-dx/displaymode.cpp"
|
"platform-dx/displaymode.cpp"
|
||||||
"platform-dx/init.cpp"
|
"platform-dx/init.cpp"
|
||||||
|
"platform-dx/audioengine.cpp"
|
||||||
"platform-dx/audioengine.cpp" "graphics/gresource.cpp" "platform-dx/effect.cpp" "platform-dx/impl.cpp")
|
"graphics/gresource.cpp"
|
||||||
|
"platform-dx/effect.cpp"
|
||||||
|
"exception.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)
|
||||||
@ -53,6 +52,6 @@ find_package(directxtk CONFIG REQUIRED)
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
Xn65 D3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib Microsoft::DirectXTK dxguid.lib
|
Xn65 D3d11.lib dxgi.lib dxguid.lib d3dcompiler.lib Microsoft::DirectXTK dxguid.lib
|
||||||
"${PROJECT_INCLUDES_DIR}/libmspack/mspack.lib"
|
#"${PROJECT_INCLUDES_DIR}/libmspack/mspack.lib"
|
||||||
"${PROJECT_INCLUDES_DIR}/effects11/Effects11.lib"
|
#"${PROJECT_INCLUDES_DIR}/effects11/Effects11.lib"
|
||||||
)
|
)
|
||||||
|
@ -2,11 +2,8 @@
|
|||||||
|
|
||||||
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 = snew<FileStream>(filePath, FileMode::Open);
|
const auto stream = snew<FileStream>(filePath, FileMode::Open);
|
||||||
|
|
||||||
if (stream->IsClosed())
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
return reinterpret_pointer_cast<Stream>(stream);
|
return reinterpret_pointer_cast<Stream>(stream);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
#include "xna/csharp/buffer.hpp"
|
#include "xna/csharp/buffer.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
BinaryReader::BinaryReader(sptr<Stream> const& input) {
|
||||||
|
Exception::ThrowIfNull(input, nameof(input));
|
||||||
|
|
||||||
|
stream = input;
|
||||||
|
buffer = std::vector<Byte>(bufferLength);
|
||||||
|
}
|
||||||
|
|
||||||
Int BinaryReader::PeekChar()
|
Int BinaryReader::PeekChar()
|
||||||
{
|
{
|
||||||
const auto position = stream->Position();
|
const auto position = stream->Position();
|
||||||
@ -256,7 +263,7 @@ namespace xna {
|
|||||||
void BinaryReader::FillBuffer(Int numBytes)
|
void BinaryReader::FillBuffer(Int numBytes)
|
||||||
{
|
{
|
||||||
if (numBytes < 0 || numBytes > buffer.size()) {
|
if (numBytes < 0 || numBytes > buffer.size()) {
|
||||||
throw std::out_of_range("numBytes");
|
Exception::Throw(Exception::OUT_OF_BOUNDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
Int bytesRead = 0;
|
Int bytesRead = 0;
|
||||||
@ -266,7 +273,7 @@ namespace xna {
|
|||||||
n = stream->ReadByte();
|
n = stream->ReadByte();
|
||||||
|
|
||||||
if (n == -1){
|
if (n == -1){
|
||||||
throw std::runtime_error("End of file.");
|
Exception::Throw(Exception::END_OF_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = static_cast<Byte>(n);
|
buffer[0] = static_cast<Byte>(n);
|
||||||
@ -277,7 +284,7 @@ namespace xna {
|
|||||||
n = stream->Read(buffer, bytesRead, numBytes - bytesRead);
|
n = stream->Read(buffer, bytesRead, numBytes - bytesRead);
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
throw std::runtime_error("End of file.");
|
Exception::Throw(Exception::END_OF_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bytesRead += n;
|
bytesRead += n;
|
||||||
@ -432,50 +439,58 @@ namespace xna {
|
|||||||
|
|
||||||
//Binary Writer
|
//Binary Writer
|
||||||
|
|
||||||
|
BinaryWriter::BinaryWriter(sptr<Stream> const& stream) {
|
||||||
|
Exception::ThrowIfNull(stream, nameof(stream));
|
||||||
|
|
||||||
|
OutStream = stream;
|
||||||
|
_buffer = std::vector<Byte>(16);
|
||||||
|
}
|
||||||
|
|
||||||
Long BinaryWriter::Seek(Int offset, SeekOrigin origin)
|
Long BinaryWriter::Seek(Int offset, SeekOrigin origin)
|
||||||
{
|
{
|
||||||
return _stream->Seek(offset, origin);
|
return OutStream->Seek(offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(bool value)
|
void BinaryWriter::Write(bool value)
|
||||||
{
|
{
|
||||||
_buffer[0] = value ? (Byte)1 : (Byte)0;
|
_buffer[0] = value ? static_cast<Byte>(1) : static_cast<Byte>(0);
|
||||||
_stream->Write(_buffer, 0, 1);
|
OutStream->Write(_buffer, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Byte value)
|
void BinaryWriter::Write(Byte value)
|
||||||
{
|
{
|
||||||
_stream->WriteByte(value);
|
OutStream->WriteByte(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Sbyte value)
|
void BinaryWriter::Write(Sbyte value)
|
||||||
{
|
{
|
||||||
_stream->WriteByte(static_cast<Byte>(value));
|
OutStream->WriteByte(static_cast<Byte>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Byte const* buffer, Int bufferLength)
|
void BinaryWriter::Write(Byte const* buffer, Int bufferLength)
|
||||||
{
|
{
|
||||||
_stream->Write(buffer, bufferLength, 0, bufferLength);
|
OutStream->Write(buffer, bufferLength, 0, bufferLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(std::vector<Byte> const& buffer)
|
void BinaryWriter::Write(std::vector<Byte> const& buffer)
|
||||||
{
|
{
|
||||||
_stream->Write(buffer, 0, static_cast<Int>(buffer.size()));
|
OutStream->Write(buffer, 0, static_cast<Int>(buffer.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Byte const* buffer, Int bufferLength, Int index, Int count)
|
void BinaryWriter::Write(Byte const* buffer, Int bufferLength, Int index, Int count)
|
||||||
{
|
{
|
||||||
_stream->Write(buffer, bufferLength, index, count);
|
OutStream->Write(buffer, bufferLength, index, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(std::vector<Byte> const& buffer, Int index, Int count)
|
void BinaryWriter::Write(std::vector<Byte> const& buffer, Int index, Int count)
|
||||||
{
|
{
|
||||||
_stream->Write(buffer, index, count);
|
OutStream->Write(buffer, index, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Char ch)
|
void BinaryWriter::Write(Char ch)
|
||||||
{
|
{
|
||||||
_buffer[0] = static_cast<Byte>(ch);
|
_buffer[0] = static_cast<Byte>(ch);
|
||||||
_stream->Write(_buffer, 0, 1);
|
OutStream->Write(_buffer, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(double value)
|
void BinaryWriter::Write(double value)
|
||||||
@ -490,21 +505,21 @@ namespace xna {
|
|||||||
_buffer[6] = static_cast<Byte>(num >> 48);
|
_buffer[6] = static_cast<Byte>(num >> 48);
|
||||||
_buffer[7] = static_cast<Byte>(num >> 56);
|
_buffer[7] = static_cast<Byte>(num >> 56);
|
||||||
|
|
||||||
_stream->Write(_buffer, 0, 8);
|
OutStream->Write(_buffer, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Short value)
|
void BinaryWriter::Write(Short value)
|
||||||
{
|
{
|
||||||
_buffer[0] = static_cast<Byte>(value);
|
_buffer[0] = static_cast<Byte>(value);
|
||||||
_buffer[1] = static_cast<Byte>((Uint)value >> 8);
|
_buffer[1] = static_cast<Byte>((Uint)value >> 8);
|
||||||
_stream->Write(_buffer, 0, 2);
|
OutStream->Write(_buffer, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Ushort value)
|
void BinaryWriter::Write(Ushort value)
|
||||||
{
|
{
|
||||||
_buffer[0] = static_cast<Byte>(value);
|
_buffer[0] = static_cast<Byte>(value);
|
||||||
_buffer[1] = static_cast<Byte>((Uint)value >> 8);
|
_buffer[1] = static_cast<Byte>((Uint)value >> 8);
|
||||||
_stream->Write(_buffer, 0, 2);
|
OutStream->Write(_buffer, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Int value)
|
void BinaryWriter::Write(Int value)
|
||||||
@ -513,7 +528,7 @@ namespace xna {
|
|||||||
_buffer[1] = static_cast<Byte>(value >> 8);
|
_buffer[1] = static_cast<Byte>(value >> 8);
|
||||||
_buffer[2] = static_cast<Byte>(value >> 16);
|
_buffer[2] = static_cast<Byte>(value >> 16);
|
||||||
_buffer[3] = static_cast<Byte>(value >> 24);
|
_buffer[3] = static_cast<Byte>(value >> 24);
|
||||||
_stream->Write(_buffer, 0, 4);
|
OutStream->Write(_buffer, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Uint value)
|
void BinaryWriter::Write(Uint value)
|
||||||
@ -522,7 +537,7 @@ namespace xna {
|
|||||||
_buffer[1] = static_cast<Byte>(value >> 8);
|
_buffer[1] = static_cast<Byte>(value >> 8);
|
||||||
_buffer[2] = static_cast<Byte>(value >> 16);
|
_buffer[2] = static_cast<Byte>(value >> 16);
|
||||||
_buffer[3] = static_cast<Byte>(value >> 24);
|
_buffer[3] = static_cast<Byte>(value >> 24);
|
||||||
_stream->Write(_buffer, 0, 4);
|
OutStream->Write(_buffer, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(Ulong value)
|
void BinaryWriter::Write(Ulong value)
|
||||||
@ -535,7 +550,7 @@ namespace xna {
|
|||||||
_buffer[5] = static_cast<Byte>(value >> 40);
|
_buffer[5] = static_cast<Byte>(value >> 40);
|
||||||
_buffer[6] = static_cast<Byte>(value >> 48);
|
_buffer[6] = static_cast<Byte>(value >> 48);
|
||||||
_buffer[7] = static_cast<Byte>(value >> 56);
|
_buffer[7] = static_cast<Byte>(value >> 56);
|
||||||
_stream->Write(_buffer, 0, 8);
|
OutStream->Write(_buffer, 0, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(float value)
|
void BinaryWriter::Write(float value)
|
||||||
@ -545,7 +560,7 @@ namespace xna {
|
|||||||
_buffer[1] = static_cast<Byte>(num >> 8);
|
_buffer[1] = static_cast<Byte>(num >> 8);
|
||||||
_buffer[2] = static_cast<Byte>(num >> 16);
|
_buffer[2] = static_cast<Byte>(num >> 16);
|
||||||
_buffer[3] = static_cast<Byte>(num >> 24);
|
_buffer[3] = static_cast<Byte>(num >> 24);
|
||||||
_stream->Write(_buffer, 0, 4);
|
OutStream->Write(_buffer, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write(std::string const& value)
|
void BinaryWriter::Write(std::string const& value)
|
||||||
@ -557,7 +572,7 @@ namespace xna {
|
|||||||
{
|
{
|
||||||
Write7BitEncodedInt(static_cast<Int>(stringLength));
|
Write7BitEncodedInt(static_cast<Int>(stringLength));
|
||||||
const auto b = reinterpret_cast<const Byte*>(_string);
|
const auto b = reinterpret_cast<const Byte*>(_string);
|
||||||
_stream->Write(b, static_cast<Int>(stringLength), 0, static_cast<Int>(stringLength));
|
OutStream->Write(b, static_cast<Int>(stringLength), 0, static_cast<Int>(stringLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BinaryWriter::Write7BitEncodedInt(Int value)
|
void BinaryWriter::Write7BitEncodedInt(Int value)
|
||||||
@ -579,6 +594,6 @@ namespace xna {
|
|||||||
_buffer[5] = static_cast<Byte>(value >> 40);
|
_buffer[5] = static_cast<Byte>(value >> 40);
|
||||||
_buffer[6] = static_cast<Byte>(value >> 48);
|
_buffer[6] = static_cast<Byte>(value >> 48);
|
||||||
_buffer[7] = static_cast<Byte>(value >> 56);
|
_buffer[7] = static_cast<Byte>(value >> 56);
|
||||||
_stream->Write(_buffer, 0, 8);
|
OutStream->Write(_buffer, 0, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +0,0 @@
|
|||||||
#include "xna/csharp/object.hpp"
|
|
||||||
#include "xna/csharp/type.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
size_t Object::GetHashCode() const
|
|
||||||
{
|
|
||||||
size_t seed = 0;
|
|
||||||
XnaHelper::HashCombine(seed, this);
|
|
||||||
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
}
|
|
@ -32,8 +32,6 @@ namespace xna {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
assertm(_position >= 0, "position >= 0");
|
|
||||||
|
|
||||||
_position = static_cast<Int>(p);
|
_position = static_cast<Int>(p);
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
@ -170,14 +168,13 @@ namespace xna {
|
|||||||
_fstream.open(path.c_str(), flags);
|
_fstream.open(path.c_str(), flags);
|
||||||
|
|
||||||
if (!_fstream.good())
|
if (!_fstream.good())
|
||||||
_closed = true;
|
Exception::Throw("Failed to open file: " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileStream::FileStream(String const& path) {
|
FileStream::FileStream(String const& path) {
|
||||||
int flags = std::fstream::in
|
int flags = std::fstream::in
|
||||||
| std::fstream::out
|
| std::fstream::out
|
||||||
| std::fstream::binary;
|
| std::fstream::binary;
|
||||||
//| std::fstream::ate;
|
|
||||||
|
|
||||||
const auto exists = std::filesystem::exists(path);
|
const auto exists = std::filesystem::exists(path);
|
||||||
|
|
||||||
@ -187,7 +184,7 @@ namespace xna {
|
|||||||
_fstream.open(path.c_str(), flags);
|
_fstream.open(path.c_str(), flags);
|
||||||
|
|
||||||
if (!_fstream.good())
|
if (!_fstream.good())
|
||||||
_closed = true;
|
Exception::Throw("Failed to open file: " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
Int FileStream::Length() {
|
Int FileStream::Length() {
|
||||||
|
37
framework/exception.cpp
Normal file
37
framework/exception.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "xna/exception.hpp"
|
||||||
|
|
||||||
|
namespace xna {
|
||||||
|
void Exception::Throw(std::string const& message, std::source_location const& location) {
|
||||||
|
std::string error;
|
||||||
|
|
||||||
|
error.append("Exception in: ");
|
||||||
|
#if _DEBUG
|
||||||
|
error.append(location.file_name());
|
||||||
|
error.append("(");
|
||||||
|
error.append(std::to_string(location.line()));
|
||||||
|
error.append(":");
|
||||||
|
error.append(std::to_string(location.column()));
|
||||||
|
error.append(") ");
|
||||||
|
#endif
|
||||||
|
error.append("': ");
|
||||||
|
error.append(location.function_name());
|
||||||
|
error.append("': ");
|
||||||
|
error.append(message);
|
||||||
|
error.append("\n");
|
||||||
|
|
||||||
|
throw std::runtime_error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Exception::ThrowIfNull(void const* argument, std::string const& argumentName, std::source_location const& location) {
|
||||||
|
if (argument)
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string error;
|
||||||
|
|
||||||
|
error.append("The value of ");
|
||||||
|
error.append(argumentName);
|
||||||
|
error.append(" is null.");
|
||||||
|
|
||||||
|
Throw(error);
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
#include "xna/graphics/adapter.hpp"
|
#include "xna/graphics/adapter.hpp"
|
||||||
#include "xna/graphics/displaymode.hpp"
|
#include "xna/graphics/displaymode.hpp"
|
||||||
#include "xna/game/gdevicemanager.hpp"
|
#include "xna/game/gdevicemanager.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
static size_t getDisplayModesCount(IDXGIAdapter* adapter);
|
||||||
@ -15,7 +15,7 @@ namespace xna {
|
|||||||
comptr<IDXGIFactory1> pFactory = nullptr;
|
comptr<IDXGIFactory1> pFactory = nullptr;
|
||||||
|
|
||||||
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)pFactory.GetAddressOf()))
|
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)pFactory.GetAddressOf()))
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
|
|
||||||
comptr<IDXGIAdapter1> pAdapter = nullptr;
|
comptr<IDXGIAdapter1> pAdapter = nullptr;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ namespace xna {
|
|||||||
comptr<IDXGIFactory1> pFactory = nullptr;
|
comptr<IDXGIFactory1> pFactory = nullptr;
|
||||||
|
|
||||||
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)pFactory.GetAddressOf()))
|
if FAILED(CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)pFactory.GetAddressOf()))
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
|
|
||||||
comptr<IDXGIAdapter1> pAdapter = nullptr;
|
comptr<IDXGIAdapter1> pAdapter = nullptr;
|
||||||
UINT count = 0;
|
UINT count = 0;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
void AudioEngine::Initialize() {
|
void AudioEngine::Initialize() {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "xna/graphics/blendstate.hpp"
|
#include "xna/graphics/blendstate.hpp"
|
||||||
#include "xna/graphics/gresource.hpp"
|
#include "xna/graphics/gresource.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
BlendState::BlendState() : BlendState(nullptr) {}
|
BlendState::BlendState() : BlendState(nullptr) {}
|
||||||
@ -98,7 +98,7 @@ namespace xna {
|
|||||||
bool BlendState::Initialize()
|
bool BlendState::Initialize()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device) {
|
if (!m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->dxBlendState) {
|
if (impl->dxBlendState) {
|
||||||
@ -110,7 +110,7 @@ namespace xna {
|
|||||||
impl->dxBlendState.GetAddressOf());
|
impl->dxBlendState.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -118,11 +118,11 @@ namespace xna {
|
|||||||
|
|
||||||
bool BlendState::Apply() {
|
bool BlendState::Apply() {
|
||||||
if (!m_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::ApplyComponent);
|
Exception::Throw(Exception::FAILED_TO_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!impl->dxBlendState) {
|
if (!impl->dxBlendState) {
|
||||||
Exception::Throw(ExMessage::UnintializedComponent);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->impl->_context->OMSetBlendState(
|
m_device->impl->_context->OMSetBlendState(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "xna/graphics/depthstencilstate.hpp"
|
#include "xna/graphics/depthstencilstate.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
static D3D11_DEPTH_STENCIL_DESC defaultDesc() {
|
static D3D11_DEPTH_STENCIL_DESC defaultDesc() {
|
||||||
@ -38,7 +38,7 @@ namespace xna {
|
|||||||
bool DepthStencilState::Initialize()
|
bool DepthStencilState::Initialize()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device) {
|
if (!m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->dxDepthStencil) {
|
if (impl->dxDepthStencil) {
|
||||||
@ -50,7 +50,7 @@ namespace xna {
|
|||||||
impl->dxDepthStencil.GetAddressOf());
|
impl->dxDepthStencil.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -59,11 +59,11 @@ namespace xna {
|
|||||||
bool DepthStencilState::Apply()
|
bool DepthStencilState::Apply()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!impl->dxDepthStencil) {
|
if (!impl->dxDepthStencil) {
|
||||||
Exception::Throw(ExMessage::UnintializedComponent);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->impl->_context->OMSetDepthStencilState(impl->dxDepthStencil.Get(), 0);
|
m_device->impl->_context->OMSetDepthStencilState(impl->dxDepthStencil.Get(), 0);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/game/gdevicemanager.hpp"
|
#include "xna/game/gdevicemanager.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
@ -53,7 +53,7 @@ namespace xna {
|
|||||||
impl._context.GetAddressOf());
|
impl._context.GetAddressOf());
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ namespace xna {
|
|||||||
auto hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&impl->_factory);
|
auto hr = CreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**)&impl->_factory);
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
|
|
||||||
const auto bounds = impl->_gameWindow->ClientBounds();
|
const auto bounds = impl->_gameWindow->ClientBounds();
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ namespace xna {
|
|||||||
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);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
Exception::Throw(ExMessage::MakeWindowAssociation);
|
Exception::Throw(Exception::FAILED_TO_MAKE_WINDOW_ASSOCIATION);
|
||||||
|
|
||||||
impl->_renderTarget2D = snew<RenderTarget2D>(_this);
|
impl->_renderTarget2D = snew<RenderTarget2D>(_this);
|
||||||
|
|
||||||
@ -185,10 +185,10 @@ namespace xna {
|
|||||||
switch (options)
|
switch (options)
|
||||||
{
|
{
|
||||||
case xna::ClearOptions::DepthBuffer:
|
case xna::ClearOptions::DepthBuffer:
|
||||||
Exception::Throw(ExMessage::NotImplemented);
|
Exception::Throw(Exception::NOT_IMPLEMENTED);
|
||||||
break;
|
break;
|
||||||
case xna::ClearOptions::Stencil:
|
case xna::ClearOptions::Stencil:
|
||||||
Exception::Throw(ExMessage::NotImplemented);
|
Exception::Throw(Exception::NOT_IMPLEMENTED);
|
||||||
break;
|
break;
|
||||||
case xna::ClearOptions::Target:
|
case xna::ClearOptions::Target:
|
||||||
Clear(color);
|
Clear(color);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/graphics/displaymode.hpp"
|
#include "xna/graphics/displaymode.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "xna/graphics/effect.hpp"
|
#include "xna/graphics/effect.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/common/math.hpp"
|
#include "xna/common/math.hpp"
|
||||||
|
|
||||||
using DxBasicEffect = DirectX::BasicEffect;
|
using DxBasicEffect = DirectX::BasicEffect;
|
||||||
@ -100,7 +100,7 @@ namespace xna {
|
|||||||
|
|
||||||
void BasicEffect::Texture(sptr<xna::Texture2D> const& value) {
|
void BasicEffect::Texture(sptr<xna::Texture2D> const& value) {
|
||||||
if (!value || !value->impl || !value->impl->dxShaderResource)
|
if (!value || !value->impl || !value->impl->dxShaderResource)
|
||||||
Exception::Throw(ExMessage::ArgumentIsNull);
|
Exception::Throw(Exception::ARGUMENT_IS_NULL);
|
||||||
|
|
||||||
impl->dxBasicEffect->SetTexture(value->impl->dxShaderResource.Get());
|
impl->dxBasicEffect->SetTexture(value->impl->dxShaderResource.Get());
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,4 @@
|
|||||||
#include "xna/content/manager.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/csharp/type.hpp"
|
|
||||||
#include "xna/game/component.hpp"
|
|
||||||
#include "xna/game/gdevicemanager.hpp"
|
|
||||||
#include "xna/game/servicecontainer.hpp"
|
|
||||||
#include "xna/game/time.hpp"
|
|
||||||
#include "xna/platform-dx/dx.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
Game::Game() {
|
Game::Game() {
|
||||||
@ -12,7 +6,7 @@ namespace xna {
|
|||||||
services = snew<GameServiceContainer>();
|
services = snew<GameServiceContainer>();
|
||||||
auto iservice = reinterpret_pointer_cast<IServiceProvider>(services);
|
auto iservice = reinterpret_pointer_cast<IServiceProvider>(services);
|
||||||
_contentManager = snew<ContentManager>(services, "");
|
_contentManager = snew<ContentManager>(services, "");
|
||||||
_contentManager->_gameServices = iservice;
|
_contentManager->mainGameService = iservice;
|
||||||
|
|
||||||
_gameWindow = snew<GameWindow>();
|
_gameWindow = snew<GameWindow>();
|
||||||
_gameWindow->impl->Color(146, 150, 154);
|
_gameWindow->impl->Color(146, 150, 154);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/input/gamepad.hpp"
|
#include "xna/input/gamepad.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "xna/game/gdevicemanager.hpp"
|
#include "xna/game/gdevicemanager.hpp"
|
||||||
#include "xna/graphics/presentparams.hpp"
|
#include "xna/graphics/presentparams.hpp"
|
||||||
#include "xna/graphics/swapchain.hpp"
|
#include "xna/graphics/swapchain.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
GraphicsDeviceManager::GraphicsDeviceManager(sptr<Game> const& game) : _game(game)
|
GraphicsDeviceManager::GraphicsDeviceManager(sptr<Game> const& game) : _game(game)
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +1,9 @@
|
|||||||
#include "xna/platform-dx/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"
|
||||||
#include "xna/content/typereadermanager.hpp"
|
#include "xna/content/typereadermanager.hpp"
|
||||||
#include "xna/content/readers/default.hpp"
|
#include "xna/content/readers/default.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
void Platform::Init() {
|
void Platform::Init() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "xna/input/keyboard.hpp"
|
#include "xna/input/keyboard.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
KeyboardState Keyboard::GetState() {
|
KeyboardState Keyboard::GetState() {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "xna/input/mouse.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
MouseState Mouse::GetState() {
|
MouseState Mouse::GetState() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "xna/graphics/rasterizerstate.hpp"
|
#include "xna/graphics/rasterizerstate.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ namespace xna {
|
|||||||
bool RasterizerState::Initialize()
|
bool RasterizerState::Initialize()
|
||||||
{
|
{
|
||||||
if (!impl || !m_device || !m_device->impl->_device) {
|
if (!impl || !m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->dxRasterizerState) {
|
if (impl->dxRasterizerState) {
|
||||||
@ -30,7 +30,7 @@ namespace xna {
|
|||||||
impl->dxRasterizerState.GetAddressOf());
|
impl->dxRasterizerState.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -39,11 +39,11 @@ namespace xna {
|
|||||||
bool RasterizerState::Apply()
|
bool RasterizerState::Apply()
|
||||||
{
|
{
|
||||||
if (!impl || !m_device || !m_device->impl->_context) {
|
if (!impl || !m_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!impl->dxRasterizerState) {
|
if (!impl->dxRasterizerState) {
|
||||||
Exception::Throw(ExMessage::UnintializedComponent);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->impl->_context->RSSetState(impl->dxRasterizerState.Get());
|
m_device->impl->_context->RSSetState(impl->dxRasterizerState.Get());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
RenderTarget2D::RenderTarget2D() : Texture2D() {
|
RenderTarget2D::RenderTarget2D() : Texture2D() {
|
||||||
@ -15,7 +15,7 @@ namespace xna {
|
|||||||
|
|
||||||
bool RenderTarget2D::Initialize() {
|
bool RenderTarget2D::Initialize() {
|
||||||
if (!impl || !m_device || !m_device->impl->_device) {
|
if (!impl || !m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_device->impl->_swapChain->impl->GetBackBuffer(impl->dxTexture2D))
|
if (!m_device->impl->_swapChain->impl->GetBackBuffer(impl->dxTexture2D))
|
||||||
@ -26,7 +26,7 @@ namespace xna {
|
|||||||
const auto hr = dxdevice->CreateRenderTargetView(impl->dxTexture2D.Get(), NULL, render_impl->_renderTargetView.ReleaseAndGetAddressOf());
|
const auto hr = dxdevice->CreateRenderTargetView(impl->dxTexture2D.Get(), NULL, render_impl->_renderTargetView.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -34,11 +34,11 @@ namespace xna {
|
|||||||
|
|
||||||
bool RenderTarget2D::Apply() {
|
bool RenderTarget2D::Apply() {
|
||||||
if (!m_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::ApplyComponent);
|
Exception::Throw(Exception::FAILED_TO_APPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!render_impl->_renderTargetView)
|
if(!render_impl->_renderTargetView)
|
||||||
Exception::Throw(ExMessage::UnintializedComponent);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
|
|
||||||
auto& context = m_device->impl->_context;
|
auto& context = m_device->impl->_context;
|
||||||
context->OMSetRenderTargets(1, render_impl->_renderTargetView.GetAddressOf(), nullptr);
|
context->OMSetRenderTargets(1, render_impl->_renderTargetView.GetAddressOf(), nullptr);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "xna/graphics/samplerstate.hpp"
|
#include "xna/graphics/samplerstate.hpp"
|
||||||
#include "xna/graphics/samplerstate.hpp"
|
#include "xna/graphics/samplerstate.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
SamplerState::SamplerState() : SamplerState(nullptr){}
|
SamplerState::SamplerState() : SamplerState(nullptr){}
|
||||||
@ -12,7 +12,7 @@ namespace xna {
|
|||||||
bool SamplerState::Initialize()
|
bool SamplerState::Initialize()
|
||||||
{
|
{
|
||||||
if (!impl || !m_device || !m_device->impl->_device) {
|
if (!impl || !m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl->_samplerState) {
|
if (impl->_samplerState) {
|
||||||
@ -24,7 +24,7 @@ namespace xna {
|
|||||||
impl->_samplerState.GetAddressOf());
|
impl->_samplerState.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -33,11 +33,11 @@ namespace xna {
|
|||||||
bool SamplerState::Apply()
|
bool SamplerState::Apply()
|
||||||
{
|
{
|
||||||
if (!impl || !m_device || !m_device->impl->_context) {
|
if (!impl || !m_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!impl->_samplerState) {
|
if (!impl->_samplerState) {
|
||||||
Exception::Throw(ExMessage::UnintializedComponent);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_device->impl->_context->PSSetSamplers(0, 1, impl->_samplerState.GetAddressOf());
|
m_device->impl->_context->PSSetSamplers(0, 1, impl->_samplerState.GetAddressOf());
|
||||||
@ -50,7 +50,7 @@ namespace xna {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!device.impl || !device.impl->_device || !device.impl->_context) {
|
if (!device.impl || !device.impl->_device || !device.impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<ID3D11SamplerState*> states(samplers.size());
|
std::vector<ID3D11SamplerState*> states(samplers.size());
|
||||||
@ -59,7 +59,7 @@ namespace xna {
|
|||||||
const auto& current = samplers[0];
|
const auto& current = samplers[0];
|
||||||
|
|
||||||
if (!current || !current->impl || !current->impl->_samplerState)
|
if (!current || !current->impl || !current->impl->_samplerState)
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
|
|
||||||
states[i] = current->impl->_samplerState.Get();
|
states[i] = current->impl->_samplerState.Get();
|
||||||
states[i]->AddRef();
|
states[i]->AddRef();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/csharp/stream.hpp"
|
#include "xna/csharp/stream.hpp"
|
||||||
|
|
||||||
using DxSoundEffect = DirectX::SoundEffect;
|
using DxSoundEffect = DirectX::SoundEffect;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "xna/graphics/viewport.hpp"
|
#include "xna/graphics/viewport.hpp"
|
||||||
#include "xna/graphics/blendstate.hpp"
|
#include "xna/graphics/blendstate.hpp"
|
||||||
#include "xna/graphics/depthstencilstate.hpp"
|
#include "xna/graphics/depthstencilstate.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
using DxSpriteBatch = DirectX::SpriteBatch;
|
using DxSpriteBatch = DirectX::SpriteBatch;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "xna/graphics/adapter.hpp"
|
#include "xna/graphics/adapter.hpp"
|
||||||
#include "xna/graphics/swapchain.hpp"
|
#include "xna/graphics/swapchain.hpp"
|
||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
#include "xna/graphics/device.hpp"
|
#include "xna/graphics/device.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
@ -51,7 +51,7 @@ namespace xna {
|
|||||||
|
|
||||||
bool SwapChain::Initialize() {
|
bool SwapChain::Initialize() {
|
||||||
if (!impl || !m_device || !m_device->impl->_device) {
|
if (!impl || !m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto parameters = m_device->impl->_presentationParameters;
|
const auto parameters = m_device->impl->_presentationParameters;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
Texture2D::~Texture2D() {
|
Texture2D::~Texture2D() {
|
||||||
@ -40,26 +40,26 @@ namespace xna {
|
|||||||
bool Texture2D::Initialize()
|
bool Texture2D::Initialize()
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device) {
|
if (!m_device || !m_device->impl->_device) {
|
||||||
Exception::Throw(ExMessage::InitializeComponent);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.ReleaseAndGetAddressOf());
|
auto hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
comptr<ID3D11Resource> resource = nullptr;
|
comptr<ID3D11Resource> resource = nullptr;
|
||||||
hr = impl->dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
hr = impl->dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, &impl->dxShaderResource);
|
hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, &impl->dxShaderResource);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -112,7 +112,7 @@ namespace xna {
|
|||||||
auto hr = device.impl->_device->CreateTexture2D(&impl.dxDescription, nullptr, impl.dxTexture2D.ReleaseAndGetAddressOf());
|
auto hr = device.impl->_device->CreateTexture2D(&impl.dxDescription, nullptr, impl.dxTexture2D.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ namespace xna {
|
|||||||
auto hr = impl.dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
auto hr = impl.dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr int R8G8B8A8U_BYTE_SIZE = 4;
|
constexpr int R8G8B8A8U_BYTE_SIZE = 4;
|
||||||
@ -130,7 +130,7 @@ namespace xna {
|
|||||||
hr = device.impl->_device->CreateShaderResourceView(resource.Get(), &impl.dxShaderDescription, impl.dxShaderResource.ReleaseAndGetAddressOf());
|
hr = device.impl->_device->CreateShaderResourceView(resource.Get(), &impl.dxShaderDescription, impl.dxShaderResource.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl.dxTexture2D->GetDesc(&impl.dxDescription);
|
impl.dxTexture2D->GetDesc(&impl.dxDescription);
|
||||||
@ -141,7 +141,7 @@ namespace xna {
|
|||||||
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount)
|
void Texture2D::SetData(std::vector<Uint> const& data, size_t startIndex, size_t elementCount)
|
||||||
{
|
{
|
||||||
if (!impl || !m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
if (!impl || !m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
internalSetData(*impl, *m_device, data.data());
|
internalSetData(*impl, *m_device, data.data());
|
||||||
@ -150,7 +150,7 @@ namespace xna {
|
|||||||
void Texture2D::SetData(std::vector<Byte> const& data, size_t startIndex, size_t elementCount)
|
void Texture2D::SetData(std::vector<Byte> const& data, size_t startIndex, size_t elementCount)
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UINT> finalData(elementCount / 4);
|
std::vector<UINT> finalData(elementCount / 4);
|
||||||
@ -171,7 +171,7 @@ namespace xna {
|
|||||||
void Texture2D::SetData(Int level, Rectangle* rect, std::vector<Byte> const& data, size_t startIndex, size_t elementCount)
|
void Texture2D::SetData(Int level, Rectangle* rect, std::vector<Byte> const& data, size_t startIndex, size_t elementCount)
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UINT> finalData(elementCount / 4);
|
std::vector<UINT> finalData(elementCount / 4);
|
||||||
@ -190,7 +190,7 @@ namespace xna {
|
|||||||
auto hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.GetAddressOf());
|
auto hr = m_device->impl->_device->CreateTexture2D(&impl->dxDescription, nullptr, impl->dxTexture2D.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ namespace xna {
|
|||||||
auto hr = impl->dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
auto hr = impl->dxTexture2D->QueryInterface(IID_ID3D11Resource, (void**)resource.GetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D11_BOX box{};
|
D3D11_BOX box{};
|
||||||
@ -220,7 +220,7 @@ namespace xna {
|
|||||||
hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf());
|
hr = m_device->impl->_device->CreateShaderResourceView(resource.Get(), &impl->dxShaderDescription, impl->dxShaderResource.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(ExMessage::CreateComponent);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl->dxTexture2D->GetDesc(&impl->dxDescription);
|
impl->dxTexture2D->GetDesc(&impl->dxDescription);
|
||||||
@ -229,7 +229,7 @@ namespace xna {
|
|||||||
void Texture2D::SetData(std::vector<Color> const& data, size_t startIndex, size_t elementCount)
|
void Texture2D::SetData(std::vector<Color> const& data, size_t startIndex, size_t elementCount)
|
||||||
{
|
{
|
||||||
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
if (!m_device || !m_device->impl->_device || !m_device->impl->_context) {
|
||||||
Exception::Throw(ExMessage::InvalidOperation);
|
Exception::Throw(Exception::INVALID_OPERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<UINT> finalData(elementCount);
|
std::vector<UINT> finalData(elementCount);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "xna/platform-dx/dx.hpp"
|
#include "xna/xna-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
GameWindow::GameWindow() {
|
GameWindow::GameWindow() {
|
||||||
|
@ -5,35 +5,34 @@
|
|||||||
#include "../csharp/stream.hpp"
|
#include "../csharp/stream.hpp"
|
||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
#include "reader.hpp"
|
#include "reader.hpp"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//The run-time component which loads managed objects from the binary files produced by the design time content pipeline.
|
//The run-time component which loads managed objects from the binary files produced by the design time content pipeline.
|
||||||
class ContentManager : public std::enable_shared_from_this<ContentManager> {
|
class ContentManager : public std::enable_shared_from_this<ContentManager> {
|
||||||
public:
|
public:
|
||||||
ContentManager(sptr<IServiceProvider> const& services) :
|
ContentManager(sptr<IServiceProvider> const& services) :
|
||||||
_rootDirectory("") {
|
rootDirectory("") {
|
||||||
_services = services;
|
serviceProvider = services;
|
||||||
};
|
};
|
||||||
|
|
||||||
ContentManager(sptr<IServiceProvider> const& services, String const& rootDirectory) :
|
ContentManager(sptr<IServiceProvider> const& services, String const& rootDirectory) :
|
||||||
_rootDirectory(rootDirectory){
|
rootDirectory(rootDirectory){
|
||||||
_services = services;
|
serviceProvider = services;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Gets the service provider associated with the ContentManager.
|
//Gets the service provider associated with the ContentManager.
|
||||||
sptr<IServiceProvider> ServiceProvider() const {
|
sptr<IServiceProvider> ServiceProvider() const {
|
||||||
return _services;
|
return serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gets or sets the root directory associated with this ContentManager.
|
//Gets or sets the root directory associated with this ContentManager.
|
||||||
constexpr String RootDirectory() const {
|
constexpr String RootDirectory() const {
|
||||||
return _rootDirectory;
|
return rootDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gets or sets the root directory associated with this ContentManager.
|
//Gets or sets the root directory associated with this ContentManager.
|
||||||
void RootDirectory(String const& value) {
|
void RootDirectory(String const& value) {
|
||||||
_rootDirectory = value;
|
rootDirectory = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Loads an asset that has been processed by the Content Pipeline.
|
//Loads an asset that has been processed by the Content Pipeline.
|
||||||
@ -45,8 +44,8 @@ namespace xna {
|
|||||||
|
|
||||||
if constexpr (XnaHelper::is_shared_ptr<T>::value) {
|
if constexpr (XnaHelper::is_shared_ptr<T>::value) {
|
||||||
|
|
||||||
if (_loadedAssets.contains(assetName)) {
|
if (loadedAssets.contains(assetName)) {
|
||||||
auto& voidAsset = _loadedAssets[assetName];
|
auto& voidAsset = loadedAssets[assetName];
|
||||||
using TYPE = T::element_type;
|
using TYPE = T::element_type;
|
||||||
auto asset = reinterpret_pointer_cast<TYPE>(voidAsset);
|
auto asset = reinterpret_pointer_cast<TYPE>(voidAsset);
|
||||||
return asset;
|
return asset;
|
||||||
@ -58,7 +57,7 @@ namespace xna {
|
|||||||
if constexpr (XnaHelper::is_shared_ptr<T>::value) {
|
if constexpr (XnaHelper::is_shared_ptr<T>::value) {
|
||||||
|
|
||||||
if(obj2)
|
if(obj2)
|
||||||
_loadedAssets.emplace( assetName, obj2 );
|
loadedAssets.emplace( assetName, obj2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj2;
|
return obj2;
|
||||||
@ -66,12 +65,12 @@ namespace xna {
|
|||||||
|
|
||||||
//Disposes all data that was loaded by this ContentManager.
|
//Disposes all data that was loaded by this ContentManager.
|
||||||
void Unload() {
|
void Unload() {
|
||||||
_loadedAssets.clear();
|
loadedAssets.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//Gets the service provider associated with the main Game.
|
//Gets the service provider associated with the main Game.
|
||||||
static sptr<IServiceProvider> GameServiceProvider() {
|
static sptr<IServiceProvider> GameServiceProvider() {
|
||||||
return _gameServices;
|
return mainGameService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -95,11 +94,11 @@ namespace xna {
|
|||||||
friend class ContentReader;
|
friend class ContentReader;
|
||||||
friend class Game;
|
friend class Game;
|
||||||
|
|
||||||
String _rootDirectory;
|
String rootDirectory;
|
||||||
sptr<IServiceProvider> _services = nullptr;
|
sptr<IServiceProvider> serviceProvider = nullptr;
|
||||||
std::map<String, sptr<void>> _loadedAssets;
|
std::map<String, sptr<void>> loadedAssets;
|
||||||
|
|
||||||
inline static sptr<IServiceProvider> _gameServices = nullptr;
|
inline static sptr<IServiceProvider> mainGameService = nullptr;
|
||||||
inline const static String contentExtension = ".xnb";
|
inline const static String contentExtension = ".xnb";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace xna {
|
|||||||
|
|
||||||
// Reads a single object from the current stream.
|
// Reads a single object from the current stream.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto ReadObject(T existingInstance);
|
auto ReadObject(T& existingInstance);
|
||||||
|
|
||||||
// Reads a single object from the current stream.
|
// Reads a single object from the current stream.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -29,7 +29,7 @@ namespace xna {
|
|||||||
|
|
||||||
// Reads a single object from the current stream.
|
// Reads a single object from the current stream.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto ReadObject(ContentTypeReader& typeReader, T existingInstance);
|
auto ReadObject(ContentTypeReader& typeReader, T& existingInstance);
|
||||||
|
|
||||||
//Reads a Vector2 value from the current stream.
|
//Reads a Vector2 value from the current stream.
|
||||||
Vector2 ReadVector2();
|
Vector2 ReadVector2();
|
||||||
@ -44,9 +44,9 @@ namespace xna {
|
|||||||
//Reads a Color value from the currently open stream.
|
//Reads a Color value from the currently open stream.
|
||||||
Color ReadColor();
|
Color ReadColor();
|
||||||
//Reads a float value from the currently open stream.
|
//Reads a float value from the currently open stream.
|
||||||
float ReadSingle();
|
float ReadSingle() override;
|
||||||
//Reads a double value from the currently open stream.
|
//Reads a double value from the currently open stream.
|
||||||
double ReadDouble();
|
double ReadDouble() override;
|
||||||
|
|
||||||
//Gets the name of the asset currently being read by this ContentReader.
|
//Gets the name of the asset currently being read by this ContentReader.
|
||||||
constexpr String AssetName() const {
|
constexpr String AssetName() const {
|
||||||
@ -77,10 +77,10 @@ namespace xna {
|
|||||||
auto ReadObjectInternal(std::any& existingInstance);
|
auto ReadObjectInternal(std::any& existingInstance);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto ReadObjectInternal(ContentTypeReader& typeReader, std::any& existingInstance);
|
auto ReadObjectInternal(ContentTypeReader& typeReader, Object& existingInstance);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
auto InvokeReader(ContentTypeReader& reader, std::any& existingInstance);
|
auto InvokeReader(ContentTypeReader& reader, Object& existingInstance);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sptr<xna::ContentManager> _contentManager = nullptr;
|
sptr<xna::ContentManager> _contentManager = nullptr;
|
||||||
@ -93,10 +93,13 @@ namespace xna {
|
|||||||
static constexpr Ushort XnbCompressedVersion = 32773;
|
static constexpr Ushort XnbCompressedVersion = 32773;
|
||||||
static constexpr Ushort XnbVersion = 5;
|
static constexpr Ushort XnbVersion = 5;
|
||||||
static constexpr Int XnbVersionProfileShift = 8;
|
static constexpr Int XnbVersionProfileShift = 8;
|
||||||
|
static constexpr Char PlatformLabel = 'w';
|
||||||
|
static constexpr Int XnbPrologueSize = 10;
|
||||||
|
static constexpr Int XnbCompressedPrologueSize = 14;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline auto ContentReader::ReadObjectInternal(std::any& existingInstance)
|
inline auto ContentReader::ReadObjectInternal(Object& existingInstance)
|
||||||
{
|
{
|
||||||
const auto num = Read7BitEncodedInt();
|
const auto num = Read7BitEncodedInt();
|
||||||
|
|
||||||
@ -107,16 +110,16 @@ namespace xna {
|
|||||||
const auto index = num - 1;
|
const auto index = num - 1;
|
||||||
|
|
||||||
if (index >= typeReaders.size()) {
|
if (index >= typeReaders.size()) {
|
||||||
throw std::runtime_error("ContentReader::ReadObjectInternal: Bad xbn.");
|
Exception::Throw(Exception::BAD_XNB);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto reader = typeReaders[index];
|
auto& reader = typeReaders[index];
|
||||||
|
|
||||||
return InvokeReader<T>(*reader, existingInstance);
|
return InvokeReader<T>(*reader, existingInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline auto ContentReader::InvokeReader(ContentTypeReader& reader, std::any& existingInstance)
|
inline auto ContentReader::InvokeReader(ContentTypeReader& reader, Object& existingInstance)
|
||||||
{
|
{
|
||||||
auto contentTypeReader = reinterpret_cast<ContentTypeReaderT<T>*>(&reader);
|
auto contentTypeReader = reinterpret_cast<ContentTypeReaderT<T>*>(&reader);
|
||||||
T objB;
|
T objB;
|
||||||
@ -126,6 +129,9 @@ namespace xna {
|
|||||||
objB = contentTypeReader->Read(*this, existingInstance1);
|
objB = contentTypeReader->Read(*this, existingInstance1);
|
||||||
return objB;
|
return objB;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Exception::Throw(Exception::NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
return XnaHelper::ReturnDefaultOrNull<T>();
|
return XnaHelper::ReturnDefaultOrNull<T>();
|
||||||
}
|
}
|
||||||
@ -146,9 +152,9 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline auto ContentReader::ReadObject(T existingInstance)
|
inline auto ContentReader::ReadObject(T& existingInstance)
|
||||||
{
|
{
|
||||||
return ReadObjectInternal<T>(std::any(existingInstance));
|
return ReadObjectInternal<T>(Object(existingInstance));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@ -159,17 +165,18 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline auto ContentReader::ReadObject(ContentTypeReader& typeReader, T existingInstance)
|
inline auto ContentReader::ReadObject(ContentTypeReader& typeReader, T& existingInstance)
|
||||||
{
|
{
|
||||||
return ReadObjectInternal<T>(typeReader, std::any(existingInstance));
|
return ReadObjectInternal<T>(typeReader, std::any(existingInstance));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline auto ContentReader::ReadObjectInternal(ContentTypeReader& typeReader, std::any& existingInstance)
|
inline auto ContentReader::ReadObjectInternal(ContentTypeReader& typeReader, Object& existingInstance)
|
||||||
{
|
{
|
||||||
return typeReader.TargetIsValueType
|
if (typeReader.TargetIsValueType)
|
||||||
? InvokeReader<T>(typeReader, existingInstance)
|
return InvokeReader<T>(typeReader, existingInstance);
|
||||||
: ReadObjectInternal<T>(existingInstance);
|
|
||||||
|
ReadObjectInternal<T>(existingInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,13 @@
|
|||||||
#include "../reader.hpp"
|
#include "../reader.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class ObjectReader : public ContentTypeReaderT<Object> {
|
class ObjectReader : public ContentTypeReader {
|
||||||
public:
|
public:
|
||||||
ObjectReader() : ContentTypeReaderT(typeof<Object>()) {}
|
ObjectReader() : ContentTypeReader(typeof<Object>()) {}
|
||||||
|
|
||||||
virtual Object Read(ContentReader& input, Object& existingInstance) override {
|
virtual Object Read(ContentReader& input, Object& existingInstance) override {
|
||||||
|
Exception::Throw(Exception::NOT_IMPLEMENTED);
|
||||||
|
|
||||||
return Object();
|
return Object();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,53 +8,47 @@ namespace xna {
|
|||||||
//A simplified port of the System.IO.BinaryReader class.
|
//A simplified port of the System.IO.BinaryReader class.
|
||||||
class BinaryReader {
|
class BinaryReader {
|
||||||
public:
|
public:
|
||||||
BinaryReader(sptr<Stream> const& input) {
|
BinaryReader(sptr<Stream> const& input);
|
||||||
if (!input)
|
|
||||||
throw std::invalid_argument("input is null.");
|
|
||||||
|
|
||||||
stream = input;
|
|
||||||
buffer = std::vector<Byte>(bufferLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Returns the next available character and does not advance the byte or character position.
|
//Returns the next available character and does not advance the byte or character position.
|
||||||
Int PeekChar();
|
Int PeekChar();
|
||||||
//Reads bytes from the underlying stream and advances the current position of the stream.
|
//Reads bytes from the underlying stream and advances the current position of the stream.
|
||||||
Int Read();
|
virtual Int Read();
|
||||||
//Reads a Boolean value from the current stream and advances the current position of the stream by one byte.
|
//Reads a Boolean value from the current stream and advances the current position of the stream by one byte.
|
||||||
bool ReadBoolean();
|
virtual bool ReadBoolean();
|
||||||
//Reads the next byte from the current stream and advances the current position of the stream by one byte.
|
//Reads the next byte from the current stream and advances the current position of the stream by one byte.
|
||||||
Byte ReadByte();
|
virtual Byte ReadByte();
|
||||||
//Reads a signed byte from this stream and advances the current position of the stream by one byte.
|
//Reads a signed byte from this stream and advances the current position of the stream by one byte.
|
||||||
Sbyte ReadSByte();
|
virtual Sbyte ReadSByte();
|
||||||
//Reads the next character from the current stream and advances the current position of the stream.
|
//Reads the next character from the current stream and advances the current position of the stream.
|
||||||
Char ReadChar();
|
virtual Char ReadChar();
|
||||||
//Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.
|
//Reads a 2-byte signed integer from the current stream and advances the current position of the stream by two bytes.
|
||||||
Short ReadInt16();
|
virtual Short ReadInt16();
|
||||||
//Reads a 2-byte unsigned integer from the current stream and advances the position of the stream by two bytes.
|
//Reads a 2-byte unsigned integer from the current stream and advances the position of the stream by two bytes.
|
||||||
Ushort ReadUInt16();
|
virtual Ushort ReadUInt16();
|
||||||
//Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.
|
//Reads a 4-byte signed integer from the current stream and advances the current position of the stream by four bytes.
|
||||||
Int ReadInt32();
|
virtual Int ReadInt32();
|
||||||
//Reads a 4-byte unsigned integer from the current stream and advances the position of the stream by four bytes.
|
//Reads a 4-byte unsigned integer from the current stream and advances the position of the stream by four bytes.
|
||||||
Uint ReadUInt32();
|
virtual Uint ReadUInt32();
|
||||||
//Reads a 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.
|
//Reads a 8-byte signed integer from the current stream and advances the current position of the stream by eight bytes.
|
||||||
Long ReadInt64();
|
virtual Long ReadInt64();
|
||||||
//Reads a 8-byte unsigned integer from the current stream and advances the position of the stream by eight bytes.
|
//Reads a 8-byte unsigned integer from the current stream and advances the position of the stream by eight bytes.
|
||||||
Ulong ReadUInt64();
|
virtual Ulong ReadUInt64();
|
||||||
//Reads a 4-byte floating point value from the current stream and advances the current position of the stream by four bytes.
|
//Reads a 4-byte floating point value from the current stream and advances the current position of the stream by four bytes.
|
||||||
float ReadSingle();
|
virtual float ReadSingle();
|
||||||
//Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes.
|
//Reads an 8-byte floating point value from the current stream and advances the current position of the stream by eight bytes.
|
||||||
double ReadDouble();
|
virtual double ReadDouble();
|
||||||
//Reads a string from the current stream.
|
//Reads a string from the current stream.
|
||||||
std::string ReadString();
|
virtual std::string ReadString();
|
||||||
|
|
||||||
//Reads chars from the underlying stream and advances the current position of the stream.
|
//Reads chars from the underlying stream and advances the current position of the stream.
|
||||||
Int Read(std::vector<Char>& buffer, size_t index, size_t count);
|
virtual Int Read(std::vector<Char>& buffer, size_t index, size_t count);
|
||||||
//Reads bytes from the underlying stream and advances the current position of the stream.
|
//Reads bytes from the underlying stream and advances the current position of the stream.
|
||||||
Int Read(std::vector<Byte>& buffer, size_t index, size_t count);
|
virtual Int Read(std::vector<Byte>& buffer, size_t index, size_t count);
|
||||||
|
|
||||||
// Reads the specified number of bytes from the current stream into a byte array
|
// Reads the specified number of bytes from the current stream into a byte array
|
||||||
// and advances the current position by that number of bytes.
|
// and advances the current position by that number of bytes.
|
||||||
std::vector<Byte> ReadBytes(size_t count);
|
virtual std::vector<Byte> ReadBytes(size_t count);
|
||||||
|
|
||||||
// Reads a 32-bit integer in compressed format.
|
// Reads a 32-bit integer in compressed format.
|
||||||
// This function may throw a std::format_error exception.
|
// This function may throw a std::format_error exception.
|
||||||
@ -64,6 +58,16 @@ namespace xna {
|
|||||||
// This function may throw a std::format_error exception.
|
// This function may throw a std::format_error exception.
|
||||||
Long Read7BitEncodedInt64();
|
Long Read7BitEncodedInt64();
|
||||||
|
|
||||||
|
//Exposes access to the underlying stream of the BinaryReader.
|
||||||
|
virtual inline sptr<Stream> BaseStream() const {
|
||||||
|
return stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Closes the current reader and the underlying stream.
|
||||||
|
virtual inline void Close() {
|
||||||
|
stream = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Int InternalReadOneChar();
|
Int InternalReadOneChar();
|
||||||
void FillBuffer(Int numBytes);
|
void FillBuffer(Int numBytes);
|
||||||
@ -79,18 +83,15 @@ namespace xna {
|
|||||||
std::vector<Char> charBuffer;
|
std::vector<Char> charBuffer;
|
||||||
|
|
||||||
//bool m2BytesPerChar{ false };
|
//bool m2BytesPerChar{ false };
|
||||||
};
|
};
|
||||||
|
|
||||||
//A simplified port of the System.IO.BinaryWriter class.
|
//A simplified port of the System.IO.BinaryWriter class.
|
||||||
class BinaryWriter {
|
class BinaryWriter {
|
||||||
public:
|
public:
|
||||||
BinaryWriter(sptr<Stream> const& stream) {
|
BinaryWriter(sptr<Stream> const& stream);
|
||||||
if (!stream)
|
|
||||||
throw std::invalid_argument("stream is null.");
|
|
||||||
|
|
||||||
_stream = stream;
|
protected:
|
||||||
_buffer = std::vector<Byte>(16);
|
BinaryWriter() = default;
|
||||||
}
|
|
||||||
|
|
||||||
//Sets the position within the current stream.
|
//Sets the position within the current stream.
|
||||||
Long Seek(Int offset, SeekOrigin origin);
|
Long Seek(Int offset, SeekOrigin origin);
|
||||||
@ -99,32 +100,56 @@ namespace xna {
|
|||||||
// Writes a value to the current stream.
|
// Writes a value to the current stream.
|
||||||
//
|
//
|
||||||
|
|
||||||
void Write(bool value);
|
//Writes a value to the current stream.
|
||||||
void Write(Byte value);
|
virtual void Write(bool value);
|
||||||
void Write(Sbyte value);
|
//Writes a value to the current stream.
|
||||||
void Write(Byte const* buffer, Int bufferLength);
|
virtual void Write(Byte value);
|
||||||
void Write(std::vector<Byte> const& buffer);
|
//Writes a value to the current stream.
|
||||||
void Write(Byte const* buffer, Int bufferLength, Int index, Int count);
|
virtual void Write(Sbyte value);
|
||||||
void Write(std::vector<Byte> const& buffer, Int index, Int count);
|
//Writes a value to the current stream.
|
||||||
void Write(Char ch);
|
virtual void Write(Byte const* buffer, Int bufferLength);
|
||||||
void Write(double value);
|
//Writes a value to the current stream.
|
||||||
void Write(Short value);
|
virtual void Write(std::vector<Byte> const& buffer);
|
||||||
void Write(Ushort value);
|
//Writes a value to the current stream.
|
||||||
void Write(Int value);
|
virtual void Write(Byte const* buffer, Int bufferLength, Int index, Int count);
|
||||||
void Write(Uint value);
|
//Writes a value to the current stream.
|
||||||
void Write(Long value);
|
virtual void Write(std::vector<Byte> const& buffer, Int index, Int count);
|
||||||
void Write(Ulong value);
|
//Writes a value to the current stream.
|
||||||
void Write(float value);
|
virtual void Write(Char ch);
|
||||||
void Write(std::string const& value);
|
//Writes a value to the current stream.
|
||||||
void Write(const char* _string, size_t stringLength);
|
virtual void Write(double value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Short value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Ushort value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Int value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Uint value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Long value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(Ulong value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(float value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(std::string const& value);
|
||||||
|
//Writes a value to the current stream.
|
||||||
|
virtual void Write(const char* _string, size_t stringLength);
|
||||||
|
|
||||||
|
//Exposes access to the underlying stream of the BinaryWriter.
|
||||||
|
virtual inline sptr<Stream> BaseStream() const {
|
||||||
|
return OutStream;
|
||||||
|
}
|
||||||
|
|
||||||
//Writes a 32-bit integer in a compressed format.
|
//Writes a 32-bit integer in a compressed format.
|
||||||
void Write7BitEncodedInt(Int value);
|
void Write7BitEncodedInt(Int value);
|
||||||
|
|
||||||
//void Write7BitEncodedInt64(Long value);
|
//void Write7BitEncodedInt64(Long value);
|
||||||
|
protected:
|
||||||
|
sptr<Stream> OutStream = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sptr<Stream> _stream = nullptr;
|
|
||||||
std::vector<Byte> _buffer;
|
std::vector<Byte> _buffer;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#ifndef XNA_CSHARP_OBJECT_HPP
|
|
||||||
#define XNA_CSHARP_OBJECT_HPP
|
|
||||||
|
|
||||||
#include "../default.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
class Object {
|
|
||||||
public:
|
|
||||||
virtual size_t GetHashCode() const;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,12 +1,15 @@
|
|||||||
#ifndef XNA_CSHARP_STREAM_HPP
|
#ifndef XNA_CSHARP_STREAM_HPP
|
||||||
#define XNA_CSHARP_STREAM_HPP
|
#define XNA_CSHARP_STREAM_HPP
|
||||||
|
|
||||||
#include "../types.hpp"
|
#include "../default.hpp"
|
||||||
#include "../enums.hpp"
|
|
||||||
#include <fstream>
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
enum class SeekOrigin {
|
||||||
|
Begin,
|
||||||
|
Current,
|
||||||
|
End,
|
||||||
|
};
|
||||||
|
|
||||||
//A simplified port of the System.IO.Stream.
|
//A simplified port of the System.IO.Stream.
|
||||||
//Provides a generic view of a sequence of bytes. This is an abstract class.
|
//Provides a generic view of a sequence of bytes. This is an abstract class.
|
||||||
class Stream {
|
class Stream {
|
||||||
@ -18,23 +21,20 @@ namespace xna {
|
|||||||
virtual Long Position() = 0;
|
virtual Long Position() = 0;
|
||||||
//Closes the current stream and releases any resources
|
//Closes the current stream and releases any resources
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
virtual bool IsClosed() = 0;
|
|
||||||
//Sets the position within the current stream.
|
//Sets the position within the current stream.
|
||||||
virtual Long Seek(Long offset, SeekOrigin const& origin) = 0;
|
virtual Long Seek(Long offset, SeekOrigin const& origin) = 0;
|
||||||
|
|
||||||
//
|
|
||||||
//Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
//Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
||||||
//
|
|
||||||
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) = 0;
|
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) = 0;
|
||||||
|
//Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
|
||||||
virtual Int Read(std::vector<Byte>& buffer, Int offset, Int count) = 0;
|
virtual Int Read(std::vector<Byte>& buffer, Int offset, Int count) = 0;
|
||||||
|
|
||||||
//Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
|
//Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.
|
||||||
virtual Int ReadByte() = 0;
|
virtual Int ReadByte() = 0;
|
||||||
|
|
||||||
//
|
//Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
|
||||||
//When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
|
|
||||||
//
|
|
||||||
virtual void Write(Byte const* buffer, Int bufferLength, Int offset, Int count) = 0;
|
virtual void Write(Byte const* buffer, Int bufferLength, Int offset, Int count) = 0;
|
||||||
|
//Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.
|
||||||
virtual void Write(std::vector<Byte> const& buffer, Int offset, Int count) = 0;
|
virtual void Write(std::vector<Byte> const& buffer, Int offset, Int count) = 0;
|
||||||
|
|
||||||
//Writes a byte to the current position in the stream and advances the position within the stream by one byte.
|
//Writes a byte to the current position in the stream and advances the position within the stream by one byte.
|
||||||
@ -49,6 +49,10 @@ namespace xna {
|
|||||||
constexpr MemoryStream(std::vector<Byte> const& bytes):
|
constexpr MemoryStream(std::vector<Byte> const& bytes):
|
||||||
_buffer(bytes), _length(bytes.size()){}
|
_buffer(bytes), _length(bytes.size()){}
|
||||||
|
|
||||||
|
~MemoryStream() override {
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
constexpr MemoryStream(Int capacity) :
|
constexpr MemoryStream(Int capacity) :
|
||||||
_buffer(static_cast<size_t>(capacity)),
|
_buffer(static_cast<size_t>(capacity)),
|
||||||
_length(capacity > 0 ? capacity : 0){}
|
_length(capacity > 0 ? capacity : 0){}
|
||||||
@ -70,11 +74,7 @@ namespace xna {
|
|||||||
virtual constexpr void Close() override {
|
virtual constexpr void Close() override {
|
||||||
_closed = true;
|
_closed = true;
|
||||||
_buffer = std::vector<Byte>();
|
_buffer = std::vector<Byte>();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr bool IsClosed() override {
|
|
||||||
return _closed;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Long Seek(Long offset, SeekOrigin const& origin) override;
|
virtual Long Seek(Long offset, SeekOrigin const& origin) override;
|
||||||
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) override;
|
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) override;
|
||||||
@ -90,6 +90,7 @@ namespace xna {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<Byte> _buffer;
|
std::vector<Byte> _buffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Int _position{ 0 };
|
Int _position{ 0 };
|
||||||
Int _origin{ 0 };
|
Int _origin{ 0 };
|
||||||
@ -103,7 +104,7 @@ namespace xna {
|
|||||||
FileStream(String const& path, FileMode fileMode);
|
FileStream(String const& path, FileMode fileMode);
|
||||||
FileStream(String const& path);
|
FileStream(String const& path);
|
||||||
|
|
||||||
~FileStream() {
|
~FileStream() override {
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,11 +116,7 @@ namespace xna {
|
|||||||
|
|
||||||
if(_fstream.is_open())
|
if(_fstream.is_open())
|
||||||
_fstream.close();
|
_fstream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline virtual constexpr bool IsClosed() override {
|
|
||||||
return _closed;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Long Seek(Long offset, SeekOrigin const& origin) override;
|
virtual Long Seek(Long offset, SeekOrigin const& origin) override;
|
||||||
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) override;
|
virtual Int Read(Byte* buffer, Int bufferLength, Int offset, Int count) override;
|
||||||
|
@ -2,13 +2,12 @@
|
|||||||
#define XNA_CSHARP_TYPE_HPP
|
#define XNA_CSHARP_TYPE_HPP
|
||||||
|
|
||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
#include "object.hpp"
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class Type : public Object {
|
class Type {
|
||||||
public:
|
public:
|
||||||
constexpr String FullName() const { return fullName; }
|
constexpr String FullName() const { return fullName; }
|
||||||
constexpr bool IsClass() const { return isClass; }
|
constexpr bool IsClass() const { return isClass; }
|
||||||
@ -17,7 +16,7 @@ namespace xna {
|
|||||||
constexpr bool IsPrimitive() const { return isPrimitive; }
|
constexpr bool IsPrimitive() const { return isPrimitive; }
|
||||||
constexpr bool IsPointer() const { return isPointer; }
|
constexpr bool IsPointer() const { return isPointer; }
|
||||||
|
|
||||||
virtual size_t GetHashCode() const;
|
size_t GetHashCode() const;
|
||||||
|
|
||||||
constexpr bool operator==(const Type& other) const {
|
constexpr bool operator==(const Type& other) const {
|
||||||
return
|
return
|
||||||
|
@ -1,5 +1,201 @@
|
|||||||
#include "types.hpp"
|
#ifndef XNA_DEFAULT_HPP
|
||||||
#include "forward.hpp"
|
#define XNA_DEFAULT_HPP
|
||||||
#include "enums.hpp"
|
|
||||||
|
#include <any>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <filesystem>
|
||||||
|
#include <fstream>
|
||||||
|
#include <limits>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "enumerations.hpp"
|
||||||
|
#include "exception.hpp"
|
||||||
#include "helpers.hpp"
|
#include "helpers.hpp"
|
||||||
#include "exception.hpp"
|
|
||||||
|
namespace xna {
|
||||||
|
|
||||||
|
//
|
||||||
|
//C# nameof
|
||||||
|
//
|
||||||
|
#define nameof(name) std::string(#name)
|
||||||
|
|
||||||
|
//
|
||||||
|
// C# standard types
|
||||||
|
//
|
||||||
|
|
||||||
|
using Sbyte = int8_t;
|
||||||
|
using Byte = uint8_t;
|
||||||
|
using Short = int16_t;
|
||||||
|
using Ushort = uint16_t;
|
||||||
|
using Int = int32_t;
|
||||||
|
using Uint = uint32_t;
|
||||||
|
using Long = int64_t;
|
||||||
|
using Ulong = uint64_t;
|
||||||
|
using Char = char16_t;
|
||||||
|
|
||||||
|
//
|
||||||
|
// C# Min and Max Value
|
||||||
|
//
|
||||||
|
|
||||||
|
constexpr Sbyte SbyteMaxValue = (std::numeric_limits<Sbyte>::max)();
|
||||||
|
constexpr Sbyte SbyteMinValue = (std::numeric_limits<Sbyte>::min)();
|
||||||
|
constexpr Byte ByteMaxValue = (std::numeric_limits<Byte>::max)();
|
||||||
|
constexpr Byte ByteMinValue = (std::numeric_limits<Byte>::min)();
|
||||||
|
constexpr Short ShortMaxValue = (std::numeric_limits<Short>::max)();
|
||||||
|
constexpr Short ShortMinValue = (std::numeric_limits<Short>::min)();
|
||||||
|
constexpr Ushort UshortMaxValue = (std::numeric_limits<Ushort>::max)();
|
||||||
|
constexpr Ushort UshortMinValue = (std::numeric_limits<Ushort>::min)();
|
||||||
|
constexpr Int IntMaxValue = (std::numeric_limits<Int>::max)();
|
||||||
|
constexpr Int IntMinValue = (std::numeric_limits<Int>::min)();
|
||||||
|
constexpr Uint UintMaxValue = (std::numeric_limits<Uint>::max)();
|
||||||
|
constexpr Uint UintMinValue = (std::numeric_limits<Uint>::min)();
|
||||||
|
constexpr Long LongMaxValue = (std::numeric_limits<Long>::max)();
|
||||||
|
constexpr Long LongMinValue = (std::numeric_limits<Long>::min)();
|
||||||
|
constexpr Ulong UlongMaxValue = (std::numeric_limits<Ulong>::max)();
|
||||||
|
constexpr Ulong UlongMinValue = (std::numeric_limits<Ulong>::min)();
|
||||||
|
constexpr Char CharMaxValue = (std::numeric_limits<Char>::max)();
|
||||||
|
constexpr Char CharMinValue = (std::numeric_limits<Char>::min)();
|
||||||
|
constexpr float FloatMaxValue = (std::numeric_limits<float>::max)();
|
||||||
|
constexpr float FloatMinValue = (std::numeric_limits<float>::min)();
|
||||||
|
constexpr double DoubleMaxValue = (std::numeric_limits<double>::max)();
|
||||||
|
constexpr double DoubleMinValue = (std::numeric_limits<double>::min)();
|
||||||
|
|
||||||
|
//
|
||||||
|
// C# Object
|
||||||
|
//
|
||||||
|
|
||||||
|
//Same as std::any
|
||||||
|
using Object = std::any;
|
||||||
|
|
||||||
|
//
|
||||||
|
// About strings: https://stackoverflow.com/questions/402283/stdwstring-vs-stdstring
|
||||||
|
//
|
||||||
|
|
||||||
|
//Same as std::string
|
||||||
|
using String = std::string;
|
||||||
|
//Same as std::wstring
|
||||||
|
using WString = std::wstring;
|
||||||
|
|
||||||
|
//Same as std::shared_ptr
|
||||||
|
template <typename T>
|
||||||
|
using sptr = std::shared_ptr<T>;
|
||||||
|
//Same as std::weak_ptr
|
||||||
|
template <typename T>
|
||||||
|
using wptr = std::weak_ptr<T>;
|
||||||
|
//Same as std::unique_ptr
|
||||||
|
template <typename T>
|
||||||
|
using uptr = std::unique_ptr<T>;
|
||||||
|
|
||||||
|
//Same as std::make_shared
|
||||||
|
template <class _Ty, class... _Types>
|
||||||
|
inline std::shared_ptr<_Ty> snew(_Types&&... _Args) {
|
||||||
|
return std::make_shared<_Ty>(std::forward<_Types>(_Args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Same as std::make_unique
|
||||||
|
template <class _Ty, class... _Types>
|
||||||
|
inline std::unique_ptr<_Ty> unew(_Types&&... _Args) {
|
||||||
|
return std::make_unique<_Ty>(std::forward<_Types>(_Args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Forward
|
||||||
|
//
|
||||||
|
|
||||||
|
//Audio
|
||||||
|
class SoundEffect;
|
||||||
|
struct SoundEffectInstance;
|
||||||
|
class AudioEngine;
|
||||||
|
struct WaveFormat;
|
||||||
|
|
||||||
|
//CShap
|
||||||
|
struct TimeSpan;
|
||||||
|
class Stream;
|
||||||
|
class FileStream;
|
||||||
|
class MemoryStream;
|
||||||
|
class Type;
|
||||||
|
|
||||||
|
//Content
|
||||||
|
class ContentManager;
|
||||||
|
class ContentReader;
|
||||||
|
class ContentTypeReader;
|
||||||
|
class ContentTypeReaderManager;
|
||||||
|
|
||||||
|
//Common
|
||||||
|
struct BoundingBox;
|
||||||
|
struct BoundingFrustum;
|
||||||
|
struct BoundingSphere;
|
||||||
|
struct Color;
|
||||||
|
struct Curve;
|
||||||
|
struct CurveKey;
|
||||||
|
struct CurveKeyCollection;
|
||||||
|
struct Matrix;
|
||||||
|
struct Plane;
|
||||||
|
struct Point;
|
||||||
|
struct Quaternion;
|
||||||
|
struct Ray;
|
||||||
|
struct Rectangle;
|
||||||
|
struct Vector2;
|
||||||
|
struct Vector3;
|
||||||
|
struct Vector4;
|
||||||
|
|
||||||
|
//Game
|
||||||
|
class Game;
|
||||||
|
class GameComponent;
|
||||||
|
class GameClock;
|
||||||
|
class GameTime;
|
||||||
|
class GameWindow;
|
||||||
|
class GraphicsDeviceInformation;
|
||||||
|
class GraphicsDeviceManager;
|
||||||
|
class IGameTime;
|
||||||
|
class IGameComponent;
|
||||||
|
class GameServiceContainer;
|
||||||
|
class GameComponentCollection;
|
||||||
|
|
||||||
|
//Graphics
|
||||||
|
class BlendState;
|
||||||
|
class ConstantBuffer;
|
||||||
|
class DataBuffer;
|
||||||
|
class DepthStencilState;
|
||||||
|
class DisplayMode;
|
||||||
|
class DisplayModeCollection;
|
||||||
|
class Effect;
|
||||||
|
class GraphicsAdapter;
|
||||||
|
class GraphicsDevice;
|
||||||
|
class GraphicsDeviceInformation;
|
||||||
|
struct PresentationParameters;
|
||||||
|
class RenderTarget2D;
|
||||||
|
class SwapChain;
|
||||||
|
class Texture;
|
||||||
|
class Texture2D;
|
||||||
|
class Texture3D;
|
||||||
|
class TextureCube;
|
||||||
|
class RasterizerState;
|
||||||
|
class SamplerState;
|
||||||
|
class SamplerStateCollection;
|
||||||
|
class Shader;
|
||||||
|
class SpriteBatch;
|
||||||
|
class SpriteFont;
|
||||||
|
struct VertexPositionColor;
|
||||||
|
class VertexShader;
|
||||||
|
struct Viewport;
|
||||||
|
|
||||||
|
//Input
|
||||||
|
struct GamePadTriggers;
|
||||||
|
struct GamePadThumbSticks;
|
||||||
|
struct GamePadDPad;
|
||||||
|
struct GamePadCapabilities;
|
||||||
|
struct GamePadButtons;
|
||||||
|
struct GamePadState;
|
||||||
|
struct KeyboardState;
|
||||||
|
struct MouseState;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,5 +1,5 @@
|
|||||||
#ifndef XNA_ENUMS_HPP
|
#ifndef XNA_ENUMERATIONS_HPP
|
||||||
#define XNA_ENUMS_HPP
|
#define XNA_ENUMERATIONS_HPP
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
enum class AudioChannels
|
enum class AudioChannels
|
||||||
@ -43,35 +43,35 @@ namespace xna {
|
|||||||
Max
|
Max
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Blend {
|
enum class Blend {
|
||||||
Zero,
|
Zero,
|
||||||
One,
|
One,
|
||||||
SourceColor,
|
SourceColor,
|
||||||
InverseSourceColor,
|
InverseSourceColor,
|
||||||
SourceAlpha,
|
SourceAlpha,
|
||||||
InverseSourceAlpha,
|
InverseSourceAlpha,
|
||||||
DestinationAlpha,
|
DestinationAlpha,
|
||||||
InverseDestinationAlpha,
|
InverseDestinationAlpha,
|
||||||
DestinationColor,
|
DestinationColor,
|
||||||
InverseDestinationColor,
|
InverseDestinationColor,
|
||||||
SourceAlphaSaturation,
|
SourceAlphaSaturation,
|
||||||
BlendFactor,
|
BlendFactor,
|
||||||
InverseBlendFactor,
|
InverseBlendFactor,
|
||||||
Source1Color,
|
Source1Color,
|
||||||
InverseSource1Color,
|
InverseSource1Color,
|
||||||
Source1Alpha,
|
Source1Alpha,
|
||||||
InverseSource1Alpha
|
InverseSource1Alpha
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlendFunction {
|
enum class BlendFunction {
|
||||||
Add = 0,
|
Add = 0,
|
||||||
Subtract = 1,
|
Subtract = 1,
|
||||||
ReverseSubtract = 2,
|
ReverseSubtract = 2,
|
||||||
Min = 3,
|
Min = 3,
|
||||||
Max = 4,
|
Max = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
using BlendOperation = BlendFunction;
|
using BlendOperation = BlendFunction;
|
||||||
|
|
||||||
enum class BufferUsage {
|
enum class BufferUsage {
|
||||||
Default,
|
Default,
|
||||||
@ -120,14 +120,14 @@ namespace xna {
|
|||||||
Target,
|
Target,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ColorWriteChannels {
|
enum class ColorWriteChannels {
|
||||||
Red,
|
Red,
|
||||||
Green,
|
Green,
|
||||||
Blue,
|
Blue,
|
||||||
Alpha,
|
Alpha,
|
||||||
All,
|
All,
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ContainmentType {
|
enum class ContainmentType {
|
||||||
Disjoint,
|
Disjoint,
|
||||||
@ -135,19 +135,19 @@ namespace xna {
|
|||||||
Intersects,
|
Intersects,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ComparisonFunction {
|
enum class ComparisonFunction {
|
||||||
Never,
|
Never,
|
||||||
Less,
|
Less,
|
||||||
Equal,
|
Equal,
|
||||||
LessEquals,
|
LessEquals,
|
||||||
Greater,
|
Greater,
|
||||||
NotEqual,
|
NotEqual,
|
||||||
GreaterEqual,
|
GreaterEqual,
|
||||||
Always
|
Always
|
||||||
};
|
};
|
||||||
|
|
||||||
using CompareFunction = ComparisonFunction;
|
using CompareFunction = ComparisonFunction;
|
||||||
|
|
||||||
enum class CurveContinuity {
|
enum class CurveContinuity {
|
||||||
Smooth,
|
Smooth,
|
||||||
Step,
|
Step,
|
||||||
@ -168,30 +168,30 @@ namespace xna {
|
|||||||
Linear,
|
Linear,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class CullMode {
|
enum class CullMode {
|
||||||
None,
|
None,
|
||||||
CullClockwiseFace,
|
CullClockwiseFace,
|
||||||
CullCounterClockwiseFace,
|
CullCounterClockwiseFace,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DepthFormat {
|
enum class DepthFormat {
|
||||||
None,
|
None,
|
||||||
Depth16,
|
Depth16,
|
||||||
Depth24,
|
Depth24,
|
||||||
Depth24Stencil8
|
Depth24Stencil8
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DepthWriteMask {
|
enum class DepthWriteMask {
|
||||||
Zero,
|
Zero,
|
||||||
All
|
All
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DisplayOrientation {
|
enum class DisplayOrientation {
|
||||||
Default = 0,
|
Default = 0,
|
||||||
LandscapeLeft = 1,
|
LandscapeLeft = 1,
|
||||||
LandscapeRight = 2,
|
LandscapeRight = 2,
|
||||||
Portrait = 4,
|
Portrait = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DisplayModeScanlineOrder {
|
enum class DisplayModeScanlineOrder {
|
||||||
Unspecified = 0,
|
Unspecified = 0,
|
||||||
@ -236,11 +236,11 @@ namespace xna {
|
|||||||
Truncate
|
Truncate
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class FillMode
|
enum class FillMode
|
||||||
{
|
{
|
||||||
WireFrame,
|
WireFrame,
|
||||||
Solid,
|
Solid,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GameComponentType {
|
enum class GameComponentType {
|
||||||
Updatable,
|
Updatable,
|
||||||
@ -268,12 +268,12 @@ namespace xna {
|
|||||||
None,
|
None,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GraphicsProfile {
|
enum class GraphicsProfile {
|
||||||
Reach,
|
Reach,
|
||||||
HiDef
|
HiDef
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Keys : unsigned char{
|
enum class Keys : unsigned char {
|
||||||
None = 0,
|
None = 0,
|
||||||
|
|
||||||
Back = 0x8,
|
Back = 0x8,
|
||||||
@ -473,12 +473,12 @@ namespace xna {
|
|||||||
Four,
|
Four,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PresentInterval {
|
enum class PresentInterval {
|
||||||
Default,
|
Default,
|
||||||
One,
|
One,
|
||||||
Two,
|
Two,
|
||||||
Immediate
|
Immediate
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class PrimitiveType
|
enum class PrimitiveType
|
||||||
{
|
{
|
||||||
@ -488,69 +488,65 @@ namespace xna {
|
|||||||
LineStrip,
|
LineStrip,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RenderTargetUsage {
|
enum RenderTargetUsage {
|
||||||
DiscardContents,
|
DiscardContents,
|
||||||
PreserveContents,
|
PreserveContents,
|
||||||
PlatformContents
|
PlatformContents
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SeekOrigin {
|
|
||||||
Begin,
|
|
||||||
Current,
|
|
||||||
End,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class SpriteEffects {
|
enum class SpriteEffects {
|
||||||
None = 0,
|
None = 0,
|
||||||
FlipHorizontally = 1,
|
FlipHorizontally = 1,
|
||||||
FlipVertically = 2,
|
FlipVertically = 2,
|
||||||
Both = FlipHorizontally | FlipVertically
|
Both = FlipHorizontally | FlipVertically
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SpriteSortMode
|
enum class SpriteSortMode
|
||||||
{
|
{
|
||||||
Deferred,
|
Deferred,
|
||||||
Immediate,
|
Immediate,
|
||||||
Texture,
|
Texture,
|
||||||
BackToFront,
|
BackToFront,
|
||||||
FrontToBack,
|
FrontToBack,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class StencilOperation
|
enum class StencilOperation
|
||||||
{
|
{
|
||||||
Keep,
|
Keep,
|
||||||
Zero,
|
Zero,
|
||||||
Replace,
|
Replace,
|
||||||
IncrementSaturation,
|
IncrementSaturation,
|
||||||
DecrementSaturation,
|
DecrementSaturation,
|
||||||
Invert,
|
Invert,
|
||||||
Increment,
|
Increment,
|
||||||
Decrement,
|
Decrement,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SurfaceFormat {
|
enum class SurfaceFormat {
|
||||||
Color = 0,
|
Color = 0,
|
||||||
Bgr565 = 1,
|
Bgr565 = 1,
|
||||||
Bgra5551 = 2,
|
Bgra5551 = 2,
|
||||||
Bgra4444 = 3,
|
Bgra4444 = 3,
|
||||||
Dxt1 = 4,
|
Dxt1 = 4,
|
||||||
Dxt3 = 5,
|
Dxt3 = 5,
|
||||||
Dxt5 = 6,
|
Dxt5 = 6,
|
||||||
NormalizedByte2 = 7,
|
NormalizedByte2 = 7,
|
||||||
NormalizedByte4 = 8,
|
NormalizedByte4 = 8,
|
||||||
Rgba1010102 = 9,
|
Rgba1010102 = 9,
|
||||||
Rg32 = 10,
|
Rg32 = 10,
|
||||||
Rgba64 = 11,
|
Rgba64 = 11,
|
||||||
Alpha8 = 12,
|
Alpha8 = 12,
|
||||||
Single = 13,
|
Single = 13,
|
||||||
Vector2 = 14,
|
Vector2 = 14,
|
||||||
Vector4 = 15,
|
Vector4 = 15,
|
||||||
HalfSingle = 16,
|
HalfSingle = 16,
|
||||||
HalfVector2 = 17,
|
HalfVector2 = 17,
|
||||||
HalfVector4 = 18,
|
HalfVector4 = 18,
|
||||||
HdrBlendable = 19,
|
HdrBlendable = 19,
|
||||||
Unknown,
|
Unknown,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SwapEffect {
|
enum class SwapEffect {
|
||||||
Discard,
|
Discard,
|
||||||
@ -559,29 +555,27 @@ namespace xna {
|
|||||||
FlipDiscard
|
FlipDiscard
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureAddressMode {
|
enum class TextureAddressMode {
|
||||||
Wrap,
|
Wrap,
|
||||||
Mirror,
|
Mirror,
|
||||||
Clamp,
|
Clamp,
|
||||||
Border,
|
Border,
|
||||||
MirrorOnce
|
MirrorOnce
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class TextureFilter {
|
enum class TextureFilter {
|
||||||
Linear,
|
Linear,
|
||||||
Point,
|
Point,
|
||||||
Anisotropic,
|
Anisotropic,
|
||||||
LinearMipPoint,
|
LinearMipPoint,
|
||||||
PointMipLinear,
|
PointMipLinear,
|
||||||
MinLinearMagPointMipLinear,
|
MinLinearMagPointMipLinear,
|
||||||
MinLinearMagPointMipPoint,
|
MinLinearMagPointMipPoint,
|
||||||
MinPointMagLinearMipLinear,
|
MinPointMagLinearMipLinear,
|
||||||
MinPointMagLinearMipPoint,
|
MinPointMagLinearMipPoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr int SURFACE_FORMAT_COUNT = 19;
|
||||||
|
|
||||||
constexpr int SURFACE_FORMAT_COUNT = 19;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -4,47 +4,36 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <source_location>
|
#include <source_location>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
|
||||||
//A list of standard exceptions
|
|
||||||
struct ExMessage {
|
|
||||||
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 CreateComponent = "Failed to create 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 MakeWindowAssociation = "Failed to create association with window";
|
|
||||||
inline static const std::string BuildObject = "Unable to build object";
|
|
||||||
inline static const std::string NotImplemented = "Not Implemented";
|
|
||||||
inline static const std::string ArgumentIsNull = "The argument is null or one of its values.";
|
|
||||||
};
|
|
||||||
|
|
||||||
//Structure for throwing exceptions with a message and information from the source file
|
//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.
|
//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 = "", std::source_location const& location = std::source_location::current());
|
||||||
std::string error;
|
|
||||||
|
|
||||||
error.append("Exception in: ");
|
inline static void ThrowIfNull(std::shared_ptr<void> const& argument, std::string const& argumentName, std::source_location const& location = std::source_location::current()) {
|
||||||
#if _DEBUG
|
ThrowIfNull(&argument, argumentName, location);
|
||||||
error.append(location.file_name());
|
|
||||||
error.append("(");
|
|
||||||
error.append(std::to_string(location.line()));
|
|
||||||
error.append(":");
|
|
||||||
error.append(std::to_string(location.column()));
|
|
||||||
error.append(") ");
|
|
||||||
#endif
|
|
||||||
error.append("'");
|
|
||||||
error.append(location.function_name());
|
|
||||||
error.append("': ");
|
|
||||||
error.append(message);
|
|
||||||
error.append("\n");
|
|
||||||
|
|
||||||
throw std::runtime_error(error);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
inline static void ThrowIfNull(std::unique_ptr<void> const& argument, std::string const& argumentName, std::source_location const& location = std::source_location::current()) {
|
||||||
|
ThrowIfNull(&argument, argumentName, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ThrowIfNull(void const* argument, std::string const& argumentName, std::source_location const& location = std::source_location::current());
|
||||||
|
|
||||||
|
inline static const std::string FAILED_TO_CREATE = "Failed to create component.";
|
||||||
|
inline static const std::string FAILED_TO_APPLY = "Failed to apply component.";
|
||||||
|
inline static const std::string FAILED_TO_MAKE_WINDOW_ASSOCIATION = "Failed to create association with window.";
|
||||||
|
inline static const std::string UNABLE_TO_INITIALIZE = "Unable to initialize component.";
|
||||||
|
inline static const std::string UNABLE_TO_BUILD_OBJECT = "Unable to build object.";
|
||||||
|
inline static const std::string NOT_IMPLEMENTED = "Not Implemented.";
|
||||||
|
inline static const std::string ARGUMENT_IS_NULL = "The argument is null or one of its values.";
|
||||||
|
inline static const std::string INVALID_OPERATION = "An invalid operation occurred.";
|
||||||
|
inline static const std::string BAD_XNB = "Bad xnb file";
|
||||||
|
inline static const std::string OUT_OF_BOUNDS = "Out of bounds.";
|
||||||
|
inline static const std::string END_OF_FILE = "End of file.";
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,97 +0,0 @@
|
|||||||
#ifndef XNA_FORWARD_HPP
|
|
||||||
#define XNA_FORWARD_HPP
|
|
||||||
|
|
||||||
#include "types.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
//Audio
|
|
||||||
class SoundEffect;
|
|
||||||
struct SoundEffectInstance;
|
|
||||||
class AudioEngine;
|
|
||||||
struct WaveFormat;
|
|
||||||
|
|
||||||
//CShap
|
|
||||||
struct TimeSpan;
|
|
||||||
class Stream;
|
|
||||||
class FileStream;
|
|
||||||
class MemoryStream;
|
|
||||||
class Object;
|
|
||||||
class Type;
|
|
||||||
|
|
||||||
//Content
|
|
||||||
class ContentManager;
|
|
||||||
class ContentReader;
|
|
||||||
class ContentTypeReader;
|
|
||||||
class ContentTypeReaderManager;
|
|
||||||
|
|
||||||
//Common
|
|
||||||
struct BoundingBox;
|
|
||||||
struct BoundingFrustum;
|
|
||||||
struct BoundingSphere;
|
|
||||||
struct Color;
|
|
||||||
struct Curve;
|
|
||||||
struct CurveKey;
|
|
||||||
struct CurveKeyCollection;
|
|
||||||
struct Matrix;
|
|
||||||
struct Plane;
|
|
||||||
struct Point;
|
|
||||||
struct Quaternion;
|
|
||||||
struct Ray;
|
|
||||||
struct Rectangle;
|
|
||||||
struct Vector2;
|
|
||||||
struct Vector3;
|
|
||||||
struct Vector4;
|
|
||||||
|
|
||||||
//Game
|
|
||||||
class Game;
|
|
||||||
class GameComponent;
|
|
||||||
class GameClock;
|
|
||||||
class GameTime;
|
|
||||||
class GameWindow;
|
|
||||||
class GraphicsDeviceInformation;
|
|
||||||
class GraphicsDeviceManager;
|
|
||||||
class IGameTime;
|
|
||||||
class IGameComponent;
|
|
||||||
class GameServiceContainer;
|
|
||||||
class GameComponentCollection;
|
|
||||||
|
|
||||||
//Graphics
|
|
||||||
class BlendState;
|
|
||||||
class ConstantBuffer;
|
|
||||||
class DataBuffer;
|
|
||||||
class DepthStencilState;
|
|
||||||
class DisplayMode;
|
|
||||||
class DisplayModeCollection;
|
|
||||||
class Effect;
|
|
||||||
class GraphicsAdapter;
|
|
||||||
class GraphicsDevice;
|
|
||||||
class GraphicsDeviceInformation;
|
|
||||||
struct PresentationParameters;
|
|
||||||
class RenderTarget2D;
|
|
||||||
class SwapChain;
|
|
||||||
class Texture;
|
|
||||||
class Texture2D;
|
|
||||||
class Texture3D;
|
|
||||||
class TextureCube;
|
|
||||||
class RasterizerState;
|
|
||||||
class SamplerState;
|
|
||||||
class SamplerStateCollection;
|
|
||||||
class Shader;
|
|
||||||
class SpriteBatch;
|
|
||||||
class SpriteFont;
|
|
||||||
struct VertexPositionColor;
|
|
||||||
class VertexShader;
|
|
||||||
struct Viewport;
|
|
||||||
|
|
||||||
//Input
|
|
||||||
struct GamePadTriggers;
|
|
||||||
struct GamePadThumbSticks;
|
|
||||||
struct GamePadDPad;
|
|
||||||
struct GamePadCapabilities;
|
|
||||||
struct GamePadButtons;
|
|
||||||
struct GamePadState;
|
|
||||||
struct KeyboardState;
|
|
||||||
struct MouseState;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,8 +1,7 @@
|
|||||||
#ifndef XNA_GAME_TIME_HPP
|
#ifndef XNA_GAME_TIME_HPP
|
||||||
#define XNA_GAME_TIME_HPP
|
#define XNA_GAME_TIME_HPP
|
||||||
|
|
||||||
#include "../forward.hpp"
|
#include "../default.hpp"
|
||||||
#include "../types.hpp"
|
|
||||||
#include "../csharp/timespan.hpp"
|
#include "../csharp/timespan.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#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"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
@ -13,7 +12,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,
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#ifndef XNA_HELPERS_HPP
|
#ifndef XNA_HELPERS_HPP
|
||||||
#define XNA_HELPERS_HPP
|
#define XNA_HELPERS_HPP
|
||||||
|
|
||||||
#include <string>
|
#include "default.hpp"
|
||||||
#include <utility>
|
|
||||||
#include "exception.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//Class for helper functions
|
//Class for helper functions
|
||||||
@ -15,6 +13,16 @@ namespace xna {
|
|||||||
|
|
||||||
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 {};
|
||||||
|
template<typename T> struct is_weak_ptr : std::false_type {};
|
||||||
|
template<typename T> struct is_weak_ptr<std::weak_ptr<T>> : std::true_type {};
|
||||||
|
template<typename T> struct is_unique_ptr : std::false_type {};
|
||||||
|
template<typename T> struct is_unique_ptr<std::unique_ptr<T>> : std::true_type {};
|
||||||
|
|
||||||
|
//Returns true if the type is a smart pointer
|
||||||
|
template <typename T>
|
||||||
|
static constexpr bool IsSmartPoint() {
|
||||||
|
return is_shared_ptr<T>::value || is_unique_ptr<T>::value || is_weak_ptr<T>::value;
|
||||||
|
}
|
||||||
|
|
||||||
//Convert a string to wstring
|
//Convert a string to wstring
|
||||||
static inline std::wstring ToWString(const std::string& str)
|
static inline std::wstring ToWString(const std::string& str)
|
||||||
@ -47,12 +55,12 @@ namespace xna {
|
|||||||
//Throws an exception if the object cannot be created
|
//Throws an exception if the object cannot be created
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static inline auto ReturnDefaultOrNull(const std::source_location location = std::source_location::current()) {
|
static inline auto ReturnDefaultOrNull(const std::source_location location = std::source_location::current()) {
|
||||||
if constexpr (is_shared_ptr<T>::value)
|
if constexpr (IsSmartPoint<T>())
|
||||||
return (T)nullptr;
|
return (T)nullptr;
|
||||||
else if (std::is_default_constructible<T>::value)
|
else if constexpr (std::is_default_constructible<T>::value)
|
||||||
return T();
|
return T();
|
||||||
else
|
else
|
||||||
Exception::Throw(ExMessage::BuildObject, location);
|
Exception::Throw(Exception::UNABLE_TO_BUILD_OBJECT, location);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -247,15 +247,15 @@ namespace xna {
|
|||||||
static GamePadCapabilities GetCapabilities(PlayerIndex index);
|
static GamePadCapabilities GetCapabilities(PlayerIndex index);
|
||||||
//Sets the vibration motor speeds on an Xbox 360 Controller.
|
//Sets the vibration motor speeds on an Xbox 360 Controller.
|
||||||
static bool SetVibration(PlayerIndex index, float leftMotor, float rightMotor, float leftTrigger = 0, float rightTrigger = 0);
|
static bool SetVibration(PlayerIndex index, float leftMotor, float rightMotor, float leftTrigger = 0, float rightTrigger = 0);
|
||||||
|
|
||||||
GamePad() = delete;
|
|
||||||
GamePad(GamePad&) = delete;
|
|
||||||
GamePad(GamePad&&) = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Game;
|
friend class Game;
|
||||||
static void Initialize();
|
static void Initialize();
|
||||||
|
|
||||||
|
GamePad() = default;
|
||||||
|
GamePad(GamePad&) = default;
|
||||||
|
GamePad(GamePad&&) = default;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
inline static uptr<PlatformImplementation> impl = nullptr;
|
inline static uptr<PlatformImplementation> impl = 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,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,94 +0,0 @@
|
|||||||
#ifndef XNA_TYPES_HPP
|
|
||||||
#define XNA_TYPES_HPP
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <limits>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <memory>
|
|
||||||
#include <utility>
|
|
||||||
#include <cassert>
|
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
namespace xna {
|
|
||||||
|
|
||||||
//
|
|
||||||
// C# standard types
|
|
||||||
//
|
|
||||||
|
|
||||||
using Sbyte = int8_t;
|
|
||||||
using Byte = uint8_t;
|
|
||||||
using Short = int16_t;
|
|
||||||
using Ushort = uint16_t;
|
|
||||||
using Int = int32_t;
|
|
||||||
using Uint = uint32_t;
|
|
||||||
using Long = int64_t;
|
|
||||||
using Ulong = uint64_t;
|
|
||||||
using Char = char16_t;
|
|
||||||
|
|
||||||
//
|
|
||||||
// C# Min and Max Value
|
|
||||||
//
|
|
||||||
|
|
||||||
constexpr Sbyte SbyteMaxValue = (std::numeric_limits<Sbyte>::max)();
|
|
||||||
constexpr Sbyte SbyteMinValue = (std::numeric_limits<Sbyte>::min)();
|
|
||||||
constexpr Byte ByteMaxValue = (std::numeric_limits<Byte>::max)();
|
|
||||||
constexpr Byte ByteMinValue = (std::numeric_limits<Byte>::min)();
|
|
||||||
constexpr Short ShortMaxValue = (std::numeric_limits<Short>::max)();
|
|
||||||
constexpr Short ShortMinValue = (std::numeric_limits<Short>::min)();
|
|
||||||
constexpr Ushort UshortMaxValue = (std::numeric_limits<Ushort>::max)();
|
|
||||||
constexpr Ushort UshortMinValue = (std::numeric_limits<Ushort>::min)();
|
|
||||||
constexpr Int IntMaxValue = (std::numeric_limits<Int>::max)();
|
|
||||||
constexpr Int IntMinValue = (std::numeric_limits<Int>::min)();
|
|
||||||
constexpr Uint UintMaxValue = (std::numeric_limits<Uint>::max)();
|
|
||||||
constexpr Uint UintMinValue = (std::numeric_limits<Uint>::min)();
|
|
||||||
constexpr Long LongMaxValue = (std::numeric_limits<Long>::max)();
|
|
||||||
constexpr Long LongMinValue = (std::numeric_limits<Long>::min)();
|
|
||||||
constexpr Ulong UlongMaxValue = (std::numeric_limits<Ulong>::max)();
|
|
||||||
constexpr Ulong UlongMinValue = (std::numeric_limits<Ulong>::min)();
|
|
||||||
constexpr Char CharMaxValue = (std::numeric_limits<Char>::max)();
|
|
||||||
constexpr Char CharMinValue = (std::numeric_limits<Char>::min)();
|
|
||||||
constexpr float FloatMaxValue = (std::numeric_limits<float>::max)();
|
|
||||||
constexpr float FloatMinValue = (std::numeric_limits<float>::min)();
|
|
||||||
constexpr double DoubleMaxValue = (std::numeric_limits<double>::max)();
|
|
||||||
constexpr double DoubleMinValue = (std::numeric_limits<double>::min)();
|
|
||||||
|
|
||||||
//
|
|
||||||
// About strings: https://stackoverflow.com/questions/402283/stdwstring-vs-stdstring
|
|
||||||
//
|
|
||||||
|
|
||||||
//Same as std::string
|
|
||||||
using String = std::string;
|
|
||||||
|
|
||||||
//Same as std::wstring
|
|
||||||
using WString = std::wstring;
|
|
||||||
|
|
||||||
//Same as std::shared_ptr
|
|
||||||
template <typename T>
|
|
||||||
using sptr = std::shared_ptr<T>;
|
|
||||||
|
|
||||||
//Same as std::weak_ptr
|
|
||||||
template <typename T>
|
|
||||||
using wptr = std::weak_ptr<T>;
|
|
||||||
|
|
||||||
//Same as std::unique_ptr
|
|
||||||
template <typename T>
|
|
||||||
using uptr = std::unique_ptr<T>;
|
|
||||||
|
|
||||||
//Same as std::make_shared
|
|
||||||
template <class _Ty, class... _Types>
|
|
||||||
inline std::shared_ptr<_Ty> snew(_Types&&... _Args) {
|
|
||||||
return std::make_shared<_Ty>(std::forward<_Types>(_Args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Same as std::make_unique
|
|
||||||
template <class _Ty, class... _Types>
|
|
||||||
inline std::unique_ptr<_Ty> unew(_Types&&... _Args) {
|
|
||||||
return std::make_unique<_Ty>(std::forward<_Types>(_Args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
//See ref: https://en.cppreference.com/w/cpp/error/assert
|
|
||||||
#define assertm(exp, msg) assert(((void)msg, exp))
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -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,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"
|
||||||
@ -16,12 +19,10 @@
|
|||||||
#include "content/typereadermanager.hpp"
|
#include "content/typereadermanager.hpp"
|
||||||
#include "csharp/binary.hpp"
|
#include "csharp/binary.hpp"
|
||||||
#include "csharp/buffer.hpp"
|
#include "csharp/buffer.hpp"
|
||||||
#include "csharp/object.hpp"
|
|
||||||
#include "csharp/service.hpp"
|
#include "csharp/service.hpp"
|
||||||
#include "csharp/stream.hpp"
|
#include "csharp/stream.hpp"
|
||||||
#include "csharp/timespan.hpp"
|
#include "csharp/timespan.hpp"
|
||||||
#include "csharp/type.hpp"
|
#include "csharp/type.hpp"
|
||||||
#include "enums.hpp"
|
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
#include "game/component.hpp"
|
#include "game/component.hpp"
|
||||||
#include "game/game.hpp"
|
#include "game/game.hpp"
|
||||||
@ -35,6 +36,7 @@
|
|||||||
#include "graphics/depthstencilstate.hpp"
|
#include "graphics/depthstencilstate.hpp"
|
||||||
#include "graphics/device.hpp"
|
#include "graphics/device.hpp"
|
||||||
#include "graphics/displaymode.hpp"
|
#include "graphics/displaymode.hpp"
|
||||||
|
#include "graphics/effect.hpp"
|
||||||
#include "graphics/gresource.hpp"
|
#include "graphics/gresource.hpp"
|
||||||
#include "graphics/presentparams.hpp"
|
#include "graphics/presentparams.hpp"
|
||||||
#include "graphics/rasterizerstate.hpp"
|
#include "graphics/rasterizerstate.hpp"
|
||||||
@ -49,6 +51,14 @@
|
|||||||
#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"
|
namespace xna {
|
||||||
#include "xna/platform-dx/dx.hpp"
|
//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/xna-dx.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace xna;
|
using namespace xna;
|
||||||
@ -26,7 +27,6 @@ namespace xna {
|
|||||||
|
|
||||||
void LoadContent() override {
|
void LoadContent() override {
|
||||||
spriteBatch = snew<SpriteBatch>(graphicsDevice);
|
spriteBatch = snew<SpriteBatch>(graphicsDevice);
|
||||||
auto texture = Content()->Load<PTexture2D>("Idle");
|
|
||||||
Game::LoadContent();
|
Game::LoadContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_ANIMATION_HPP
|
#ifndef PLATFORMSTARTERKIT_ANIMATION_HPP
|
||||||
#define PLATFORMSTARTERKIT_ANIMATION_HPP
|
#define PLATFORMSTARTERKIT_ANIMATION_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
/*
|
/*
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_CIRCLE_HPP
|
#ifndef PLATFORMSTARTERKIT_CIRCLE_HPP
|
||||||
#define PLATFORMSTARTERKIT_CIRCLE_HPP
|
#define PLATFORMSTARTERKIT_CIRCLE_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
//Represents a 2D circle.
|
//Represents a 2D circle.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_ENEMY_HPP
|
#ifndef PLATFORMSTARTERKIT_ENEMY_HPP
|
||||||
#define PLATFORMSTARTERKIT_ENEMY_HPP
|
#define PLATFORMSTARTERKIT_ENEMY_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// xna.cpp : Defines the entry point for the application.
|
// xna.cpp : Defines the entry point for the application.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
#include "player.hpp"
|
#include "player.hpp"
|
||||||
#include "enemy.hpp"
|
#include "enemy.hpp"
|
||||||
#include "level.hpp"
|
#include "level.hpp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_GEM_HPP
|
#ifndef PLATFORMSTARTERKIT_GEM_HPP
|
||||||
#define PLATFORMSTARTERKIT_GEM_HPP
|
#define PLATFORMSTARTERKIT_GEM_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
#include "circle.hpp"
|
#include "circle.hpp"
|
||||||
#include "tile.hpp"
|
#include "tile.hpp"
|
||||||
|
|
||||||
|
2
samples/02_PlatfformerStarterKit/headers.hpp
Normal file
2
samples/02_PlatfformerStarterKit/headers.hpp
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#include "xna/xna.hpp"
|
||||||
|
#include "xna/xna-dx.hpp"
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_LEVEL_HPP
|
#ifndef PLATFORMSTARTERKIT_LEVEL_HPP
|
||||||
#define PLATFORMSTARTERKIT_LEVEL_HPP
|
#define PLATFORMSTARTERKIT_LEVEL_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
#include "tile.hpp"
|
#include "tile.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_PLAYER_HPP
|
#ifndef PLATFORMSTARTERKIT_PLAYER_HPP
|
||||||
#define PLATFORMSTARTERKIT_PLAYER_HPP
|
#define PLATFORMSTARTERKIT_PLAYER_HPP
|
||||||
|
|
||||||
#include "xna/xna.hpp"
|
#include "headers.hpp"
|
||||||
#include "animation.hpp"
|
#include "animation.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#ifndef PLATFORMSTARTERKIT_TILE_HPP
|
#ifndef PLATFORMSTARTERKIT_TILE_HPP
|
||||||
#define PLATFORMSTARTERKIT_TILE_HPP
|
#define PLATFORMSTARTERKIT_TILE_HPP
|
||||||
|
|
||||||
|
#include "headers.hpp"
|
||||||
|
|
||||||
namespace PlatformerStarterKit {
|
namespace PlatformerStarterKit {
|
||||||
// Controls the collision detection and response behavior of a tile.
|
// Controls the collision detection and response behavior of a tile.
|
||||||
enum class TileCollision {
|
enum class TileCollision {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user