Added several small upstream patches for CPU module.
Added the D2D rendering module from 86Box, and updated it. Fixed the Slovenian translation. Added Norwegian (Bokmal) translation. Several small fixes here and there.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#
|
||||
# Makefile for Windows systems using the MinGW32 environment.
|
||||
#
|
||||
# Version: @(#)Makefile.mingw 1.0.49 2018/06/16
|
||||
# Version: @(#)Makefile.mingw 1.0.50 2018/07/28
|
||||
#
|
||||
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
#
|
||||
@@ -92,6 +92,9 @@ endif
|
||||
ifndef SDL
|
||||
SDL := n
|
||||
endif
|
||||
ifndef D2D
|
||||
D2D := n
|
||||
endif
|
||||
ifndef VNC
|
||||
VNC := n
|
||||
endif
|
||||
@@ -404,6 +407,28 @@ ifneq ($(SDL), n)
|
||||
SDLOBJ := win_sdl.o
|
||||
endif
|
||||
|
||||
# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static
|
||||
ifneq ($(D2D), n)
|
||||
ifeq ($(D2D), d)
|
||||
OPTS += -DUSE_D2D=2
|
||||
else
|
||||
OPTS += -DUSE_D2D=1
|
||||
endif
|
||||
RFLAGS += -DUSE_D2D
|
||||
ifneq ($(D2D_PATH), )
|
||||
OPTS += -I$(D2D_PATH)/include/mingw -I$(D2D_PATH)/include
|
||||
ifeq ($(X64), y)
|
||||
LOPTS += -L$(D2D_PATH)/lib/mingw/x64
|
||||
else
|
||||
LOPTS += -L$(D2D_PATH)/lib/mingw/x86
|
||||
endif
|
||||
endif
|
||||
ifeq ($(D2D), y)
|
||||
LIBS += -ld2d1
|
||||
endif
|
||||
D2DOBJ := win_d2d.o
|
||||
endif
|
||||
|
||||
# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static
|
||||
ifneq ($(VNC), n)
|
||||
OPTS += -DUSE_VNC
|
||||
@@ -468,7 +493,7 @@ ifneq ($(WX), n)
|
||||
UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o
|
||||
else
|
||||
UIOBJ := win_ui.o \
|
||||
win_ddraw.o win_d3d.o $(SDLOBJ) \
|
||||
win_ddraw.o win_d3d.o $(SDLOBJ) $(D2DOBJ) \
|
||||
win_dialog.o win_about.o win_status.o \
|
||||
win_settings.o win_devconf.o win_snd_gain.o \
|
||||
win_new_image.o
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#
|
||||
# Makefile for Windows using Visual Studio 2015.
|
||||
#
|
||||
# Version: @(#)Makefile.VC 1.0.36 2018/06/19
|
||||
# Version: @(#)Makefile.VC 1.0.37 2018/07/28
|
||||
#
|
||||
# Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
#
|
||||
@@ -93,6 +93,9 @@ endif
|
||||
ifndef SDL
|
||||
SDL := n
|
||||
endif
|
||||
ifndef D2D
|
||||
D2D := n
|
||||
endif
|
||||
ifndef VNC
|
||||
VNC := n
|
||||
endif
|
||||
@@ -378,6 +381,28 @@ ifneq ($(SDL), n)
|
||||
SDLOBJ := win_sdl.obj
|
||||
endif
|
||||
|
||||
# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static
|
||||
ifneq ($(D2D), n)
|
||||
ifeq ($(D2D), d)
|
||||
OPTS += -DUSE_D2D=2
|
||||
else
|
||||
OPTS += -DUSE_D2D=1
|
||||
endif
|
||||
RFLAGS += -DUSE_D2D
|
||||
ifneq ($(D2D_PATH), )
|
||||
OPTS += -I$(D2D_PATH)/include/msvc -I$(D2D_PATH)/include
|
||||
ifeq ($(X64), y)
|
||||
LOPTS += -LIBPATH:$(D2D_PATH)\lib\msvc\x64
|
||||
else
|
||||
LOPTS += -LIBPATH:$(D2D_PATH)\lib\msvc\x86
|
||||
endif
|
||||
endif
|
||||
ifeq ($(D2D), y)
|
||||
LIBS += d2d1.lib
|
||||
endif
|
||||
D2DOBJ := win_d2d.obj
|
||||
endif
|
||||
|
||||
# N=no, Y=yes,linked, D=yes,dynamic, S=yes,static
|
||||
ifneq ($(VNC), n)
|
||||
OPTS += -DUSE_VNC
|
||||
@@ -442,7 +467,7 @@ ifneq ($(WX), n)
|
||||
UIOBJ := wx_main.obj wx_ui.obj wx_stbar.obj wx_render.obj
|
||||
else
|
||||
UIOBJ := win_ui.obj \
|
||||
win_ddraw.obj win_d3d.obj $(SDLOBJ) \
|
||||
win_ddraw.obj win_d3d.obj $(SDLOBJ) $(D2DOBJ) \
|
||||
win_dialog.obj win_about.obj win_status.obj \
|
||||
win_settings.obj win_devconf.obj win_snd_gain.obj \
|
||||
win_new_image.obj
|
||||
@@ -711,7 +736,7 @@ win/Mklang.cmd: win/msvc/Makefile.VC
|
||||
@echo @IF NOT "%%LANG%%"=="none" @$(MAKE) -fwin/msvc/Makefile.VC "RFLAGS=$(RFLAGS) $(EXTRAS)" LANG=%%LANG%% VARCem-%%1.dll >>win\Mklang.cmd
|
||||
|
||||
|
||||
lang: win/Mklang.cmd
|
||||
langs: win/Mklang.cmd
|
||||
ifdef LANG
|
||||
@echo Generating localization $(LANG) ..
|
||||
else
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Platform main support module for Windows.
|
||||
*
|
||||
* Version: @(#)win.c 1.0.16 2018/05/20
|
||||
* Version: @(#)win.c 1.0.17 2018/07/28
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
@@ -58,6 +58,9 @@
|
||||
#ifdef USE_SDL
|
||||
# include "win_sdl.h"
|
||||
#endif
|
||||
#ifdef USE_D2D
|
||||
# include "win_d2d.h"
|
||||
#endif
|
||||
#ifdef USE_VNC
|
||||
# include "../vnc.h"
|
||||
#endif
|
||||
@@ -89,6 +92,9 @@ const vidapi_t *plat_vidapis[] = {
|
||||
&ddraw_vidapi,
|
||||
&d3d_vidapi,
|
||||
#endif
|
||||
#ifdef USE_D2D
|
||||
&d2d_vidapi,
|
||||
#endif
|
||||
|
||||
#ifdef USE_SDL
|
||||
&sdl_vidapi,
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
* Platform support defintions for Win32.
|
||||
*
|
||||
* Version: @(#)win.h 1.0.17 2018/05/28
|
||||
* Version: @(#)win.h 1.0.18 2018/07/28
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
|
||||
450
src/win/win_d2d.cpp
Normal file
450
src/win/win_d2d.cpp
Normal file
@@ -0,0 +1,450 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Rendering module for Microsoft Direct2D.
|
||||
*
|
||||
* Version: @(#)win_d2d.cpp 1.0.1 2018/07/28
|
||||
*
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* David Hrdlicka, <hrdlickadavid@outlook.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2018 David Hrdlicka.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
#define UNICODE
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <d2d1.h>
|
||||
#include <d2d1helper.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#define PNG_DEBUG 0
|
||||
#include <png.h>
|
||||
#include "../emu.h"
|
||||
#include "../version.h"
|
||||
#include "../device.h"
|
||||
#include "../plat.h"
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable: 4200)
|
||||
#endif
|
||||
#include "../devices/video/video.h"
|
||||
#include "win.h"
|
||||
#include "win_d2d.h"
|
||||
|
||||
|
||||
#ifdef USE_D2D
|
||||
|
||||
# if USE_D2D == 2
|
||||
# define PATH_D2D_DLL "d2d1.dll"
|
||||
# define DLLFUNC(x) D2D1_ ## x
|
||||
|
||||
|
||||
/* Pointers to the real functions. */
|
||||
static bool (*D2D1_CreateFactory)(
|
||||
D2D1_FACTORY_TYPE factoryType,
|
||||
REFIID riid,
|
||||
CONST D2D1_FACTORY_OPTIONS *pFactoryOptions,
|
||||
void **ppIFactory);
|
||||
|
||||
static const dllimp_t d2d_imports[] = {
|
||||
{ "D2D1CreateFactory", &D2D1_CreateFactory },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
static void *d2d_handle = NULL;
|
||||
# else
|
||||
# define DLLFUNC(x) D2D1 ## x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
static HWND d2d_hwnd, old_hwndMain;
|
||||
static ID2D1Factory *d2d_factory;
|
||||
static ID2D1HwndRenderTarget *d2d_hwndRT;
|
||||
static ID2D1BitmapRenderTarget *d2d_btmpRT;
|
||||
static ID2D1Bitmap *d2d_bitmap;
|
||||
static int d2d_width, d2d_height,
|
||||
d2d_screen_width, d2d_screen_height,
|
||||
d2d_fs;
|
||||
|
||||
|
||||
static void
|
||||
d2d_stretch(float *w, float *h, float *x, float *y)
|
||||
{
|
||||
double dw, dh, dx, dy, temp, temp2, ratio_w, ratio_h, gsr, hsr;
|
||||
|
||||
switch (vid_fullscreen_scale) {
|
||||
case FULLSCR_SCALE_FULL:
|
||||
*w = (float)d2d_screen_width;
|
||||
*h = (float)d2d_screen_height;
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
break;
|
||||
|
||||
case FULLSCR_SCALE_43:
|
||||
dw = (double)d2d_screen_width;
|
||||
dh = (double)d2d_screen_height;
|
||||
temp = (dh / 3.0) * 4.0;
|
||||
dx = (dw - temp) / 2.0;
|
||||
dw = temp;
|
||||
*w = (float)dw;
|
||||
*h = (float)dh;
|
||||
*x = (float)dx;
|
||||
*y = 0;
|
||||
break;
|
||||
|
||||
case FULLSCR_SCALE_SQ:
|
||||
dw = (double)d2d_screen_width;
|
||||
dh = (double)d2d_screen_height;
|
||||
temp = ((double) *w);
|
||||
temp2 = ((double) *h);
|
||||
dx = (dw / 2.0) - ((dh * temp) / (temp2 * 2.0));
|
||||
dy = 0.0;
|
||||
if (dx < 0.0) {
|
||||
dx = 0.0;
|
||||
dy = (dw / 2.0) - ((dh * temp2) / (temp * 2.0));
|
||||
}
|
||||
dw -= (dx * 2.0);
|
||||
dh -= (dy * 2.0);
|
||||
*w = (float)dw;
|
||||
*h = (float)dh;
|
||||
*x = (float)dx;
|
||||
*y = (float)dy;
|
||||
break;
|
||||
|
||||
case FULLSCR_SCALE_INT:
|
||||
dw = (double)d2d_screen_width;
|
||||
dh = (double)d2d_screen_height;
|
||||
temp = ((double) *w);
|
||||
temp2 = ((double) *h);
|
||||
ratio_w = dw / ((double) *w);
|
||||
ratio_h = dh / ((double) *h);
|
||||
if (ratio_h < ratio_w)
|
||||
ratio_w = ratio_h;
|
||||
dx = (dw / 2.0) - ((temp * ratio_w) / 2.0);
|
||||
dy = (dh / 2.0) - ((temp2 * ratio_h) / 2.0);
|
||||
dw -= (dx * 2.0);
|
||||
dh -= (dy * 2.0);
|
||||
*w = (float)dw;
|
||||
*h = (float)dh;
|
||||
*x = (float)dx;
|
||||
*y = (float)dy;
|
||||
break;
|
||||
|
||||
case FULLSCR_SCALE_KEEPRATIO:
|
||||
dw = (double)d2d_screen_width;
|
||||
dh = (double)d2d_screen_height;
|
||||
hsr = dw / dh;
|
||||
gsr = ((double) *w) / ((double) *h);
|
||||
if (gsr <= hsr) {
|
||||
temp = dh * gsr;
|
||||
dx = (dw - temp) / 2.0;
|
||||
dw = temp;
|
||||
*w = (float)dw;
|
||||
*h = (float)dh;
|
||||
*x = (float)dx;
|
||||
*y = 0;
|
||||
} else {
|
||||
temp = dw / gsr;
|
||||
dy = (dh - temp) / 2.0;
|
||||
dh = temp;
|
||||
*w = (float)dw;
|
||||
*h = (float)dh;
|
||||
*x = 0;
|
||||
*y = (float)dy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
d2d_blit(int x, int y, int y1, int y2, int w, int h)
|
||||
{
|
||||
ID2D1Bitmap *fs_bitmap;
|
||||
ID2D1RenderTarget *RT;
|
||||
D2D1_RECT_U rectU;
|
||||
HRESULT hr = S_OK;
|
||||
void *srcdata;
|
||||
int yy;
|
||||
float fs_x, fs_y;
|
||||
float fs_w = (float)w;
|
||||
float fs_h = (float)h;
|
||||
|
||||
#if 0
|
||||
pclog("D2D: blit(x=%d, y=%d, y1=%d, y2=%d, w=%d, h=%d)\n", x,y, y1,y2, w,h);
|
||||
#endif
|
||||
|
||||
// TODO: Detect double scanned mode and resize render target
|
||||
// appropriately for more clear picture
|
||||
if (w != d2d_width || h != d2d_height) {
|
||||
if (d2d_fs) {
|
||||
if (d2d_btmpRT) {
|
||||
d2d_btmpRT->Release();
|
||||
d2d_btmpRT = NULL;
|
||||
}
|
||||
hr = d2d_hwndRT->CreateCompatibleRenderTarget(
|
||||
D2D1::SizeF((float)w, (float)h),
|
||||
&d2d_btmpRT);
|
||||
if (SUCCEEDED(hr)) {
|
||||
d2d_width = w;
|
||||
d2d_height = h;
|
||||
}
|
||||
} else {
|
||||
hr = d2d_hwndRT->Resize(D2D1::SizeU(w, h));
|
||||
if (SUCCEEDED(hr)) {
|
||||
d2d_width = w;
|
||||
d2d_height = h;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((y1 == y2) || (buffer32 == NULL)) {
|
||||
video_blit_complete();
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Copy data directly from buffer32 to d2d_bitmap
|
||||
srcdata = malloc(h * w * 4);
|
||||
for (yy = y1; yy < y2; yy++) {
|
||||
if ((y + yy) >= 0 && (y + yy) < buffer32->h) {
|
||||
#if 0
|
||||
if (vid_grayscale || invert_display)
|
||||
video_transform_copy(
|
||||
(uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]),
|
||||
&(((uint32_t *)buffer32->line[y + yy])[x]),
|
||||
w);
|
||||
else
|
||||
#endif
|
||||
memcpy(
|
||||
(uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]),
|
||||
&(((uint32_t *)buffer32->line[y + yy])[x]),
|
||||
w * 4);
|
||||
}
|
||||
}
|
||||
|
||||
video_blit_complete();
|
||||
|
||||
rectU = D2D1::RectU(0, 0, w, h);
|
||||
hr = d2d_bitmap->CopyFromMemory(&rectU, srcdata, w * 4);
|
||||
// In fullscreen mode we first draw offscreen to an intermediate
|
||||
// BitmapRenderTarget, which then gets rendered to the actual
|
||||
// HwndRenderTarget in order to implement different scaling modes
|
||||
// In windowed mode we draw directly to the HwndRenderTarget
|
||||
if (SUCCEEDED(hr)) {
|
||||
RT = d2d_fs ? (ID2D1RenderTarget *) d2d_btmpRT : (ID2D1RenderTarget *) d2d_hwndRT;
|
||||
RT->BeginDraw();
|
||||
RT->DrawBitmap(d2d_bitmap,
|
||||
D2D1::RectF(0, (float)y1, (float)w, (float)y2),
|
||||
1.0f,
|
||||
D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR,
|
||||
D2D1::RectF(0, (float)y1, (float)w, (float)y2));
|
||||
hr = RT->EndDraw();
|
||||
}
|
||||
|
||||
if (d2d_fs) {
|
||||
if (SUCCEEDED(hr))
|
||||
hr = d2d_btmpRT->GetBitmap(&fs_bitmap);
|
||||
if (SUCCEEDED(hr)) {
|
||||
d2d_stretch(&fs_w, &fs_h, &fs_x, &fs_y);
|
||||
d2d_hwndRT->BeginDraw();
|
||||
d2d_hwndRT->Clear(D2D1::ColorF(D2D1::ColorF::Black));
|
||||
d2d_hwndRT->DrawBitmap(fs_bitmap,
|
||||
D2D1::RectF(fs_x, fs_y, fs_x + fs_w, fs_y + fs_h),
|
||||
1.0f,
|
||||
D2D1_BITMAP_INTERPOLATION_MODE_LINEAR,
|
||||
D2D1::RectF(0, 0, (float)w, (float)h));
|
||||
hr = d2d_hwndRT->EndDraw();
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
pclog("D2D: blit: error 0x%08lx\n", hr);
|
||||
|
||||
/* Clean up. */
|
||||
free(srcdata);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
d2d_close(void)
|
||||
{
|
||||
pclog("D2D: close()\n");
|
||||
|
||||
video_setblit(NULL);
|
||||
|
||||
if (d2d_bitmap) {
|
||||
d2d_bitmap->Release();
|
||||
d2d_bitmap = NULL;
|
||||
}
|
||||
if (d2d_btmpRT) {
|
||||
d2d_btmpRT->Release();
|
||||
d2d_btmpRT = NULL;
|
||||
}
|
||||
|
||||
if (d2d_hwndRT) {
|
||||
d2d_hwndRT->Release();
|
||||
d2d_hwndRT = NULL;
|
||||
}
|
||||
if (d2d_factory) {
|
||||
d2d_factory->Release();
|
||||
d2d_factory = NULL;
|
||||
}
|
||||
if (d2d_hwnd) {
|
||||
hwndMain = old_hwndMain;
|
||||
plat_set_input(hwndMain);
|
||||
DestroyWindow(d2d_hwnd);
|
||||
d2d_hwnd = NULL;
|
||||
old_hwndMain = NULL;
|
||||
}
|
||||
|
||||
#if defined(USE_D2D) && USE_D2D == 2
|
||||
/* Quit and unload the DLL if possible. */
|
||||
if (d2d_handle != NULL) {
|
||||
dynld_close(d2d_handle);
|
||||
d2d_handle = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
d2d_init(int fs)
|
||||
{
|
||||
WCHAR title[200];
|
||||
D2D1_HWND_RENDER_TARGET_PROPERTIES props;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
pclog("D2D: init(fs=%d)\n", fs);
|
||||
|
||||
cgapal_rebuild();
|
||||
|
||||
#if defined(USE_D2D) && USE_D2D == 2
|
||||
/* Try loading the DLL. */
|
||||
d2d_handle = dynld_module(PATH_D2D_DLL, d2d_imports);
|
||||
if (d2d_handle == NULL) {
|
||||
pclog("D2D: unable to load '%s', D2D not available.\n", PATH_D2D_DLL);
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get and log the version of the DLL we are using. */
|
||||
if (fs) {
|
||||
/*
|
||||
* Direct2D seems to lack any proper fullscreen mode,
|
||||
* therefore we just create a full screen window and
|
||||
* pass its handle to a HwndRenderTarget.
|
||||
*/
|
||||
d2d_screen_width = GetSystemMetrics(SM_CXSCREEN);
|
||||
d2d_screen_height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
mbstowcs(title, emu_version, sizeof_w(title));
|
||||
d2d_hwnd = CreateWindow(FS_CLASS_NAME,
|
||||
title,
|
||||
WS_POPUP,
|
||||
0, 0, d2d_screen_width, d2d_screen_height,
|
||||
HWND_DESKTOP,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
old_hwndMain = hwndMain;
|
||||
hwndMain = d2d_hwnd;
|
||||
|
||||
plat_set_input(d2d_hwnd);
|
||||
SetFocus(d2d_hwnd);
|
||||
SetWindowPos(d2d_hwnd, HWND_TOPMOST,
|
||||
0,0, d2d_screen_width,d2d_screen_height, SWP_SHOWWINDOW);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = DLLFUNC(CreateFactory)(D2D1_FACTORY_TYPE_MULTI_THREADED,
|
||||
__uuidof(ID2D1Factory),
|
||||
NULL,
|
||||
reinterpret_cast <void **>(&d2d_factory));
|
||||
|
||||
if (fs) {
|
||||
props = D2D1::HwndRenderTargetProperties(d2d_hwnd,
|
||||
D2D1::SizeU(d2d_screen_width, d2d_screen_height));
|
||||
} else {
|
||||
// HwndRenderTarget will get resized appropriately by d2d_blit,
|
||||
// so it's fine to let D2D imply size of 0x0 for now
|
||||
props = D2D1::HwndRenderTargetProperties(hwndRender);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = d2d_factory->CreateHwndRenderTarget(D2D1::RenderTargetProperties(),
|
||||
props,
|
||||
&d2d_hwndRT);
|
||||
if (SUCCEEDED(hr)) {
|
||||
// Create a bitmap for storing intermediate data
|
||||
hr = d2d_hwndRT->CreateBitmap(D2D1::SizeU(2048, 2048),
|
||||
D2D1::BitmapProperties(D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE)),
|
||||
&d2d_bitmap);
|
||||
}
|
||||
|
||||
if (FAILED(hr)) {
|
||||
pclog("D2D: init: error 0x%08lx\n", hr);
|
||||
d2d_close();
|
||||
return(0);
|
||||
}
|
||||
|
||||
d2d_fs = fs;
|
||||
d2d_width = 0;
|
||||
d2d_height = 0;
|
||||
|
||||
/* Make sure we get a clean exit. */
|
||||
atexit(d2d_close);
|
||||
|
||||
/* Register our renderer! */
|
||||
video_setblit(d2d_blit);
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
d2d_screenshot(const wchar_t *fn)
|
||||
{
|
||||
// Saving a screenshot of a Direct2D render target is harder than
|
||||
// one would think. Keeping this stubbed for the moment
|
||||
// -ryu
|
||||
pclog("D2D: screenshot(%ls)\n", fn);
|
||||
}
|
||||
|
||||
|
||||
const vidapi_t d2d_vidapi = {
|
||||
"D2D",
|
||||
1,
|
||||
d2d_init,
|
||||
d2d_close,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
d2d_screenshot,
|
||||
NULL
|
||||
};
|
||||
62
src/win/win_d2d.h
Normal file
62
src/win/win_d2d.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the Direct2D rendering module.
|
||||
*
|
||||
* Version: @(#)win_d2d.h 1.0.1 2018/07/28
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef WIN_D2D_H
|
||||
# define WIN_D2D_H
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const vidapi_t d2d_vidapi;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /*WIN_D2D_H*/
|
||||
Reference in New Issue
Block a user