Removes the legacy DirectDraw and Direct3D 9 renderers, and instead adds SDL (Hardware) and renames the existing SDL renderer to SDL (Software).

This commit is contained in:
OBattler
2019-12-05 00:51:07 +01:00
parent 743fafbc8e
commit 26c0a5d2ea
9 changed files with 128 additions and 233 deletions

View File

@@ -8,7 +8,7 @@
* *
* Application resource script for Windows. * Application resource script for Windows.
* *
* Version: @(#)86Box.rc 1.0.54 2019/11/19 * Version: @(#)86Box.rc 1.0.55 2019/12/05
* *
* Authors: Miran Grca, <mgrca8@gmail.com> * Authors: Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
@@ -66,12 +66,11 @@ BEGIN
MENUITEM SEPARATOR MENUITEM SEPARATOR
POPUP "Re&nderer" POPUP "Re&nderer"
BEGIN BEGIN
MENUITEM "&DirectDraw", IDM_VID_DDRAW MENUITEM "&SDL (Software)", IDM_VID_SDL_SW
MENUITEM "&SDL (Hardware)", IDM_VID_SDL_HW
#ifdef USE_D2D #ifdef USE_D2D
MENUITEM "Direct&2D 1.0", IDM_VID_D2D MENUITEM "Direct&2D 1.0", IDM_VID_D2D
#endif #endif
MENUITEM "Direct&3D 9", IDM_VID_D3D
MENUITEM "&SDL", IDM_VID_SDL
#ifdef USE_VNC #ifdef USE_VNC
MENUITEM "&VNC", IDM_VID_VNC MENUITEM "&VNC", IDM_VID_VNC
#endif #endif

View File

@@ -8,7 +8,7 @@
# #
# Makefile for Win32 (MinGW32) environment. # Makefile for Win32 (MinGW32) environment.
# #
# Version: @(#)Makefile.mingw 1.0.138 2019/10/23 # Version: @(#)Makefile.mingw 1.0.139 2019/12/05
# #
# Authors: Miran Grca, <mgrca8@gmail.com> # Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com> # Fred N. van Kempen, <decwiz@yahoo.com>
@@ -369,7 +369,7 @@ ifneq ($(WX), n)
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
else else
UIOBJ := win_ui.o win_stbar.o \ UIOBJ := win_ui.o win_stbar.o \
win_ddraw.o win_d3d.o win_sdl.o \ win_sdl.o \
win_dialog.o win_about.o \ win_dialog.o win_about.o \
win_settings.o win_devconf.o win_snd_gain.o \ win_settings.o win_devconf.o win_snd_gain.o \
win_new_floppy.o win_jsconf.o win_new_floppy.o win_jsconf.o
@@ -688,15 +688,8 @@ ifdef EXOBJ
OBJ += $(EXOBJ) OBJ += $(EXOBJ)
endif endif
LIBS := -mwindows \ LIBS := -mwindows -lcomctl32 \
-lddraw -ldxguid -ld3d9 \ -lopenal -lole32
-lcomctl32
ifeq ($(STATIC), y)
LIBS += -lopenal -lole32 -lwinmm
else
LIBS += -lwinmm -lopenal.dll
endif
ifeq ($(D2D), y) ifeq ($(D2D), y)
LIBS += $(D2DLIB) LIBS += $(D2DLIB)
@@ -710,8 +703,7 @@ endif
ifneq ($(WX), n) ifneq ($(WX), n)
LIBS += $(WX_LIBS) -lm LIBS += $(WX_LIBS) -lm
endif endif
LIBS += -lpng -lz -lwsock32 -liphlpapi -ldinput8 LIBS += -lpng -lz -lwsock32 -liphlpapi -ldinput8 -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -lversion -lwinmm -static -lstdc++
LIBS += -static -lstdc++
ifneq ($(X64), y) ifneq ($(X64), y)
LIBS += -Wl,--large-address-aware LIBS += -Wl,--large-address-aware
endif endif
@@ -719,9 +711,7 @@ ifneq ($(DINPUT), y)
LIBS += -lxinput LIBS += -lxinput
endif endif
ifeq ($(STATIC), y)
LIBS += -static LIBS += -static
endif
# Build module rules. # Build module rules.
ifeq ($(AUTODEP), y) ifeq ($(AUTODEP), y)

View File

@@ -8,7 +8,7 @@
# #
# Makefile for Win32 (MinGW32) environment. # Makefile for Win32 (MinGW32) environment.
# #
# Version: @(#)Makefile.mingw 1.0.138 2019/10/23 # Version: @(#)Makefile.mingw 1.0.139 2019/12/05
# #
# Authors: Miran Grca, <mgrca8@gmail.com> # Authors: Miran Grca, <mgrca8@gmail.com>
# Fred N. van Kempen, <decwiz@yahoo.com> # Fred N. van Kempen, <decwiz@yahoo.com>
@@ -375,7 +375,7 @@ ifneq ($(WX), n)
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
else else
UIOBJ := win_ui.o win_stbar.o \ UIOBJ := win_ui.o win_stbar.o \
win_ddraw.o win_d3d.o win_sdl.o \ win_sdl.o \
win_dialog.o win_about.o \ win_dialog.o win_about.o \
win_settings.o win_devconf.o win_snd_gain.o \ win_settings.o win_devconf.o win_snd_gain.o \
win_new_floppy.o win_jsconf.o win_new_floppy.o win_jsconf.o
@@ -694,15 +694,8 @@ ifdef EXOBJ
OBJ += $(EXOBJ) OBJ += $(EXOBJ)
endif endif
LIBS := -mwindows \ LIBS := -mwindows -lcomctl32 \
-lddraw -ldxguid -ld3d9 \ -lopenal -lole32
-lcomctl32
ifeq ($(STATIC), y)
LIBS += -lopenal -lole32 -lwinmm
else
LIBS += -lwinmm -lopenal.dll
endif
ifeq ($(D2D), y) ifeq ($(D2D), y)
LIBS += $(D2DLIB) LIBS += $(D2DLIB)
@@ -716,8 +709,7 @@ endif
ifneq ($(WX), n) ifneq ($(WX), n)
LIBS += $(WX_LIBS) -lm LIBS += $(WX_LIBS) -lm
endif endif
LIBS += -lpng -lz -lwsock32 -liphlpapi -ldinput8 LIBS += -lpng -lz -lwsock32 -liphlpapi -ldinput8 -lSDL2 -limm32 -lhid -lsetupapi -loleaut32 -lversion -lwinmm -static -lstdc++
LIBS += -static -lstdc++
ifneq ($(X64), y) ifneq ($(X64), y)
LIBS += -Wl,--large-address-aware LIBS += -Wl,--large-address-aware
endif endif
@@ -725,9 +717,7 @@ ifneq ($(DINPUT), y)
LIBS += -lxinput LIBS += -lxinput
endif endif
ifeq ($(STATIC), y)
LIBS += -static LIBS += -static
endif
# Build module rules. # Build module rules.
ifeq ($(AUTODEP), y) ifeq ($(AUTODEP), y)

View File

@@ -8,16 +8,16 @@
* *
* Windows resource defines. * Windows resource defines.
* *
* Version: @(#)resource.h 1.0.30 2019/01/19 * Version: @(#)resource.h 1.0.31 2019/12/05
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
* Fred N. van Kempen, <decwiz@yahoo.com> * Fred N. van Kempen, <decwiz@yahoo.com>
* David Hrdlička, <hrdlickadavid@outlook.com> * David Hrdlička, <hrdlickadavid@outlook.com>
* *
* Copyright 2008-2018 Sarah Walker. * Copyright 2008-2019 Sarah Walker.
* Copyright 2016-2018 Miran Grca. * Copyright 2016-2019 Miran Grca.
* Copyright 2018 David Hrdlička. * Copyright 2018,2019 David Hrdlička.
*/ */
#ifndef WIN_RESOURCE_H #ifndef WIN_RESOURCE_H
# define WIN_RESOURCE_H # define WIN_RESOURCE_H
@@ -266,18 +266,17 @@
#define IDM_UPDATE_ICONS 40030 #define IDM_UPDATE_ICONS 40030
#define IDM_VID_RESIZE 40040 #define IDM_VID_RESIZE 40040
#define IDM_VID_REMEMBER 40041 #define IDM_VID_REMEMBER 40041
#define IDM_VID_DDRAW 40050 #define IDM_VID_SDL_SW 40050
#define IDM_VID_SDL_HW 40051
#ifdef USE_D2D #ifdef USE_D2D
#define IDM_VID_D2D 40051 #define IDM_VID_D2D 40052
#define IDM_VID_D3D 40052
#define IDM_VID_SDL 40053
#define IDM_VID_VNC 40054
#else
#define IDM_VID_D3D 40051
#define IDM_VID_SDL 40052
#ifdef USE_VNC #ifdef USE_VNC
#define IDM_VID_VNC 40053 #define IDM_VID_VNC 40053
#endif #endif
#else
#ifdef USE_VNC
#define IDM_VID_VNC 40052
#endif
#endif #endif
#define IDM_VID_SCALE_1X 40055 #define IDM_VID_SCALE_1X 40055
#define IDM_VID_SCALE_2X 40056 #define IDM_VID_SCALE_2X 40056

View File

@@ -8,7 +8,7 @@
* *
* Platform main support module for Windows. * Platform main support module for Windows.
* *
* Version: @(#)win.c 1.0.59 2019/11/02 * Version: @(#)win.c 1.0.60 2019/12/05
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -43,9 +43,7 @@
#ifdef USE_VNC #ifdef USE_VNC
# include "../vnc.h" # include "../vnc.h"
#endif #endif
# include "win_ddraw.h"
# include "win_d2d.h" # include "win_d2d.h"
# include "win_d3d.h"
# include "win_sdl.h" # include "win_sdl.h"
#include "win.h" #include "win.h"
@@ -87,23 +85,21 @@ static const struct {
void (*enable)(int enable); void (*enable)(int enable);
} vid_apis[2][RENDERERS_NUM] = { } vid_apis[2][RENDERERS_NUM] = {
{ {
{ "DDraw", 1, (int(*)(void*))ddraw_init, ddraw_close, NULL, ddraw_pause, ddraw_enable }, { "SDL_Software", 1, (int(*)(void*))sdl_inits, sdl_close, NULL, sdl_pause, sdl_enable },
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable }
#ifdef USE_D2D #ifdef USE_D2D
{ "D2D", 1, (int(*)(void*))d2d_init, d2d_close, NULL, d2d_pause, d2d_enable }, ,{ "D2D", 1, (int(*)(void*))d2d_init, d2d_close, NULL, d2d_pause, d2d_enable }
#endif #endif
{ "D3D", 1, (int(*)(void*))d3d_init, d3d_close, d3d_resize, d3d_pause, d3d_enable },
{ "SDL", 1, (int(*)(void*))sdl_init, sdl_close, NULL, sdl_pause, sdl_enable }
#ifdef USE_VNC #ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL } ,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL }
#endif #endif
}, },
{ {
{ "DDraw", 1, (int(*)(void*))ddraw_init_fs, ddraw_close, NULL, ddraw_pause, ddraw_enable }, { "SDL_Software", 1, (int(*)(void*))sdl_inits_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable },
{ "SDL_Hardware", 1, (int(*)(void*))sdl_inith_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable }
#ifdef USE_D2D #ifdef USE_D2D
{ "D2D", 1, (int(*)(void*))d2d_init_fs, d2d_close, NULL, d2d_pause, d2d_enable }, ,{ "D2D", 1, (int(*)(void*))d2d_init_fs, d2d_close, NULL, d2d_pause, d2d_enable }
#endif #endif
{ "D3D", 1, (int(*)(void*))d3d_init_fs, d3d_close, NULL, d3d_pause, d3d_enable },
{ "SDL", 1, (int(*)(void*))sdl_init_fs, sdl_close, sdl_resize, sdl_pause, sdl_enable }
#ifdef USE_VNC #ifdef USE_VNC
,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL } ,{ "VNC", 0, vnc_init, vnc_close, vnc_resize, vnc_pause, NULL }
#endif #endif
@@ -664,11 +660,11 @@ plat_vidapi(char *name)
{ {
int i; int i;
#ifdef USE_D2D /* Default/System is SDL Hardware. */
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(2);
#else
if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(1); if (!strcasecmp(name, "default") || !strcasecmp(name, "system")) return(1);
#endif
/* If DirectDraw or plain SDL was specified, return SDL Software. */
if (!strcasecmp(name, "ddraw") || !strcasecmp(name, "sdl")) return(1);
for (i = 0; i < RENDERERS_NUM; i++) { for (i = 0; i < RENDERERS_NUM; i++) {
if (vid_apis[0][i].name && if (vid_apis[0][i].name &&
@@ -676,7 +672,7 @@ plat_vidapi(char *name)
} }
/* Default value. */ /* Default value. */
return(0); return(1);
} }
@@ -688,38 +684,29 @@ plat_vidapi_name(int api)
switch(api) { switch(api) {
case 0: case 0:
name = "ddraw"; name = "sdl_software";
break;
case 1:
break; break;
#ifdef USE_D2D #ifdef USE_D2D
case 1: case 2:
name = "d2d"; name = "d2d";
break; break;
case 2:
break;
case 3:
name = "sdl";
break;
#else
case 1:
break;
case 2:
name = "sdl";
break;
#endif #endif
#ifdef USE_VNC #ifdef USE_VNC
#ifdef USE_D2D #ifdef USE_D2D
case 4:
#else
case 3: case 3:
#else
case 2:
#endif #endif
name = "vnc"; name = "vnc";
break; break;
#endif #endif
default:
fatal("Unknown renderer: %i\n", api);
break;
} }
return(name); return(name);

View File

@@ -8,7 +8,7 @@
* *
* Platform support defintions for Win32. * Platform support defintions for Win32.
* *
* Version: @(#)win.h 1.0.28 2019/11/02 * Version: @(#)win.h 1.0.29 2019/12/05
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -49,8 +49,7 @@
and 0x8895 with WPARAM = <previous pause status> followed by 0x8896 with WPARAM = 0. and 0x8895 with WPARAM = <previous pause status> followed by 0x8896 with WPARAM = 0.
All shutdowns will send an 0x8897. */ All shutdowns will send an 0x8897. */
#define WM_RESETD3D WM_USER #define WM_LEAVEFULLSCREEN WM_USER
#define WM_LEAVEFULLSCREEN WM_USER+1
#define WM_SAVESETTINGS 0x8888 #define WM_SAVESETTINGS 0x8888
#define WM_SHOWSETTINGS 0x8889 #define WM_SHOWSETTINGS 0x8889
#define WM_PAUSE 0x8890 #define WM_PAUSE 0x8890
@@ -67,16 +66,16 @@
#ifdef USE_VNC #ifdef USE_VNC
#ifdef USE_D2D #ifdef USE_D2D
#define RENDERERS_NUM 5
#else
#define RENDERERS_NUM 4
#endif
#else
#ifdef USE_D2D
#define RENDERERS_NUM 4 #define RENDERERS_NUM 4
#else #else
#define RENDERERS_NUM 3 #define RENDERERS_NUM 3
#endif #endif
#else
#ifdef USE_D2D
#define RENDERERS_NUM 3
#else
#define RENDERERS_NUM 2
#endif
#endif #endif

View File

@@ -12,7 +12,7 @@
* we will not use that, but, instead, use a new window which * we will not use that, but, instead, use a new window which
* coverrs the entire desktop. * coverrs the entire desktop.
* *
* Version: @(#)win_sdl.c 1.0.8 2019/10/22 * Version: @(#)win_sdl.c 1.0.9 2019/12/05
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Michael Dr<44>ing, <michael@drueing.de> * Michael Dr<44>ing, <michael@drueing.de>
@@ -72,10 +72,10 @@
#include "win_sdl.h" #include "win_sdl.h"
#define PATH_SDL_DLL "SDL2.dll" #define RENDERER_FULL_SCREEN 1
#define RENDERER_HARDWARE 2
static void *sdl_handle = NULL; /* handle to libSDL2 DLL */
static SDL_Window *sdl_win = NULL; static SDL_Window *sdl_win = NULL;
static SDL_Renderer *sdl_render = NULL; static SDL_Renderer *sdl_render = NULL;
static SDL_Texture *sdl_tex = NULL; static SDL_Texture *sdl_tex = NULL;
@@ -88,71 +88,6 @@ static volatile int sdl_enabled = 0;
static SDL_mutex* sdl_mutex = NULL; static SDL_mutex* sdl_mutex = NULL;
/* Pointers to the real functions. */
static void (*sdl_GetVersion)(SDL_version *ver);
static char *const (*sdl_GetError)(void);
static int (*sdl_Init)(Uint32 flags);
static void (*sdl_Quit)(void);
static SDL_Window *(*sdl_CreateWindowFrom)(const void *data);
static void (*sdl_DestroyWindow)(SDL_Window *window);
static SDL_Renderer *(*sdl_CreateRenderer)(SDL_Window *window,
int index, Uint32 flags);
static void (*sdl_DestroyRenderer)(SDL_Renderer *renderer);
static SDL_Texture *(*sdl_CreateTexture)(SDL_Renderer *renderer,
Uint32 format, int access,
int w, int h);
static void (*sdl_DestroyTexture)(SDL_Texture *texture);
static int (*sdl_LockTexture)(SDL_Texture *texture,
const SDL_Rect *rect,
void **pixels, int *pitch);
static void (*sdl_UnlockTexture)(SDL_Texture *texture);
static int (*sdl_RenderCopy)(SDL_Renderer *renderer,
SDL_Texture *texture,
const SDL_Rect *srcrect,
const SDL_Rect *dstrect);
static void (*sdl_RenderPresent)(SDL_Renderer *renderer);
static void (*sdl_GetWindowSize)(SDL_Window* window,
int* w,
int* h);
static int (*sdl_RenderReadPixels)(SDL_Renderer* renderer,
const SDL_Rect* rect,
Uint32 format,
void* pixels,
int pitch);
static SDL_bool (*sdl_SetHint)(const char* name,
const char* value);
static SDL_mutex* (*sdl_CreateMutex)(void);
static void (*sdl_DestroyMutex)(SDL_mutex* mutex);
static int (*sdl_LockMutex)(SDL_mutex* mutex);
static int (*sdl_UnlockMutex)(SDL_mutex* mutex);
static dllimp_t sdl_imports[] = {
{ "SDL_GetVersion", &sdl_GetVersion },
{ "SDL_GetError", &sdl_GetError },
{ "SDL_Init", &sdl_Init },
{ "SDL_Quit", &sdl_Quit },
{ "SDL_CreateWindowFrom", &sdl_CreateWindowFrom },
{ "SDL_DestroyWindow", &sdl_DestroyWindow },
{ "SDL_CreateRenderer", &sdl_CreateRenderer },
{ "SDL_DestroyRenderer", &sdl_DestroyRenderer },
{ "SDL_CreateTexture", &sdl_CreateTexture },
{ "SDL_DestroyTexture", &sdl_DestroyTexture },
{ "SDL_LockTexture", &sdl_LockTexture },
{ "SDL_UnlockTexture", &sdl_UnlockTexture },
{ "SDL_RenderCopy", &sdl_RenderCopy },
{ "SDL_RenderPresent", &sdl_RenderPresent },
{ "SDL_GetWindowSize", &sdl_GetWindowSize },
{ "SDL_RenderReadPixels", &sdl_RenderReadPixels },
{ "SDL_SetHint", &sdl_SetHint },
{ "SDL_CreateMutex", &sdl_CreateMutex },
{ "SDL_DestroyMutex", &sdl_DestroyMutex },
{ "SDL_LockMutex", &sdl_LockMutex },
{ "SDL_UnlockMutex", &sdl_UnlockMutex },
{ NULL, NULL }
};
#ifdef ENABLE_SDL_LOG #ifdef ENABLE_SDL_LOG
int sdl_do_log = ENABLE_SDL_LOG; int sdl_do_log = ENABLE_SDL_LOG;
@@ -257,14 +192,14 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
return; return;
} }
sdl_LockMutex(sdl_mutex); SDL_LockMutex(sdl_mutex);
/* /*
* TODO: * TODO:
* SDL_UpdateTexture() might be better here, as it is * SDL_UpdateTexture() might be better here, as it is
* (reportedly) slightly faster. * (reportedly) slightly faster.
*/ */
sdl_LockTexture(sdl_tex, 0, &pixeldata, &pitch); SDL_LockTexture(sdl_tex, 0, &pixeldata, &pitch);
for (yy = y1; yy < y2; yy++) { for (yy = y1; yy < y2; yy++) {
if ((y + yy) >= 0 && (y + yy) < buffer32->h) { if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
@@ -277,7 +212,7 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
video_blit_complete(); video_blit_complete();
sdl_UnlockTexture(sdl_tex); SDL_UnlockTexture(sdl_tex);
if (sdl_fs) { if (sdl_fs) {
sdl_log("sdl_blit(%i, %i, %i, %i, %i, %i) (%i, %i)\n", x, y, y1, y2, w, h, unscaled_size_x, efscrnsz_y); sdl_log("sdl_blit(%i, %i, %i, %i, %i, %i) (%i, %i)\n", x, y, y1, y2, w, h, unscaled_size_x, efscrnsz_y);
@@ -291,13 +226,13 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
r_src.w = w; r_src.w = w;
r_src.h = h; r_src.h = h;
ret = sdl_RenderCopy(sdl_render, sdl_tex, &r_src, 0); ret = SDL_RenderCopy(sdl_render, sdl_tex, &r_src, 0);
if (ret) if (ret)
sdl_log("SDL: unable to copy texture to renderer (%s)\n", sdl_GetError()); sdl_log("SDL: unable to copy texture to renderer (%s)\n", sdl_GetError());
sdl_RenderPresent(sdl_render); SDL_RenderPresent(sdl_render);
sdl_UnlockMutex(sdl_mutex); SDL_UnlockMutex(sdl_mutex);
} }
@@ -311,22 +246,22 @@ sdl_close(void)
sdl_enabled = 0; sdl_enabled = 0;
if (sdl_mutex != NULL) { if (sdl_mutex != NULL) {
sdl_DestroyMutex(sdl_mutex); SDL_DestroyMutex(sdl_mutex);
sdl_mutex = NULL; sdl_mutex = NULL;
} }
if (sdl_tex != NULL) { if (sdl_tex != NULL) {
sdl_DestroyTexture(sdl_tex); SDL_DestroyTexture(sdl_tex);
sdl_tex = NULL; sdl_tex = NULL;
} }
if (sdl_render != NULL) { if (sdl_render != NULL) {
sdl_DestroyRenderer(sdl_render); SDL_DestroyRenderer(sdl_render);
sdl_render = NULL; sdl_render = NULL;
} }
if (sdl_win != NULL) { if (sdl_win != NULL) {
sdl_DestroyWindow(sdl_win); SDL_DestroyWindow(sdl_win);
sdl_win = NULL; sdl_win = NULL;
} }
@@ -347,13 +282,8 @@ sdl_close(void)
sdl_parent_hwnd = NULL; sdl_parent_hwnd = NULL;
} }
/* Quit and unload the DLL if possible. */ /* Quit. */
if (sdl_handle != NULL) { SDL_Quit();
sdl_Quit();
dynld_close(sdl_handle);
sdl_handle = NULL;
}
} }
@@ -361,7 +291,7 @@ static int old_capture = 0;
static int static int
sdl_init_common(int fs) sdl_init_common(int flags)
{ {
wchar_t temp[128]; wchar_t temp[128];
SDL_version ver; SDL_version ver;
@@ -370,24 +300,21 @@ sdl_init_common(int fs)
sdl_log("SDL: init (fs=%d)\n", fs); sdl_log("SDL: init (fs=%d)\n", fs);
/* Try loading the DLL. */
sdl_handle = dynld_module(PATH_SDL_DLL, sdl_imports);
if (sdl_handle == NULL) {
ui_msgbox(MBX_ERROR, (wchar_t *)IDS_2120);
return(0);
}
/* Get and log the version of the DLL we are using. */ /* Get and log the version of the DLL we are using. */
sdl_GetVersion(&ver); SDL_GetVersion(&ver);
sdl_log("SDL: version %d.%d.%d\n", ver.major, ver.minor, ver.patch); sdl_log("SDL: version %d.%d.%d\n", ver.major, ver.minor, ver.patch);
/* Initialize the SDL system. */ /* Initialize the SDL system. */
if (sdl_Init(SDL_INIT_VIDEO) < 0) { if (SDL_Init(SDL_INIT_VIDEO) < 0) {
sdl_log("SDL: initialization failed (%s)\n", sdl_GetError()); sdl_log("SDL: initialization failed (%s)\n", sdl_GetError());
return(0); return(0);
} }
if (fs) { if (flags & RENDERER_HARDWARE)
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d");
/* TODO: why is this necessary to avoid black screen on Win7/8/10? */
if (flags & RENDERER_FULL_SCREEN) {
/* Get the size of the (current) desktop. */ /* Get the size of the (current) desktop. */
sdl_w = GetSystemMetrics(SM_CXSCREEN); sdl_w = GetSystemMetrics(SM_CXSCREEN);
sdl_h = GetSystemMetrics(SM_CYSCREEN); sdl_h = GetSystemMetrics(SM_CYSCREEN);
@@ -431,7 +358,7 @@ sdl_init_common(int fs)
x, y, w, h, SWP_SHOWWINDOW); x, y, w, h, SWP_SHOWWINDOW);
/* Now create the SDL window from that. */ /* Now create the SDL window from that. */
sdl_win = sdl_CreateWindowFrom((void *)sdl_hwnd); sdl_win = SDL_CreateWindowFrom((void *)sdl_hwnd);
old_capture = mouse_capture; old_capture = mouse_capture;
@@ -442,7 +369,7 @@ sdl_init_common(int fs)
mouse_capture = 1; mouse_capture = 1;
} else { } else {
/* Create the SDL window from the render window. */ /* Create the SDL window from the render window. */
sdl_win = sdl_CreateWindowFrom((void *)hwndRender); sdl_win = SDL_CreateWindowFrom((void *)hwndRender);
mouse_capture = old_capture; mouse_capture = old_capture;
@@ -453,7 +380,7 @@ sdl_init_common(int fs)
} }
} }
if (sdl_win == NULL) { if (sdl_win == NULL) {
sdl_log("SDL: unable to CreateWindowFrom (%s)\n", sdl_GetError()); sdl_log("SDL: unable to CreateWindowFrom (%s)\n", SDL_GetError());
sdl_close(); sdl_close();
return(0); return(0);
} }
@@ -465,9 +392,14 @@ sdl_init_common(int fs)
* trying to switch to fullscreen even though the window is * trying to switch to fullscreen even though the window is
* not a fullscreen window?) * not a fullscreen window?)
*/ */
sdl_render = sdl_CreateRenderer(sdl_win, -1, SDL_RENDERER_SOFTWARE); if (flags & RENDERER_HARDWARE) {
sdl_render = SDL_CreateRenderer(sdl_win, -1, SDL_RENDERER_ACCELERATED);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
} else
sdl_render = SDL_CreateRenderer(sdl_win, -1, SDL_RENDERER_SOFTWARE);
if (sdl_render == NULL) { if (sdl_render == NULL) {
sdl_log("SDL: unable to create renderer (%s)\n", sdl_GetError()); sdl_log("SDL: unable to create renderer (%s)\n", SDL_GetError());
sdl_close(); sdl_close();
return(0); return(0);
} }
@@ -478,10 +410,10 @@ sdl_init_common(int fs)
* channel seems to be set to 255 everywhere, so ARGB8888 works * channel seems to be set to 255 everywhere, so ARGB8888 works
* just as well. * just as well.
*/ */
sdl_tex = sdl_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888, sdl_tex = SDL_CreateTexture(sdl_render, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 2048, 2048); SDL_TEXTUREACCESS_STREAMING, 2048, 2048);
if (sdl_tex == NULL) { if (sdl_tex == NULL) {
sdl_log("SDL: unable to create texture (%s)\n", sdl_GetError()); sdl_log("SDL: unable to create texture (%s)\n", SDL_GetError());
sdl_close(); sdl_close();
return(0); return(0);
} }
@@ -492,27 +424,41 @@ sdl_init_common(int fs)
/* Register our renderer! */ /* Register our renderer! */
video_setblit(sdl_blit); video_setblit(sdl_blit);
sdl_fs = fs; sdl_fs = !!(flags & RENDERER_FULL_SCREEN);
sdl_enabled = 1; sdl_enabled = 1;
sdl_mutex = sdl_CreateMutex(); sdl_mutex = SDL_CreateMutex();
return(1); return(1);
} }
int int
sdl_init(HWND h) sdl_inits(HWND h)
{ {
return sdl_init_common(0); return sdl_init_common(0);
} }
int int
sdl_init_fs(HWND h) sdl_inith(HWND h)
{ {
return sdl_init_common(1); return sdl_init_common(RENDERER_HARDWARE);
}
int
sdl_inits_fs(HWND h)
{
return sdl_init_common(RENDERER_FULL_SCREEN);
}
int
sdl_inith_fs(HWND h)
{
return sdl_init_common(RENDERER_FULL_SCREEN | RENDERER_HARDWARE);
} }
@@ -533,10 +479,11 @@ sdl_resize(int x, int y)
ww = x; ww = x;
wh = y; wh = y;
sdl_stretch(&ww, &wh, &wx, &wy);
if (sdl_fs) if (sdl_fs) {
sdl_stretch(&ww, &wh, &wx, &wy);
MoveWindow(sdl_hwnd, wx, wy, ww, wh, TRUE); MoveWindow(sdl_hwnd, wx, wy, ww, wh, TRUE);
}
cur_w = x; cur_w = x;
cur_h = y; cur_h = y;

