mirror of https://github.com/encounter/SDL.git
Add SDL_GetDisplayDPI implementation on Emscripten
Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
This commit is contained in:
parent
f03215bc70
commit
41e7d1baa6
|
@ -43,6 +43,7 @@ static int Emscripten_VideoInit(_THIS);
|
||||||
static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||||
static void Emscripten_VideoQuit(_THIS);
|
static void Emscripten_VideoQuit(_THIS);
|
||||||
static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
static int Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect);
|
||||||
|
static int Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi, float * hdpi, float * vdpi);
|
||||||
|
|
||||||
static int Emscripten_CreateWindow(_THIS, SDL_Window * window);
|
static int Emscripten_CreateWindow(_THIS, SDL_Window * window);
|
||||||
static void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
|
static void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
|
||||||
|
@ -82,6 +83,7 @@ Emscripten_CreateDevice(int devindex)
|
||||||
device->VideoInit = Emscripten_VideoInit;
|
device->VideoInit = Emscripten_VideoInit;
|
||||||
device->VideoQuit = Emscripten_VideoQuit;
|
device->VideoQuit = Emscripten_VideoQuit;
|
||||||
device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds;
|
device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds;
|
||||||
|
device->GetDisplayDPI = Emscripten_GetDisplayDPI;
|
||||||
device->SetDisplayMode = Emscripten_SetDisplayMode;
|
device->SetDisplayMode = Emscripten_SetDisplayMode;
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,6 +184,27 @@ Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect *
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
Emscripten_GetDisplayDPI(_THIS, SDL_VideoDisplay * display, float * ddpi_out, float * hdpi_out, float * vdpi_out)
|
||||||
|
{
|
||||||
|
const float dpi_reference = 96.0f;
|
||||||
|
float dpi;
|
||||||
|
|
||||||
|
dpi = (float)emscripten_get_device_pixel_ratio() * dpi_reference;
|
||||||
|
|
||||||
|
if (ddpi_out) {
|
||||||
|
*ddpi_out = dpi;
|
||||||
|
}
|
||||||
|
if (hdpi_out) {
|
||||||
|
*hdpi_out = dpi;
|
||||||
|
}
|
||||||
|
if (vdpi_out) {
|
||||||
|
*vdpi_out = dpi;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
Emscripten_PumpEvents(_THIS)
|
Emscripten_PumpEvents(_THIS)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue