From f5248bda8a70a90afcecdaf46cf1c218f38fafcc Mon Sep 17 00:00:00 2001 From: kichikuou Date: Thu, 10 Sep 2020 15:42:27 +0900 Subject: [PATCH] Merge sdl_mode.c to sdl_video.c --- CMakeLists.txt | 2 +- src/sdl_mode.c | 75 ------------------------------------------------- src/sdl_video.c | 37 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 76 deletions(-) delete mode 100644 src/sdl_mode.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c7cbec..85ad994 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,7 @@ if (X11_FOUND) set(SRC_GRAPHDEV xcore_draw.c xcore_video.c xcore_mode.c xcore_event.c xcore_cursor.c xcore_maskupdate.c image.c xcore_image.c) set(SUMMARY_GRAPHDEV "X11") elseif (SDL2_FOUND) - set(SRC_GRAPHDEV sdl_video.c sdl_mode.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c) + set(SRC_GRAPHDEV sdl_video.c sdl_draw.c sdl_event.c sdl_image.c sdl_cursor.c image.c) set(SUMMARY_GRAPHDEV "SDL2") set(ENABLE_SDL 1) else() diff --git a/src/sdl_mode.c b/src/sdl_mode.c deleted file mode 100644 index 7ffdf84..0000000 --- a/src/sdl_mode.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * sdl_darw.c SDL video mode and full-screen - * - * Copyright (C) 2000- Fumihiko Murata - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * -*/ -/* $Id: sdl_mode.c,v 1.6 2003/01/04 17:01:02 chikama Exp $ */ - -#include "config.h" - -#include -#include -#include -#ifdef __EMSCRIPTEN__ -#include -#endif - -#include "portab.h" -#include "system.h" -#include "sdl_private.h" - - -void sdl_FullScreen(boolean on) { - - if (on && !sdl_fs_on) { - sdl_fs_on = TRUE; - SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP); - } else if (!on && sdl_fs_on) { - sdl_fs_on = FALSE; - SDL_SetWindowFullscreen(sdl_window, 0); - } -} - - -/* Windowの大きさの変更 */ -void sdl_setWindowSize(int x, int y, int w, int h) { - view_x = x; - view_y = y; - - if (w == view_w && h == view_h) return; - - view_w = w; - view_h = h; - -#ifndef __ANDROID__ - SDL_SetWindowSize(sdl_window, w, h); -#endif - SDL_RenderSetLogicalSize(sdl_renderer, w, h); - if (sdl_display) - SDL_FreeSurface(sdl_display); - if (sdl_texture) - SDL_DestroyTexture(sdl_texture); - sdl_display = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0); - sdl_texture = SDL_CreateTexture(sdl_renderer, sdl_display->format->format, - SDL_TEXTUREACCESS_STATIC, w, h); - - //ms_active = (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ? TRUE : FALSE; -#ifdef __EMSCRIPTEN__ - EM_ASM( xsystem35.shell.windowSizeChanged(); ); -#endif -} diff --git a/src/sdl_video.c b/src/sdl_video.c index 58cdb71..ee9a576 100644 --- a/src/sdl_video.c +++ b/src/sdl_video.c @@ -206,6 +206,43 @@ void sdl_setAutoRepeat(boolean bool) { } } +void sdl_FullScreen(boolean on) { + if (on && !sdl_fs_on) { + sdl_fs_on = TRUE; + SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP); + } else if (!on && sdl_fs_on) { + sdl_fs_on = FALSE; + SDL_SetWindowFullscreen(sdl_window, 0); + } +} + +void sdl_setWindowSize(int x, int y, int w, int h) { + view_x = x; + view_y = y; + + if (w == view_w && h == view_h) return; + + view_w = w; + view_h = h; + +#ifndef __ANDROID__ + SDL_SetWindowSize(sdl_window, w, h); +#endif + SDL_RenderSetLogicalSize(sdl_renderer, w, h); + if (sdl_display) + SDL_FreeSurface(sdl_display); + if (sdl_texture) + SDL_DestroyTexture(sdl_texture); + sdl_display = SDL_CreateRGBSurface(0, w, h, 32, 0, 0, 0, 0); + sdl_texture = SDL_CreateTexture(sdl_renderer, sdl_display->format->format, + SDL_TEXTUREACCESS_STATIC, w, h); + + //ms_active = (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ? TRUE : FALSE; +#ifdef __EMSCRIPTEN__ + EM_ASM( xsystem35.shell.windowSizeChanged(); ); +#endif +} + #ifdef __EMSCRIPTEN__ void* EMSCRIPTEN_KEEPALIVE sdl_getDisplaySurface() {