View File

@@ -8,7 +8,7 @@
* *
* Definitions for the libSDL2 rendering module. * Definitions for the libSDL2 rendering module.
* *
* Version: @(#)win_sdl.h 1.0.1 2019/10/12 * Version: @(#)win_sdl.h 1.0.2 2019/12/05
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Michael Dr<44>ing, <michael@drueing.de> * Michael Dr<44>ing, <michael@drueing.de>
@@ -51,8 +51,10 @@
extern void sdl_close(void); extern void sdl_close(void);
extern int sdl_init(HWND h); extern int sdl_inits(HWND h);
extern int sdl_init_fs(HWND h); extern int sdl_inith(HWND h);
extern int sdl_inits_fs(HWND h);
extern int sdl_inith_fs(HWND h);
extern int sdl_pause(void); extern int sdl_pause(void);
extern void sdl_resize(int x, int y); extern void sdl_resize(int x, int y);
extern void sdl_enable(int enable); extern void sdl_enable(int enable);

View File

@@ -8,7 +8,7 @@
* *
* user Interface module for WinAPI on Windows. * user Interface module for WinAPI on Windows.
* *
* Version: @(#)win_ui.c 1.0.44 2019/11/02 * Version: @(#)win_ui.c 1.0.45 2019/12/05
* *
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/> * Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -39,7 +39,6 @@
#include "../plat_midi.h" #include "../plat_midi.h"
#include "../ui.h" #include "../ui.h"
#include "win.h" #include "win.h"
#include "win_d3d.h"
#define TIMER_1SEC 1 /* ID of the one-second timer */ #define TIMER_1SEC 1 /* ID of the one-second timer */
@@ -156,20 +155,13 @@ ResetAllMenus(void)
CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_INVERT, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+0, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_SW, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SDL_HW, MF_UNCHECKED);
#ifdef USE_D2D #ifdef USE_D2D
CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_D2D, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED);
#ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_DDRAW+4, MF_UNCHECKED);
#endif #endif
#else
CheckMenuItem(menuMain, IDM_VID_DDRAW+1, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+2, MF_UNCHECKED);
#ifdef USE_VNC #ifdef USE_VNC
CheckMenuItem(menuMain, IDM_VID_DDRAW+3, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_VNC, MF_UNCHECKED);
#endif
#endif #endif
CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FS_FULL+0, MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_FS_FULL+1, MF_UNCHECKED);
@@ -226,7 +218,7 @@ ResetAllMenus(void)
if (vid_resize) if (vid_resize)
CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_RESIZE, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_DDRAW+vid_api, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_SW+vid_api, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_FS_FULL+video_fullscreen_scale, MF_CHECKED);
CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_REMEMBER, window_remember?MF_CHECKED:MF_UNCHECKED);
CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED); CheckMenuItem(menuMain, IDM_VID_SCALE_1X+scale, MF_CHECKED);
@@ -440,18 +432,17 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
config_save(); config_save();
break; break;
case IDM_VID_DDRAW: case IDM_VID_SDL_SW:
case IDM_VID_SDL_HW:
#ifdef USE_D2D #ifdef USE_D2D
case IDM_VID_D2D: case IDM_VID_D2D:
#endif #endif
case IDM_VID_D3D:
case IDM_VID_SDL:
#ifdef USE_VNC #ifdef USE_VNC
case IDM_VID_VNC: case IDM_VID_VNC:
#endif #endif
CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_UNCHECKED); CheckMenuItem(hmenu, IDM_VID_SDL_SW + vid_api, MF_UNCHECKED);
plat_setvid(LOWORD(wParam) - IDM_VID_DDRAW); plat_setvid(LOWORD(wParam) - IDM_VID_SDL_SW);
CheckMenuItem(hmenu, IDM_VID_DDRAW+vid_api, MF_CHECKED); CheckMenuItem(hmenu, IDM_VID_SDL_SW + vid_api, MF_CHECKED);
config_save(); config_save();
break; break;
@@ -673,15 +664,6 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
ui_sb_timer_callback(wParam & 0xff); ui_sb_timer_callback(wParam & 0xff);
break; break;
case WM_RESETD3D:
startblit();
if (video_fullscreen)
d3d_reset_fs();
else
d3d_reset();
endblit();
break;
case WM_LEAVEFULLSCREEN: case WM_LEAVEFULLSCREEN:
plat_setfullscreen(0); plat_setfullscreen(0);
config_save(); config_save();