mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige Windows e GraphicsInfo
This commit is contained in:
parent
01af08b711
commit
d2a8b1d397
@ -13,26 +13,18 @@ add_executable (xna WIN32
|
||||
"platform/texture-dx.cpp"
|
||||
"platform/blendstate-dx.cpp"
|
||||
"platform/game-dx.cpp"
|
||||
|
||||
"csharp/stream.cpp"
|
||||
"platform/gdevicemanager-dx.cpp"
|
||||
|
||||
"platform/shader-dx.cpp"
|
||||
"platform/rasterizerstate-dx.cpp"
|
||||
|
||||
|
||||
|
||||
|
||||
"platform/samplerstate-dx.cpp"
|
||||
"platform/sprite-dx.cpp"
|
||||
|
||||
"platform/depthstencilstate-dx.cpp"
|
||||
"platform/keyboard-dx.cpp"
|
||||
"platform/mouse-dx.cpp"
|
||||
"platform/gamepad-dx.cpp"
|
||||
"platform/soundeffect-dx.cpp"
|
||||
"platform/displaymode-dx.cpp"
|
||||
|
||||
"game/component.cpp"
|
||||
"content/manager.cpp"
|
||||
"content/reader.cpp"
|
||||
@ -47,7 +39,9 @@ add_executable (xna WIN32
|
||||
"common/color.cpp"
|
||||
"common/collision.cpp"
|
||||
"common/gjk.cpp"
|
||||
"common/numerics.cpp" "common/packedvalue.cpp" "platform/buffer.cpp")
|
||||
"common/numerics.cpp"
|
||||
"common/packedvalue.cpp"
|
||||
"platform/buffer.cpp" )
|
||||
|
||||
if (CMAKE_VERSION VERSION_GREATER 3.12)
|
||||
set_property(TARGET xna PROPERTY CXX_STANDARD 20)
|
||||
|
@ -3,11 +3,9 @@
|
||||
#include "graphics/blendstate.hpp"
|
||||
#include "graphics/rendertarget.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "platform-dx/gdeviceinfo-dx.hpp"
|
||||
#include "platform-dx/gdevicemanager-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
#include "platform-dx/window-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
#include "game/gdeviceinfo.hpp"
|
||||
|
||||
namespace xna {
|
||||
GraphicsDevice::GraphicsDevice() {
|
||||
@ -16,12 +14,12 @@ namespace xna {
|
||||
}
|
||||
|
||||
GraphicsDevice::GraphicsDevice(GraphicsDeviceInformation const& info) {
|
||||
_adapter = info.Adapter();
|
||||
_presentationParameters = info.PresentationParameters();
|
||||
_adapter = info.Adapter;
|
||||
_presentationParameters = info.Parameters;
|
||||
_adapter->CurrentDisplayMode(
|
||||
_presentationParameters.BackBufferFormat,
|
||||
_presentationParameters.BackBufferWidth,
|
||||
_presentationParameters.BackBufferHeight);
|
||||
_presentationParameters->BackBufferFormat,
|
||||
_presentationParameters->BackBufferWidth,
|
||||
_presentationParameters->BackBufferHeight);
|
||||
}
|
||||
|
||||
bool GraphicsDevice::Initialize(GameWindow& gameWindow) {
|
||||
@ -41,7 +39,7 @@ namespace xna {
|
||||
static_cast<float>(bounds.Height),
|
||||
0.0F, 1.F);
|
||||
|
||||
COLORREF color = gameWindow.Color();
|
||||
COLORREF color = gameWindow.impl->Color();
|
||||
_backgroundColor[0] = GetRValue(color) / 255.0f;
|
||||
_backgroundColor[1] = GetGValue(color) / 255.0f;
|
||||
_backgroundColor[2] = GetBValue(color) / 255.0f;
|
||||
@ -50,7 +48,7 @@ namespace xna {
|
||||
_swapChain = New<xna::SwapChain>(_this);
|
||||
_swapChain->Initialize();
|
||||
|
||||
hr = _factory->MakeWindowAssociation(gameWindow.WindowHandle(), DXGI_MWA_NO_ALT_ENTER);
|
||||
hr = _factory->MakeWindowAssociation(gameWindow.impl->WindowHandle(), DXGI_MWA_NO_ALT_ENTER);
|
||||
if (FAILED(hr)) return false;
|
||||
|
||||
_renderTarget2D = New<RenderTarget2D>(_this);
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "csharp/type.hpp"
|
||||
#include "game/time.hpp"
|
||||
#include "platform-dx/audioengine-dx.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "platform-dx/game-dx.hpp"
|
||||
#include "platform-dx/gdevicemanager-dx.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
#include "platform-dx/window-dx.hpp"
|
||||
|
||||
namespace xna {
|
||||
Game::Game() {
|
||||
@ -13,9 +11,9 @@ namespace xna {
|
||||
_contentManager = New<ContentManager>("", services);
|
||||
|
||||
_gameWindow = New<GameWindow>();
|
||||
_gameWindow->Color(146, 150, 154);
|
||||
_gameWindow->impl->Color(146, 150, 154);
|
||||
_gameWindow->Title("XN65");
|
||||
_gameWindow->Size(
|
||||
_gameWindow->impl->Size(
|
||||
GraphicsDeviceManager::DefaultBackBufferWidth,
|
||||
GraphicsDeviceManager::DefaultBackBufferHeight, false);
|
||||
|
||||
@ -23,7 +21,7 @@ namespace xna {
|
||||
}
|
||||
|
||||
void Game::Exit() {
|
||||
_gameWindow->Close();
|
||||
_gameWindow->impl->Close();
|
||||
}
|
||||
|
||||
int Game::Run() {
|
||||
|
@ -1,8 +1,6 @@
|
||||
#include "platform-dx/gdevicemanager-dx.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "platform-dx/game-dx.hpp"
|
||||
#include "platform-dx/window-dx.hpp"
|
||||
#include "platform-dx/gdeviceinfo-dx.hpp"
|
||||
#include "graphics/presentparams.hpp"
|
||||
#include "graphics/swapchain.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
@ -10,17 +8,18 @@
|
||||
namespace xna {
|
||||
GraphicsDeviceManager::GraphicsDeviceManager(Game*& game) : _game(game) {
|
||||
sptr<GraphicsAdapter> adp = GraphicsAdapter::DefaultAdapter();
|
||||
_information.Adapter(adp);
|
||||
_information.GraphicsProfile(xna::GraphicsProfile::HiDef);
|
||||
_information.Adapter = adp;
|
||||
_information.Profile = xna::GraphicsProfile::HiDef;
|
||||
|
||||
PresentationParameters parameters;
|
||||
parameters.BackBufferWidth = _backBufferWidth;
|
||||
parameters.BackBufferHeight = _backBufferHeight;
|
||||
parameters.BackBufferFormat = SurfaceFormat::Color;
|
||||
parameters.Fullscreen = false;
|
||||
_information.PresentationParameters(parameters);
|
||||
auto parameters = snew<PresentationParameters>();
|
||||
parameters->BackBufferWidth = _backBufferWidth;
|
||||
parameters->BackBufferHeight = _backBufferHeight;
|
||||
parameters->BackBufferFormat = SurfaceFormat::Color;
|
||||
parameters->Fullscreen = false;
|
||||
_information.Parameters = parameters;
|
||||
|
||||
if(_game) _information.Window(_game->Window());
|
||||
if(_game)
|
||||
_information.Window =_game->Window();
|
||||
}
|
||||
|
||||
bool GraphicsDeviceManager::Initialize() {
|
||||
@ -65,8 +64,8 @@ namespace xna {
|
||||
|
||||
bool GraphicsDeviceManager::CreateDevice() {
|
||||
if (_isDeviceDirty) {
|
||||
_information._parameters.BackBufferWidth = _backBufferWidth;
|
||||
_information._parameters.BackBufferHeight = _backBufferHeight;
|
||||
_information.Parameters->BackBufferWidth = _backBufferWidth;
|
||||
_information.Parameters->BackBufferHeight = _backBufferHeight;
|
||||
}
|
||||
|
||||
auto result = initWindow();
|
||||
@ -81,32 +80,32 @@ namespace xna {
|
||||
|
||||
bool GraphicsDeviceManager::initWindow()
|
||||
{
|
||||
auto window = _information.Window();
|
||||
auto window = _information.Window;
|
||||
|
||||
if (!window) {
|
||||
window = _game->Window();
|
||||
_information.Window(window);
|
||||
_information.Window = window;
|
||||
}
|
||||
|
||||
window->Size(_backBufferWidth, _backBufferHeight);
|
||||
window->impl->Size(_backBufferWidth, _backBufferHeight);
|
||||
|
||||
if (!window->Create()) {
|
||||
if (!window->impl->Create()) {
|
||||
MessageBox(nullptr, "Falha na criação da janela", "XN65", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
_information._parameters.DeviceWindowHandle = reinterpret_cast<intptr_t>(window->WindowHandle());
|
||||
_information.Parameters->DeviceWindowHandle = reinterpret_cast<intptr_t>(window->impl->WindowHandle());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GraphicsDeviceManager::initDevice()
|
||||
{
|
||||
auto window = _information.Window();
|
||||
auto window = _information.Window;
|
||||
_device = New<GraphicsDevice>(_information);
|
||||
|
||||
if (!_device->Initialize(*window)) {
|
||||
MessageBox(window->WindowHandle(), "Falha na inicialização do dispositivo gráfico", "XN65", MB_OK);
|
||||
MessageBox(window->impl->WindowHandle(), "Falha na inicialização do dispositivo gráfico", "XN65", MB_OK);
|
||||
_device = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
@ -59,23 +59,23 @@ namespace xna {
|
||||
|
||||
const auto parameters = m_device->_presentationParameters;
|
||||
|
||||
impl->dxDescription.Width = static_cast<UINT>(parameters.BackBufferWidth);
|
||||
impl->dxDescription.Height = static_cast<UINT>(parameters.BackBufferHeight);
|
||||
impl->dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(parameters.BackBufferFormat);
|
||||
impl->dxDescription.Width = static_cast<UINT>(parameters->BackBufferWidth);
|
||||
impl->dxDescription.Height = static_cast<UINT>(parameters->BackBufferHeight);
|
||||
impl->dxDescription.Format = DxHelpers::ConvertSurfaceToDXGIFORMAT(parameters->BackBufferFormat);
|
||||
impl->dxDescription.SampleDesc.Count = 1;
|
||||
impl->dxDescription.SampleDesc.Quality = 0;
|
||||
impl->dxDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
impl->dxDescription.BufferCount = 2;
|
||||
impl->dxDescription.SwapEffect = static_cast<DXGI_SWAP_EFFECT>(parameters.PresentationSwapEffect);
|
||||
impl->dxDescription.SwapEffect = static_cast<DXGI_SWAP_EFFECT>(parameters->PresentationSwapEffect);
|
||||
impl->dxDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||
impl->dxDescription.AlphaMode = DXGI_ALPHA_MODE::DXGI_ALPHA_MODE_UNSPECIFIED;
|
||||
impl->dxFullScreenDescription.RefreshRate.Numerator = 60;
|
||||
impl->dxFullScreenDescription.RefreshRate.Denominator = 1;
|
||||
impl->dxFullScreenDescription.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
|
||||
impl->dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||
impl->dxFullScreenDescription.Windowed = !parameters.Fullscreen;
|
||||
impl->dxFullScreenDescription.Windowed = !parameters->Fullscreen;
|
||||
|
||||
HWND hwnd = reinterpret_cast<HWND>(parameters.DeviceWindowHandle);
|
||||
HWND hwnd = reinterpret_cast<HWND>(parameters->DeviceWindowHandle);
|
||||
return internalInit(*m_device, hwnd, impl->dxSwapChain, impl->dxDescription, impl->dxFullScreenDescription);
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,23 @@
|
||||
#include "platform-dx/window-dx.hpp"
|
||||
#include "input/gamepad.hpp"
|
||||
#include "platform-dx/implementations.hpp"
|
||||
|
||||
namespace xna {
|
||||
GameWindow::GameWindow() {
|
||||
_hInstance = GetModuleHandle(NULL);
|
||||
_windowIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
_windowCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
_windowStyle = static_cast<int>(GameWindowMode::Windowed);
|
||||
_windowCenterX = _windowWidth / 2.0F;
|
||||
_windowCenterY = _windowHeight / 2.0F;
|
||||
impl = unew<PlatformImplementation>();
|
||||
|
||||
impl->_hInstance = GetModuleHandle(NULL);
|
||||
impl->_windowIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
impl->_windowCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
impl->_windowStyle = static_cast<int>(GameWindowMode::Windowed);
|
||||
impl->_windowCenterX = impl->_windowWidth / 2.0F;
|
||||
impl->_windowCenterY = impl->_windowHeight / 2.0F;
|
||||
|
||||
}
|
||||
|
||||
void GameWindow::Position(int width, int height, bool update) {
|
||||
GameWindow::~GameWindow() {
|
||||
impl = nullptr;
|
||||
}
|
||||
|
||||
void GameWindow::PlatformImplementation::Position(int width, int height, bool update) {
|
||||
_windowPosX = width;
|
||||
_windowPosY = height;
|
||||
setCenter();
|
||||
@ -21,7 +25,7 @@ namespace xna {
|
||||
if(update) Update();
|
||||
}
|
||||
|
||||
void GameWindow::Size(int width, int height, bool update) {
|
||||
void GameWindow::PlatformImplementation::Size(int width, int height, bool update) {
|
||||
_windowWidth = width;
|
||||
_windowHeight = height;
|
||||
setPosition();
|
||||
@ -31,10 +35,12 @@ namespace xna {
|
||||
}
|
||||
|
||||
void GameWindow::Title(String const& title) {
|
||||
_windowTitle = title;
|
||||
if (!impl) return;
|
||||
|
||||
impl->_windowTitle = title;
|
||||
}
|
||||
|
||||
bool GameWindow::Create() {
|
||||
bool GameWindow::PlatformImplementation::Create() {
|
||||
WNDCLASSEX wndClass{};
|
||||
wndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
wndClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
|
||||
@ -89,7 +95,7 @@ namespace xna {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GameWindow::Update() {
|
||||
bool GameWindow::PlatformImplementation::Update() {
|
||||
if (_windowStyle == static_cast<int>(GameWindowMode::Windowed)) {
|
||||
RECT winRect = { 0, 0, _windowWidth, _windowHeight };
|
||||
|
||||
@ -116,23 +122,29 @@ namespace xna {
|
||||
}
|
||||
|
||||
String GameWindow::Title() const {
|
||||
return _windowTitle;
|
||||
if (!impl) return String();
|
||||
|
||||
return impl->_windowTitle;
|
||||
}
|
||||
|
||||
Rectangle GameWindow::ClientBounds() const {
|
||||
if (!impl) return {};
|
||||
|
||||
return Rectangle(
|
||||
_windowPosX,
|
||||
_windowPosY,
|
||||
_windowWidth,
|
||||
_windowHeight
|
||||
impl->_windowPosX,
|
||||
impl->_windowPosY,
|
||||
impl->_windowWidth,
|
||||
impl->_windowHeight
|
||||
);
|
||||
}
|
||||
|
||||
intptr_t GameWindow::Handle() const {
|
||||
return reinterpret_cast<intptr_t>(_windowHandle);
|
||||
if (!impl) return 0;
|
||||
|
||||
return reinterpret_cast<intptr_t>(impl->_windowHandle);
|
||||
}
|
||||
|
||||
LRESULT GameWindow::WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
LRESULT GameWindow::PlatformImplementation::WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (msg) {
|
||||
case WM_DESTROY:
|
||||
@ -140,18 +152,18 @@ namespace xna {
|
||||
return 0;
|
||||
case WM_ACTIVATE:
|
||||
case WM_ACTIVATEAPP:
|
||||
Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
Mouse::impl->ProcessMessage(msg, wParam, lParam);
|
||||
if(Keyboard::impl) Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
if(Mouse::impl) Mouse::impl->ProcessMessage(msg, wParam, lParam);
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
if (!(wParam == VK_RETURN && (lParam & 0x60000000) == 0x20000000)) {
|
||||
Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
if (Keyboard::impl) Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
if (Keyboard::impl) Keyboard::impl->ProcessMessage(msg, wParam, lParam);
|
||||
break;
|
||||
|
||||
case WM_INPUT:
|
||||
@ -166,13 +178,13 @@ namespace xna {
|
||||
case WM_XBUTTONDOWN:
|
||||
case WM_XBUTTONUP:
|
||||
case WM_MOUSEHOVER:
|
||||
Mouse::impl->ProcessMessage(msg, wParam, lParam);
|
||||
if (Mouse::impl) Mouse::impl->ProcessMessage(msg, wParam, lParam);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
GamePad::impl->Suspend();
|
||||
if (GamePad::impl) GamePad::impl->Suspend();
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
GamePad::impl->Resume();
|
||||
if (GamePad::impl) GamePad::impl->Resume();
|
||||
break;
|
||||
}
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
|
@ -1,21 +1,15 @@
|
||||
#ifndef XNA_GAME_GDEVICEINFO_HPP
|
||||
#define XNA_GAME_GDEVICEINFO_HPP
|
||||
|
||||
#include "../forward.hpp"
|
||||
#include "../enums.hpp"
|
||||
#include "../default.hpp"
|
||||
|
||||
namespace xna {
|
||||
class IGraphicsDeviceInformation {
|
||||
class GraphicsDeviceInformation {
|
||||
public:
|
||||
virtual ~IGraphicsDeviceInformation(){}
|
||||
virtual sptr<GraphicsAdapter> Adapter() const = 0;
|
||||
virtual void Adapter(sptr<GraphicsAdapter> const& value) = 0;
|
||||
virtual xna::PresentationParameters PresentationParameters() const = 0;
|
||||
virtual void PresentationParameters(xna::PresentationParameters const& value) = 0;
|
||||
virtual xna::GraphicsProfile GraphicsProfile() const = 0;
|
||||
virtual void GraphicsProfile(xna::GraphicsProfile value) = 0;
|
||||
virtual sptr<GameWindow> Window() const = 0;
|
||||
virtual void Window(sptr<GameWindow> const& window) = 0;
|
||||
sptr<GraphicsAdapter> Adapter = nullptr;
|
||||
xna::GraphicsProfile Profile{ xna::GraphicsProfile::Reach };
|
||||
sptr<xna::PresentationParameters> Parameters = nullptr;
|
||||
sptr<GameWindow> Window = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,22 @@
|
||||
#ifndef XNA_GAME_WINDOW_HPP
|
||||
#define XNA_GAME_WINDOW_HPP
|
||||
|
||||
#include "../enums.hpp"
|
||||
#include "../default.hpp"
|
||||
#include "../common/numerics.hpp"
|
||||
|
||||
namespace xna {
|
||||
class IGameWindow {
|
||||
class GameWindow {
|
||||
public:
|
||||
virtual ~IGameWindow(){}
|
||||
GameWindow();
|
||||
~GameWindow();
|
||||
String Title() const;
|
||||
void Title(String const& title);
|
||||
Rectangle ClientBounds() const;
|
||||
intptr_t Handle() const;
|
||||
|
||||
virtual String Title() const = 0;
|
||||
virtual void Title(String const& title) = 0;
|
||||
virtual Rectangle ClientBounds() const = 0;
|
||||
virtual intptr_t Handle() const = 0;
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ namespace xna {
|
||||
bool Connected{ false };
|
||||
Ushort Vid{ 0 };
|
||||
Ushort Pid{ 0 };
|
||||
GamePadId Id;
|
||||
GamePadId Id{};
|
||||
};
|
||||
|
||||
struct GamePadState {
|
||||
|
@ -6,9 +6,7 @@
|
||||
#include "../graphics/presentparams.hpp"
|
||||
#include "../graphics/viewport.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
#include "gdeviceinfo-dx.hpp"
|
||||
#include "window-dx.hpp"
|
||||
#include "graphics/presentparams.hpp"
|
||||
#include "game/gdeviceinfo.hpp"
|
||||
|
||||
namespace xna {
|
||||
class GraphicsDevice : public IGraphicsDevice, public std::enable_shared_from_this<GraphicsDevice> {
|
||||
@ -77,7 +75,7 @@ namespace xna {
|
||||
sptr<RenderTarget2D> _renderTarget2D{ nullptr };
|
||||
sptr<BlendState> _blendState{ nullptr };
|
||||
xna::Viewport _viewport{};
|
||||
xna::PresentationParameters _presentationParameters;
|
||||
sptr<xna::PresentationParameters> _presentationParameters;
|
||||
|
||||
private:
|
||||
unsigned int _createDeviceFlags{ 0 };
|
||||
|
@ -30,6 +30,7 @@
|
||||
//Windows
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <Windows.Foundation.h>
|
||||
#include <wrl\wrappers\corewrappers.h>
|
||||
#include <wrl\client.h>
|
@ -1,53 +0,0 @@
|
||||
#ifndef XNA_PLATFORM_GDEVICEINFOR_DX_HPP
|
||||
#define XNA_PLATFORM_GDEVICEINFOR_DX_HPP
|
||||
|
||||
#include "../game/gdeviceinfo.hpp"
|
||||
#include "window-dx.hpp"
|
||||
#include "graphics/presentparams.hpp"
|
||||
|
||||
namespace xna {
|
||||
class GraphicsDeviceInformation : public IGraphicsDeviceInformation {
|
||||
public:
|
||||
virtual ~GraphicsDeviceInformation() override {}
|
||||
|
||||
inline virtual sptr<GraphicsAdapter> Adapter() const override {
|
||||
return _adapter;
|
||||
};
|
||||
|
||||
inline virtual void Adapter(sptr<GraphicsAdapter> const& value) override {
|
||||
_adapter = value;
|
||||
}
|
||||
|
||||
virtual xna::PresentationParameters PresentationParameters() const override{
|
||||
return _parameters;
|
||||
};
|
||||
|
||||
virtual void PresentationParameters(xna::PresentationParameters const& value) override{
|
||||
_parameters = value;
|
||||
};
|
||||
|
||||
virtual xna::GraphicsProfile GraphicsProfile() const override {
|
||||
return _profile;
|
||||
};
|
||||
|
||||
virtual void GraphicsProfile(xna::GraphicsProfile value) override {
|
||||
_profile = value;
|
||||
};
|
||||
|
||||
inline virtual sptr<GameWindow> Window() const override {
|
||||
return _window;
|
||||
}
|
||||
|
||||
inline virtual void Window(sptr<GameWindow> const& window) override {
|
||||
_window = window;
|
||||
}
|
||||
|
||||
public:
|
||||
sptr<GraphicsAdapter> _adapter{ nullptr };
|
||||
xna::GraphicsProfile _profile{xna::GraphicsProfile::Reach};
|
||||
xna::PresentationParameters _parameters{};
|
||||
sptr<GameWindow> _window{ nullptr };
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -2,7 +2,7 @@
|
||||
#define XNA_PLATFORM_GDEVICEMANAGER_DX_HPP
|
||||
|
||||
#include "../game/gdevicemanager.hpp"
|
||||
#include "gdeviceinfo-dx.hpp"
|
||||
#include "game/gdeviceinfo.hpp"
|
||||
|
||||
namespace xna {
|
||||
class GraphicsDeviceManager : public IGraphicsDeviceManager {
|
||||
|
@ -2,11 +2,11 @@
|
||||
#define XNA_PLATFORM_DX_IMPLEMENTATIONS_HPP
|
||||
|
||||
#include "dxheaders.hpp"
|
||||
#include "platform-dx/device-dx.hpp"
|
||||
#include "graphics/adapter.hpp"
|
||||
#include "graphics/blendstate.hpp"
|
||||
#include "graphics/buffer.hpp"
|
||||
#include "graphics/depthstencilstate.hpp"
|
||||
#include "graphics/device.hpp"
|
||||
#include "graphics/displaymode.hpp"
|
||||
#include "graphics/sprite.hpp"
|
||||
#include "graphics/samplerstate.hpp"
|
||||
@ -19,7 +19,7 @@
|
||||
#include "graphics/swapchain.hpp"
|
||||
#include "graphics/texture.hpp"
|
||||
#include "graphics/rendertarget.hpp"
|
||||
#include "device-dx.hpp"
|
||||
#include "game/window.hpp"
|
||||
|
||||
namespace xna {
|
||||
struct SpriteFont::PlatformImplementation {
|
||||
@ -345,6 +345,118 @@ namespace xna {
|
||||
ID3D11InputLayout* _inputLayout{ nullptr };
|
||||
std::vector<D3D11_INPUT_ELEMENT_DESC> _description{};
|
||||
};
|
||||
|
||||
enum class GameWindowMode : UINT {
|
||||
Fullscreen = WS_POPUP | WS_VISIBLE,
|
||||
Windowed = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE,
|
||||
Borderless = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,
|
||||
};
|
||||
|
||||
struct GameWindow::PlatformImplementation {
|
||||
public:
|
||||
constexpr void Mode(GameWindowMode mode) {
|
||||
_windowStyle = static_cast<int>(mode);
|
||||
}
|
||||
|
||||
constexpr GameWindowMode Mode() const {
|
||||
return static_cast<GameWindowMode>(_windowStyle);
|
||||
}
|
||||
|
||||
void Position(int width, int height, bool update = true);
|
||||
void Size(int width, int height, bool update = true);
|
||||
|
||||
inline HINSTANCE HInstance() const {
|
||||
return _hInstance;
|
||||
}
|
||||
|
||||
inline HWND WindowHandle() const {
|
||||
return _windowHandle;
|
||||
}
|
||||
|
||||
constexpr int Width() const {
|
||||
return _windowWidth;
|
||||
}
|
||||
|
||||
constexpr int Height() const {
|
||||
return _windowHeight;
|
||||
}
|
||||
|
||||
inline void Icon(unsigned int icon) {
|
||||
_windowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon));
|
||||
}
|
||||
|
||||
inline void Icon(HICON icon) {
|
||||
_windowIcon = icon;
|
||||
}
|
||||
|
||||
inline void Cursor(unsigned int cursor) {
|
||||
_windowCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(cursor));
|
||||
}
|
||||
|
||||
inline void Cursor(HCURSOR cursor) {
|
||||
_windowCursor = cursor;
|
||||
}
|
||||
|
||||
constexpr float CenterX() const {
|
||||
return _windowCenterX;
|
||||
}
|
||||
|
||||
constexpr float CenterY() const {
|
||||
return _windowCenterY;
|
||||
}
|
||||
|
||||
inline void CursorVisibility(bool visible) const {
|
||||
ShowCursor(visible);
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
||||
}
|
||||
|
||||
constexpr COLORREF Color() const {
|
||||
return _windowColor;
|
||||
}
|
||||
|
||||
constexpr void Color(COLORREF color) {
|
||||
_windowColor = color;
|
||||
}
|
||||
|
||||
constexpr void Color(BYTE r, BYTE g, BYTE b) {
|
||||
_windowColor = RGB(r, g, b);
|
||||
}
|
||||
|
||||
bool Create();
|
||||
bool Update();
|
||||
|
||||
static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
friend class GameWindow;
|
||||
|
||||
HINSTANCE _hInstance{ nullptr };
|
||||
HWND _windowHandle{ nullptr };
|
||||
int _windowWidth{ 800 };
|
||||
int _windowHeight{ 600 };
|
||||
HICON _windowIcon{ nullptr };
|
||||
HCURSOR _windowCursor{ nullptr };
|
||||
COLORREF _windowColor{ RGB(0,0,0) };
|
||||
String _windowTitle{ "Xna++ Game Development" };
|
||||
DWORD _windowStyle{ 0 };
|
||||
int _windowPosX{ 0 };
|
||||
int _windowPosY{ 0 };
|
||||
float _windowCenterX{ 0 };
|
||||
float _windowCenterY{ 0 };
|
||||
|
||||
inline void setPosition() {
|
||||
_windowPosX = GetSystemMetrics(SM_CXSCREEN) / 2 - _windowWidth / 2;
|
||||
_windowPosY = GetSystemMetrics(SM_CYSCREEN) / 2 - _windowHeight / 2;
|
||||
}
|
||||
|
||||
inline void setCenter() {
|
||||
_windowCenterX = _windowWidth / 2.0f;
|
||||
_windowCenterY = _windowHeight / 2.0f;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,129 +0,0 @@
|
||||
#ifndef XNA_PLATFORM_WINDOW_DX_HPP
|
||||
#define XNA_PLATFORM_WINDOW_DX_HPP
|
||||
|
||||
#include "../game/window.hpp"
|
||||
#include <Windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
namespace xna {
|
||||
|
||||
enum class GameWindowMode : UINT {
|
||||
Fullscreen = WS_POPUP | WS_VISIBLE,
|
||||
Windowed = WS_OVERLAPPED | WS_SYSMENU | WS_VISIBLE,
|
||||
Borderless = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE,
|
||||
};
|
||||
|
||||
class GameWindow : public IGameWindow {
|
||||
public:
|
||||
GameWindow();
|
||||
|
||||
constexpr void Mode(GameWindowMode mode) {
|
||||
_windowStyle = static_cast<int>(mode);
|
||||
}
|
||||
|
||||
constexpr GameWindowMode Mode() const {
|
||||
return static_cast<GameWindowMode>(_windowStyle);
|
||||
}
|
||||
|
||||
void Position(int width, int height, bool update = true);
|
||||
void Size(int width, int height, bool update = true);
|
||||
|
||||
inline HINSTANCE HInstance() const {
|
||||
return _hInstance;
|
||||
}
|
||||
|
||||
inline HWND WindowHandle() const {
|
||||
return _windowHandle;
|
||||
}
|
||||
|
||||
inline int Width() const {
|
||||
return _windowWidth;
|
||||
}
|
||||
|
||||
inline int Height() const {
|
||||
return _windowHeight;
|
||||
}
|
||||
|
||||
inline void Icon(unsigned int icon) {
|
||||
_windowIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(icon));
|
||||
}
|
||||
|
||||
inline void Icon(HICON icon) {
|
||||
_windowIcon = icon;
|
||||
}
|
||||
|
||||
inline void Cursor(unsigned int cursor) {
|
||||
_windowCursor = LoadCursor(GetModuleHandle(NULL), MAKEINTRESOURCE(cursor));
|
||||
}
|
||||
|
||||
inline void Cursor(HCURSOR cursor) {
|
||||
_windowCursor = cursor;
|
||||
}
|
||||
|
||||
inline float CenterX() const {
|
||||
return _windowCenterX;
|
||||
}
|
||||
|
||||
inline float CenterY() const {
|
||||
return _windowCenterY;
|
||||
}
|
||||
|
||||
inline void CursorVisibility(bool visible) const {
|
||||
ShowCursor(visible);
|
||||
}
|
||||
|
||||
inline void Close() {
|
||||
PostMessage(_windowHandle, WM_DESTROY, 0, 0);
|
||||
}
|
||||
|
||||
inline COLORREF Color() const {
|
||||
return _windowColor;
|
||||
}
|
||||
|
||||
inline void Color(COLORREF color) {
|
||||
_windowColor = color;
|
||||
}
|
||||
|
||||
inline void Color(BYTE r, BYTE g, BYTE b) {
|
||||
_windowColor = RGB(r, g, b);
|
||||
}
|
||||
|
||||
bool Create();
|
||||
bool Update();
|
||||
|
||||
static LRESULT CALLBACK WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
virtual String Title() const override;
|
||||
virtual void Title(String const& title) override;
|
||||
virtual Rectangle ClientBounds() const override;
|
||||
virtual intptr_t Handle() const override;
|
||||
|
||||
private:
|
||||
HINSTANCE _hInstance{ nullptr };
|
||||
HWND _windowHandle{ nullptr };
|
||||
int _windowWidth{ 800 };
|
||||
int _windowHeight{ 600 };
|
||||
HICON _windowIcon{ nullptr };
|
||||
HCURSOR _windowCursor{ nullptr };
|
||||
COLORREF _windowColor{ RGB(0,0,0) };
|
||||
String _windowTitle{ "Xna++ Game Development" };
|
||||
DWORD _windowStyle{ 0 };
|
||||
int _windowPosX{ 0 };
|
||||
int _windowPosY{ 0 };
|
||||
float _windowCenterX{ 0 };
|
||||
float _windowCenterY{ 0 };
|
||||
|
||||
private:
|
||||
inline void setPosition() {
|
||||
_windowPosX = GetSystemMetrics(SM_CXSCREEN) / 2 - _windowWidth / 2;
|
||||
_windowPosY = GetSystemMetrics(SM_CYSCREEN) / 2 - _windowHeight / 2;
|
||||
}
|
||||
|
||||
inline void setCenter() {
|
||||
_windowCenterX = _windowWidth / 2.0f;
|
||||
_windowCenterY = _windowHeight / 2.0f;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -4,9 +4,7 @@
|
||||
#include "dx/StepTimer.hpp"
|
||||
#include "dxheaders.hpp"
|
||||
#include "game-dx.hpp"
|
||||
#include "gdeviceinfo-dx.hpp"
|
||||
#include "gdevicemanager-dx.hpp"
|
||||
#include "init-dx.hpp"
|
||||
#include "soundeffect-dx.hpp"
|
||||
#include "window-dx.hpp"
|
||||
#include "implementations.hpp"
|
Loading…
x
Reference in New Issue
Block a user