mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Correções em GraphicsDeviceManager
This commit is contained in:
parent
dd43a0c1ed
commit
1fe092449f
@ -6,16 +6,16 @@ namespace xna {
|
|||||||
GraphicsDeviceManager::GraphicsDeviceManager(sptr<Game> const& game) : game(game)
|
GraphicsDeviceManager::GraphicsDeviceManager(sptr<Game> const& game) : game(game)
|
||||||
{
|
{
|
||||||
sptr<GraphicsAdapter> adp = GraphicsAdapter::DefaultAdapter();
|
sptr<GraphicsAdapter> adp = GraphicsAdapter::DefaultAdapter();
|
||||||
_information.Adapter = adp;
|
information.Adapter = adp;
|
||||||
_information.Profile = xna::GraphicsProfile::HiDef;
|
information.Profile = xna::GraphicsProfile::HiDef;
|
||||||
|
|
||||||
auto parameters = snew<PresentationParameters>();
|
auto parameters = snew<PresentationParameters>();
|
||||||
parameters->BackBufferWidth = backBufferWidth;
|
parameters->BackBufferWidth = backBufferWidth;
|
||||||
parameters->BackBufferHeight = backBufferHeight;
|
parameters->BackBufferHeight = backBufferHeight;
|
||||||
parameters->BackBufferFormat = SurfaceFormat::Color;
|
parameters->BackBufferFormat = SurfaceFormat::Color;
|
||||||
parameters->IsFullscreen = false;
|
parameters->IsFullscreen = false;
|
||||||
_information.PresentParameters = parameters;
|
information.PresentParameters = parameters;
|
||||||
_information.Window = game->Window();
|
information.Window = game->Window();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsDeviceManager::ApplyChanges() {
|
void GraphicsDeviceManager::ApplyChanges() {
|
||||||
|
@ -9,16 +9,16 @@ namespace xna {
|
|||||||
struct IGraphicsDeviceService {
|
struct IGraphicsDeviceService {
|
||||||
virtual sptr<GraphicsDevice> GetGraphicsDevice() = 0;
|
virtual sptr<GraphicsDevice> GetGraphicsDevice() = 0;
|
||||||
|
|
||||||
EventHandler<EventArgs> DeviceDisposing;
|
//EventHandler<EventArgs> DeviceDisposing;
|
||||||
EventHandler<EventArgs> DeviceReset;
|
//EventHandler<EventArgs> DeviceReset;
|
||||||
EventHandler<EventArgs> DeviceResetting;
|
//EventHandler<EventArgs> DeviceResetting;
|
||||||
EventHandler<EventArgs> DeviceCreated;
|
//EventHandler<EventArgs> DeviceCreated;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IGraphicsDeviceManager {
|
class IGraphicsDeviceManager {
|
||||||
virtual void CreateDevice() = 0;
|
virtual void CreateDevice() = 0;
|
||||||
virtual bool BeginDraw() = 0;
|
//virtual bool BeginDraw() = 0;
|
||||||
virtual void EndDraw() = 0;
|
//virtual void EndDraw() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GraphicsDeviceManager : public IGraphicsDeviceService, public IGraphicsDeviceManager {
|
class GraphicsDeviceManager : public IGraphicsDeviceService, public IGraphicsDeviceManager {
|
||||||
@ -104,10 +104,12 @@ namespace xna {
|
|||||||
isDeviceDirty = true;
|
isDeviceDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets a value that indicates whether to enable a multisampled back buffer.
|
||||||
constexpr bool PreferMultiSampling() const {
|
constexpr bool PreferMultiSampling() const {
|
||||||
return allowMultiSampling;
|
return allowMultiSampling;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Gets or sets a value that indicates whether to enable a multisampled back buffer.
|
||||||
constexpr void PreferMultiSampling(bool value) {
|
constexpr void PreferMultiSampling(bool value) {
|
||||||
allowMultiSampling = value;
|
allowMultiSampling = value;
|
||||||
isDeviceDirty = true;
|
isDeviceDirty = true;
|
||||||
@ -138,36 +140,22 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
//Applies any changes to device-related properties, changing the graphics device as necessary.
|
//Applies any changes to device-related properties, changing the graphics device as necessary.
|
||||||
void ApplyChanges();
|
void ApplyChanges();
|
||||||
bool Initialize();
|
//Toggles between full screen and windowed mode.
|
||||||
bool ToggleFullScreen();
|
bool ToggleFullScreen();
|
||||||
|
|
||||||
inline void CreateDevice() { ChangeDevice(true); }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline virtual void RankDevices(std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) {
|
inline virtual void RankDevices(std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) { RankDevicesPlatform(foundDevices); }
|
||||||
RankDevicesPlatform(foundDevices);
|
inline virtual sptr<GraphicsDeviceInformation> FindBestDevice(bool anySuitableDevice) { return FindBestPlatformDevice(anySuitableDevice); }
|
||||||
}
|
|
||||||
|
|
||||||
inline virtual sptr<GraphicsDeviceInformation> FindBestDevice(bool anySuitableDevice) {
|
|
||||||
return FindBestPlatformDevice(anySuitableDevice);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool CanResetDevice(GraphicsDeviceInformation& newDeviceInfo);
|
virtual bool CanResetDevice(GraphicsDeviceInformation& newDeviceInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
inline void CreateDevice() { ChangeDevice(true); }
|
||||||
void ChangeDevice(bool forceCreate);
|
void ChangeDevice(bool forceCreate);
|
||||||
void AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
void AddDevices(bool anySuitableDevice, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
||||||
void AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) const;
|
void AddDevices(GraphicsAdapter const& adapter, DisplayMode const& mode, sptr<GraphicsDeviceInformation>& baseDeviceInfo, std::vector<sptr<GraphicsDeviceInformation>>& foundDevices) const;
|
||||||
|
|
||||||
bool BeginDraw() override { return false; }
|
|
||||||
void EndDraw() override{ }
|
|
||||||
|
|
||||||
sptr<GraphicsDeviceInformation> FindBestPlatformDevice(bool anySuitableDevice);
|
sptr<GraphicsDeviceInformation> FindBestPlatformDevice(bool anySuitableDevice);
|
||||||
|
|
||||||
void RankDevicesPlatform(std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
void RankDevicesPlatform(std::vector<sptr<GraphicsDeviceInformation>>& foundDevices);
|
||||||
|
void CreateDevice(GraphicsDeviceInformation& newInfo);
|
||||||
void CreateDevice(GraphicsDeviceInformation& newInfo);
|
|
||||||
|
|
||||||
void MassagePresentParameters(PresentationParameters& pp);
|
void MassagePresentParameters(PresentationParameters& pp);
|
||||||
void ValidateGraphicsDeviceInformation(GraphicsDeviceInformation& devInfo);
|
void ValidateGraphicsDeviceInformation(GraphicsDeviceInformation& devInfo);
|
||||||
|
|
||||||
@ -175,8 +163,7 @@ namespace xna {
|
|||||||
sptr<Game> game = nullptr;
|
sptr<Game> game = nullptr;
|
||||||
bool isDeviceDirty{ false };
|
bool isDeviceDirty{ false };
|
||||||
sptr<GraphicsDevice> device = nullptr;
|
sptr<GraphicsDevice> device = nullptr;
|
||||||
GraphicsDeviceInformation _information{};
|
GraphicsDeviceInformation information{};
|
||||||
|
|
||||||
bool isFullScreen{ false };
|
bool isFullScreen{ false };
|
||||||
Int backBufferWidth{ DefaultBackBufferWidth };
|
Int backBufferWidth{ DefaultBackBufferWidth };
|
||||||
Int backBufferHeight{ DefaultBackBufferHeight };
|
Int backBufferHeight{ DefaultBackBufferHeight };
|
||||||
@ -192,7 +179,6 @@ namespace xna {
|
|||||||
bool inDeviceTransition{ false };
|
bool inDeviceTransition{ false };
|
||||||
bool isReallyFullScreen{ false };
|
bool isReallyFullScreen{ false };
|
||||||
DisplayOrientation currentWindowOrientation{ DisplayOrientation::Default };
|
DisplayOrientation currentWindowOrientation{ DisplayOrientation::Default };
|
||||||
|
|
||||||
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
std::vector<sptr<GraphicsDeviceInformation>> foundDevices;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user