21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_EMSCRIPTEN 28 #include "../SDL_sysvideo.h" 29 #include "../SDL_pixels_c.h" 30 #include "../SDL_egl_c.h" 31 #include "../../events/SDL_events_c.h" 39 #define EMSCRIPTENVID_DRIVER_NAME "emscripten" 42 static int Emscripten_VideoInit(
_THIS);
44 static void Emscripten_VideoQuit(
_THIS);
50 static void Emscripten_PumpEvents(
_THIS);
57 Emscripten_Available(
void)
69 Emscripten_CreateDevice(
int devindex)
113 #if SDL_VIDEO_OPENGL_EGL 126 device->
free = Emscripten_DeleteDevice;
132 EMSCRIPTENVID_DRIVER_NAME,
"SDL emscripten video driver",
133 Emscripten_Available, Emscripten_CreateDevice
138 Emscripten_VideoInit(
_THIS)
145 mode.
w = EM_ASM_INT_V({
149 mode.
h = EM_ASM_INT_V({
176 Emscripten_VideoQuit(
_THIS)
182 Emscripten_PumpEvents(
_THIS)
191 double scaled_w, scaled_h;
201 wdata->
pixel_ratio = emscripten_get_device_pixel_ratio();
209 emscripten_set_canvas_size(scaled_w, scaled_h);
211 emscripten_get_element_css_size(
NULL, &css_w, &css_h);
220 emscripten_set_canvas_size(scaled_w, scaled_h);
228 emscripten_set_element_css_size(
NULL, window->
w, window->
h);
232 #if SDL_VIDEO_OPENGL_EGL 234 if (!
_this->egl_data) {
242 return SDL_SetError(
"Could not create GLES window surface");
270 data->
pixel_ratio = emscripten_get_device_pixel_ratio();
276 emscripten_set_element_css_size(
NULL, window->
w, window->
h);
290 #if SDL_VIDEO_OPENGL_EGL 309 EmscriptenFullscreenStrategy strategy;
313 strategy.scaleMode = is_desktop_fullscreen ? EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH : EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT;
315 if(!is_desktop_fullscreen) {
316 strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE;
318 strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF;
320 strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF;
323 strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT;
326 strategy.canvasResizedCallbackUserData =
data;
331 res = emscripten_request_fullscreen_strategy(
NULL, 1, &strategy);
332 if(res != EMSCRIPTEN_RESULT_SUCCESS && res != EMSCRIPTEN_RESULT_DEFERRED) {
338 emscripten_exit_fullscreen();
345 if (typeof Module[
'setWindowTitle'] !==
'undefined') {
346 Module[
'setWindowTitle'](Module[
'Pointer_stringify']($0));
void SDL_SetKeyboardFocus(SDL_Window *window)
EM_BOOL Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData)
void Emscripten_FiniMouse()
#define SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS
Minimize your SDL_Window if it loses key focus when in fullscreen mode. Defaults to true...
int SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode)
int(* GL_SetSwapInterval)(_THIS, int interval)
The structure that defines a display mode.
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d ®2 endm macro vzip8 reg2 vzip d d ®2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld [DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp local skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
void(* SetWindowSize)(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
VideoBootStrap Emscripten_bootstrap
void SDL_SetMouseFocus(SDL_Window *window)
void Emscripten_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
#define SDL_GL_LoadLibrary
void Emscripten_RegisterEventHandlers(SDL_WindowData *data)
int(* GL_LoadLibrary)(_THIS, const char *path)
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void(* GL_GetDrawableSize)(_THIS, SDL_Window *window, int *w, int *h)
static SDL_VideoDevice * _this
static SDL_AudioDeviceID device
int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
SDL_VideoDisplay * displays
void(* DestroyWindow)(_THIS, SDL_Window *window)
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
void(* GL_UnloadLibrary)(_THIS)
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
int requested_fullscreen_mode
EGLSurface EGLNativeWindowType * window
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
The type used to identify a window.
SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
void Emscripten_UnregisterEventHandlers(SDL_WindowData *data)
int(* GL_GetSwapInterval)(_THIS)
int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
SDL_bool fullscreen_resize
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
void Emscripten_InitMouse()
void(* PumpEvents)(_THIS)