|
|
@ -12,10 +12,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "../driver.h"
|
|
|
|
#include "../driver.h"
|
|
|
|
#include "../core/geometry_type.hpp"
|
|
|
|
#include "../core/geometry_type.hpp"
|
|
|
|
|
|
|
|
#include "../core/math_func.hpp"
|
|
|
|
#include <vector>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern std::string _ini_videodriver;
|
|
|
|
|
|
|
|
extern std::vector<Dimension> _resolutions;
|
|
|
|
|
|
|
|
extern Dimension _cur_resolution;
|
|
|
|
|
|
|
|
extern bool _rightclick_emulate;
|
|
|
|
|
|
|
|
|
|
|
|
/** The base of all video drivers. */
|
|
|
|
/** The base of all video drivers. */
|
|
|
|
class VideoDriver : public Driver {
|
|
|
|
class VideoDriver : public Driver {
|
|
|
|
|
|
|
|
const uint DEFAULT_WINDOW_WIDTH = 640u; ///< Default window width.
|
|
|
|
|
|
|
|
const uint DEFAULT_WINDOW_HEIGHT = 480u; ///< Default window height.
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Mark a particular area dirty.
|
|
|
|
* Mark a particular area dirty.
|
|
|
@ -102,11 +111,27 @@ public:
|
|
|
|
static VideoDriver *GetInstance() {
|
|
|
|
static VideoDriver *GetInstance() {
|
|
|
|
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
|
|
|
|
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern std::string _ini_videodriver;
|
|
|
|
protected:
|
|
|
|
extern std::vector<Dimension> _resolutions;
|
|
|
|
/*
|
|
|
|
extern Dimension _cur_resolution;
|
|
|
|
* Get the resolution of the main screen.
|
|
|
|
extern bool _rightclick_emulate;
|
|
|
|
*/
|
|
|
|
|
|
|
|
virtual Dimension GetScreenSize() const { return { DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT }; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Apply resolution auto-detection and clamp to sensible defaults.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void UpdateAutoResolution()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_cur_resolution.width == 0 || _cur_resolution.height == 0) {
|
|
|
|
|
|
|
|
/* Auto-detect a good resolution. We aim for 75% of the screen size.
|
|
|
|
|
|
|
|
* Limit width times height times bytes per pixel to fit a 32 bit
|
|
|
|
|
|
|
|
* integer, This way all internal drawing routines work correctly. */
|
|
|
|
|
|
|
|
Dimension res = this->GetScreenSize();
|
|
|
|
|
|
|
|
_cur_resolution.width = ClampU(res.width * 3 / 4, DEFAULT_WINDOW_WIDTH, UINT16_MAX / 2);
|
|
|
|
|
|
|
|
_cur_resolution.height = ClampU(res.height * 3 / 4, DEFAULT_WINDOW_HEIGHT, UINT16_MAX / 2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* VIDEO_VIDEO_DRIVER_HPP */
|
|
|
|
#endif /* VIDEO_VIDEO_DRIVER_HPP */
|
|
|
|