diff --git a/configure b/configure index f6ff13b..a2d0ba6 100755 --- a/configure +++ b/configure @@ -55,7 +55,8 @@ param_set("examples", 1); param_set("allow-sloppy-focus", 0); # (option that only makes sense on Windows) -param_set("directx", 0); +param_set("dxd8", 0); +param_set("dxd9", 0); my %features = ( "classic-theme" => "use classic theme", @@ -73,7 +74,8 @@ my %features = ( "gnustep" => "use gnustep", "dbus" => "use DBus on supported platform", "allow-sloppy-focus" => "prevent the x11 backend from using XSetInputFocus to enforce click-to-focus", - "directx" => "(Windows only) build DirectX widget" + "directx8" => "(Windows only) build DXD8 widget", + "directx9" => "(Windows only) build DXD9 widget" ); my @features_keys = ( "1classic-theme", "1stb-image", @@ -82,7 +84,7 @@ my @features_keys = ( "1vulkan", "2vulkan-string-helper", "1shared", "1static", "1wayland", "1gnustep", - "1dbus", "1directx" + "1dbus", "1direct8", "1directx9" ); sub def_platform { diff --git a/examples/dxdemos/d3d8.c b/examples/dxdemos/d3d8.c index 400adc6..2ef08a3 100644 --- a/examples/dxdemos/d3d8.c +++ b/examples/dxdemos/d3d8.c @@ -5,6 +5,8 @@ #include #include +#ifdef MW_DIRECTX8 + MwWidget window, d3d8; LPDIRECT3D8 d3d; LPDIRECT3DDEVICE8 d3ddev; @@ -89,3 +91,5 @@ int main() { MwLoop(window); } + +#endif diff --git a/examples/dxdemos/d3d9.c b/examples/dxdemos/d3d9.c index 5975739..9fe685c 100644 --- a/examples/dxdemos/d3d9.c +++ b/examples/dxdemos/d3d9.c @@ -6,6 +6,8 @@ #include #include +#ifdef MW_DIRECTX9 + MwWidget window, d3d8; LPDIRECT3D9 d3d; LPDIRECT3DDEVICE9 d3ddev; @@ -91,3 +93,5 @@ int main() { MwLoop(window); } + +#endif diff --git a/include/Mw/Widget/D3D8.h b/include/Mw/Widget/D3D8.h index 022e7bc..ee1bf05 100644 --- a/include/Mw/Widget/D3D8.h +++ b/include/Mw/Widget/D3D8.h @@ -22,6 +22,7 @@ #ifndef _WIN32 #error D3D8 widget only avaliable for Win32 backends +#undef MW_DIRECTX8 #else #ifdef MW_DIRECTX8 #include @@ -37,6 +38,7 @@ MWDECL MwClass MwD3D8Class; extern "C" { #endif +#ifdef MW_DIRECTX8 MwInline LPDIRECT3D8 MwDirectXGetD3D8(MwWidget handle) { LPDIRECT3D8 out = NULL; MwVaWidgetExecute(handle, "mwDirectXGetD3D8", &out, NULL); @@ -47,6 +49,16 @@ MwInline LPDIRECT3DDEVICE8 MwDirectXGetD3Dev8(MwWidget handle) { MwVaWidgetExecute(handle, "mwDirectXGetD3Dev8", &out); return out; }; +#else +MwInline void* MwDirectXGetD3D8(MwWidget handle) { + (void)handle; + return NULL; +}; +MwInline void* MwDirectXGetD3Dev8(MwWidget handle) { + (void)handle; + return NULL; +}; +#endif #ifdef __cplusplus } diff --git a/include/Mw/Widget/D3D9.h b/include/Mw/Widget/D3D9.h index 2639e17..e7a7149 100644 --- a/include/Mw/Widget/D3D9.h +++ b/include/Mw/Widget/D3D9.h @@ -20,6 +20,7 @@ #ifndef _WIN32 #error D3D9 widget only avaliable for Win32 backends +#undef MW_DIRECTX9 #else #ifdef MW_DIRECTX9 #include @@ -36,6 +37,7 @@ MWDECL MwClass MwD3D9Class; extern "C" { #endif +#ifdef MW_DIRECTX9 MwInline LPDIRECT3D9 MwDirectXGetD3D9(MwWidget handle) { LPDIRECT3D9 out = NULL; MwVaWidgetExecute(handle, "mwDirectXGetD3D9", &out, NULL); @@ -46,6 +48,16 @@ MwInline LPDIRECT3DDEVICE9 MwDirectXGetD3Dev9(MwWidget handle) { MwVaWidgetExecute(handle, "mwDirectXGetD3Dev9", &out); return out; }; +#else +MwInline void* MwDirectXGetD3D9(MwWidget handle) { + (void)handle; + return NULL; +}; +MwInline void* MwDirectXGetD3Dev9(MwWidget handle) { + (void)handle; + return NULL; +}; +#endif #ifdef __cplusplus } diff --git a/pl/rules.pl b/pl/rules.pl index 2f336cb..b12b76c 100644 --- a/pl/rules.pl +++ b/pl/rules.pl @@ -178,7 +178,8 @@ new_object("src/widget/window.c"); new_object("src/widget/opengl.c"); new_object("src/widget/vulkan.c"); -new_object("src/widget/directx.c"); +new_object("src/widget/d3d8.c"); +new_object("src/widget/d3d9.c"); if (param_get("opengl")) { add_cflags("-DMW_OPENGL"); @@ -186,8 +187,11 @@ if (param_get("opengl")) { if (param_get("vulkan")) { add_cflags("-DMW_VULKAN"); } -if (param_get("directx")) { - add_cflags("-DMW_DIRECTX"); +if (param_get("directx8")) { + add_cflags("-DMW_DIRECTX8"); +} +if (param_get("directx9")) { + add_cflags("-DMW_DIRECTX9"); } new_object("src/dialog/*.c"); @@ -234,8 +238,12 @@ if (param_get("vulkan")) { new_example("examples/vkdemos/vulkan"); } -if (param_get("directx")) { - new_example("examples/dxdemos/directx9"); +if (param_get("directx8")) { + new_example("examples/dxdemos/d3d8"); +} + +if (param_get("directx9")) { + new_example("examples/dxdemos/d3d9"); } 1; diff --git a/src/widget/d3d8.c b/src/widget/d3d8.c index 13e656d..0663321 100644 --- a/src/widget/d3d8.c +++ b/src/widget/d3d8.c @@ -1,13 +1,7 @@ #include -#ifndef MW_DIRECTX8 -#define MW_DIRECTX8_NO_INCLUDE -MWDECL MwClass MwDX8Class; - -MwClass MwDX8Class = NULL; -#else +#ifdef MW_DIRECTX8 #include - typedef struct gdid3d8 { void* d3d8dll; IDirect3D8* (*Direct3DCreate8)(UINT sdk_version); @@ -104,4 +98,8 @@ MwClassRec MwDX8ClassRec = {wcreate_d3d8, /* create */ NULL, /* props_change */ NULL, NULL, NULL}; MwClass MwD3D8Class = &MwDX8ClassRec; +#else +MWDECL MwClass MwDX8Class; + +MwClass MwDX8Class = NULL; #endif diff --git a/src/widget/d3d9.c b/src/widget/d3d9.c index f6fc5d9..3246caf 100644 --- a/src/widget/d3d9.c +++ b/src/widget/d3d9.c @@ -1,13 +1,7 @@ #include -#ifndef MW_DIRECTX9 -#define MW_DIRECTX9_NO_INCLUDE -MWDECL MwClass MwDX9Class; - -MwClass MwDX9Class = NULL; -#else +#ifdef MW_DIRECTX9 #include - typedef struct gdid3d9 { void* d3d9dll; IDirect3D9* (*Direct3DCreate9)(UINT sdk_version); @@ -93,4 +87,8 @@ MwClassRec MwDX9ClassRec = {wcreate_d3d9, /* create */ NULL, /* props_change */ NULL, NULL, NULL}; MwClass MwD3D9Class = &MwDX9ClassRec; +#else +MWDECL MwClass MwDX9Class; + +MwClass MwDX9Class = NULL; #endif diff --git a/tools/gendcl.pl b/tools/gendcl.pl index f2e3399..ccc29dc 100755 --- a/tools/gendcl.pl +++ b/tools/gendcl.pl @@ -59,6 +59,8 @@ sub scan { while (my $file = readdir($dh)) { if ( !(($dir . "/" . $file) eq "src/widget/opengl.c") && !(($dir . "/" . $file) eq "src/widget/vulkan.c") + && !(($dir . "/" . $file) eq "src/widget/d3d8.c") + && !(($dir . "/" . $file) eq "src/widget/d3d9.c") && !(($dir . "/" . $file) eq "external/stb_truetype.c") && !(($dir . "/" . $file) eq "external/stb_image.c") && ($file =~ /\.c$/))