early-access version 2835
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@@ -43,6 +43,7 @@ static int Emscripten_VideoInit(_THIS);
|
||||
static int Emscripten_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
|
||||
static void Emscripten_VideoQuit(_THIS);
|
||||
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 void Emscripten_SetWindowSize(_THIS, SDL_Window * window);
|
||||
@@ -82,6 +83,7 @@ Emscripten_CreateDevice(int devindex)
|
||||
device->VideoInit = Emscripten_VideoInit;
|
||||
device->VideoQuit = Emscripten_VideoQuit;
|
||||
device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds;
|
||||
device->GetDisplayDPI = Emscripten_GetDisplayDPI;
|
||||
device->SetDisplayMode = Emscripten_SetDisplayMode;
|
||||
|
||||
|
||||
@@ -172,16 +174,37 @@ Emscripten_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect *
|
||||
if (rect) {
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
rect->w = EM_ASM_INT_V({
|
||||
rect->w = MAIN_THREAD_EM_ASM_INT({
|
||||
return window.innerWidth;
|
||||
});
|
||||
rect->h = EM_ASM_INT_V({
|
||||
rect->h = MAIN_THREAD_EM_ASM_INT({
|
||||
return window.innerHeight;
|
||||
});
|
||||
}
|
||||
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
|
||||
Emscripten_PumpEvents(_THIS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user