CVideo: added getter for current DPI scale factor
This commit is contained in:
parent
3230c42cbb
commit
3a301db7d4
2 changed files with 21 additions and 0 deletions
|
@ -28,6 +28,8 @@ static lg::log_domain log_display("display");
|
|||
#define LOG_DP LOG_STREAM(info, log_display)
|
||||
#define ERR_DP LOG_STREAM(err, log_display)
|
||||
|
||||
#define MAGIC_DPI_SCALE_NUMBER 96
|
||||
|
||||
CVideo* CVideo::singleton_ = nullptr;
|
||||
|
||||
namespace {
|
||||
|
@ -342,6 +344,23 @@ sdl::window *CVideo::get_window()
|
|||
return window.get();
|
||||
}
|
||||
|
||||
std::pair<int, int> CVideo::get_dpi_scale_factor() const
|
||||
{
|
||||
std::pair<int, int> result;
|
||||
|
||||
if(!window) {
|
||||
return result;
|
||||
}
|
||||
|
||||
float hdpi, vdpi;
|
||||
SDL_GetDisplayDPI(window->get_display_index(), nullptr, &hdpi, &vdpi);
|
||||
|
||||
result.first = hdpi / MAGIC_DPI_SCALE_NUMBER;
|
||||
result.second = vdpi / MAGIC_DPI_SCALE_NUMBER;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, int>> CVideo::get_available_resolutions(const bool include_current)
|
||||
{
|
||||
std::vector<std::pair<int, int>> result;
|
||||
|
|
|
@ -80,6 +80,8 @@ public:
|
|||
int getx() const;
|
||||
int gety() const;
|
||||
|
||||
std::pair<int, int> get_dpi_scale_factor() const;
|
||||
|
||||
//blits a surface with black as alpha
|
||||
void blit_surface(int x, int y, surface surf, SDL_Rect* srcrect=nullptr, SDL_Rect* clip_rect=nullptr);
|
||||
void flip();
|
||||
|
|
Loading…
Add table
Reference in a new issue