Load d3dxof.dll dynamically

This commit is contained in:
Anonymous Maarten 2024-06-26 02:31:02 +02:00
parent eeef231ee2
commit 568abe24fb
6 changed files with 63 additions and 1 deletions

View File

@ -28,6 +28,8 @@ else()
add_library(d3drm_guid INTERFACE)
endif()
option(WINE_D3DRM_DYNAMIC_D3DXOF "Dynamic d3dxof" ON)
add_library(d3drm-wine SHARED
d3drm.c
d3drm_main.c
@ -49,8 +51,16 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
else()
target_sources(d3drm-wine PRIVATE d3drm64.def)
endif()
if(WINE_D3DRM_DYNAMIC_D3DXOF)
target_sources(d3drm-wine PRIVATE dyn_d3dxof.c dyn_d3dxof.h)
target_compile_definitions(d3drm-wine PRIVATE DYNAMIC_D3DXOF)
endif()
target_include_directories(d3drm-wine SYSTEM PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include")
target_link_libraries(d3drm-wine PRIVATE d3dxof ddraw)
if(NOT WINE_D3DRM_DYNAMIC_D3DXOF)
target_link_libraries(d3drm-wine PRIVATE d3dxof)
endif()
target_link_libraries(d3drm-wine PRIVATE ddraw)
set_property(TARGET d3drm-wine PROPERTY PREFIX "")
set_property(TARGET d3drm-wine PROPERTY OUTPUT_NAME "d3drm")
target_compile_definitions(d3drm-wine PRIVATE "__WINESRC__")

View File

@ -2145,7 +2145,11 @@ static HRESULT WINAPI d3drm3_Load(IDirect3DRM3 *iface, void *source, void *objec
return E_NOTIMPL;
}
#ifdef DYNAMIC_D3DXOF
hr = DynamicDirectXFileCreate(&file);
#else
hr = DirectXFileCreate(&file);
#endif
if (hr != DXFILE_OK)
goto end;

View File

@ -30,6 +30,10 @@
#include "wine/debug.h"
#include "wine/list.h"
#ifdef DYNAMIC_D3DXOF
#include "dyn_d3dxof.h"
#endif
struct d3drm_matrix
{
float _11, _12, _13, _14;

32
3rdparty/d3drm/dyn_d3dxof.c vendored Normal file
View File

@ -0,0 +1,32 @@
#include "dyn_d3dxof.h"
static enum {
DYN_D3DXOF_INIT = 0,
DYN_D3DXOF_SUCCESS = 1,
} g_dyn_d3dxof_state = DYN_D3DXOF_INIT;
static HMODULE g_d3dxof;
static HRESULT (STDAPICALLTYPE * g_DynamicDirectXFileCreate)(LPDIRECTXFILE *lplpDirectXFile);
static void init_dyn_d3d(void) {
if (g_dyn_d3dxof_state == DYN_D3DXOF_SUCCESS) {
return;
}
g_d3dxof = LoadLibraryA("d3dxof.dll");
if (g_d3dxof == NULL) {
MessageBoxA(NULL, "Cannot find d3dxof.dll", "Cannot find d3dxof.dll", MB_ICONERROR);
abort();
}
g_DynamicDirectXFileCreate = (void*)GetProcAddress(g_d3dxof, "DirectXFileCreate");
if (g_d3dxof == NULL) {
MessageBoxA(NULL, "Missing symbols", "d3dxof.dll misses DirectXFileCreate", MB_ICONERROR);
abort();
}
g_dyn_d3dxof_state = DYN_D3DXOF_SUCCESS;
}
STDAPI DynamicDirectXFileCreate(LPDIRECTXFILE *lplpDirectXFile)
{
init_dyn_d3d();
return g_DynamicDirectXFileCreate(lplpDirectXFile);
}

8
3rdparty/d3drm/dyn_d3dxof.h vendored Normal file
View File

@ -0,0 +1,8 @@
#ifndef __DYN_D3DXOF_H__
#define __DYN_D3DXOF_H__
#include <dxfile.h>
STDAPI DynamicDirectXFileCreate(LPDIRECTXFILE *lplpDirectXFile);
#endif /* __DYN_D3DXOF_H__ */

View File

@ -1483,7 +1483,11 @@ static HRESULT WINAPI d3drm_mesh_builder3_Load(IDirect3DRMMeshBuilder3 *iface, v
clean_mesh_builder_data(mesh_builder);
#ifdef DYNAMIC_D3DXOF
hr = DynamicDirectXFileCreate(&dxfile);
#else
hr = DirectXFileCreate(&dxfile);
#endif
if (hr != DXFILE_OK)
goto end;