c – 初始化D3D9会导致第三方库停止工作
作者:互联网
首先,一般情况……通过DLL加载的第三方库会渲染为HWND.它是简单的2D渲染,并没有以我能看到的方式直接使用D3D – DLL上的依赖性遍历显示了许多D3DKMT函数,如D3DKMTCreateDevice,但不是常规的D3D调用,如IDirect3D9 :: CreateDevice.
当我调用IDirect3D9 :: CreateDevice时,第三方渲染变得棘手.它没有抱怨,只是简单地将所有内容呈现为黑色矩形.我自己的渲染工作正常.
细节……第三方DLL是Mozilla XULRunner 1.9.x,它是包含在wxWidgets wxWebConnect库中的FireFox(不是具有硬件加速功能的2.0)的核心. wxWC加载XUL DLL并提供Web浏览器GUI组件.
我有一个使用wx&的工作应用程序wxWebConnect这里有一个编译好的EXE和代码:
http://www.kirix.com/forums/viewtopic.php?f=25&t=911#p2605
这是我现实生活中的代码,它与wxWidgets略有约束但不足以使其难以阅读 – 我从随机窗口获得HWND只是为了初始化D3D但从未渲染到它:
void MyFrame::OnD3DButton( wxCommandEvent &event )
{
static bool initialized = false;
static LPDIRECT3D9 mpD3D = NULL;
static LPDIRECT3DDEVICE9 mpD3DDevice=NULL;
if(!initialized)
{
wxButton *button=wxDynamicCast(event.GetEventObject(), wxButton);
HWND mHWnd = (HWND)button->GetHandle();
mpD3D = Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS md3dpp;
ZeroMemory( &md3dpp, sizeof(D3DPRESENT_PARAMETERS) );
md3dpp.Windowed = true;
md3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
// triple buffer if VSync is on
md3dpp.BackBufferCount = 1;
md3dpp.EnableAutoDepthStencil = 0;
md3dpp.hDeviceWindow = mHWnd;
md3dpp.BackBufferWidth = 0;
md3dpp.BackBufferHeight = 0;
md3dpp.FullScreen_RefreshRateInHz = 0;
md3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
md3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
md3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
md3dpp.MultiSampleQuality = 0;
HRESULT hr = mpD3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,mHWnd,
D3DCREATE_MULTITHREADED|D3DCREATE_MIXED_VERTEXPROCESSING,&md3dpp,&mpD3DDevice);
if(FAILED(hr))
wxMessageBox(wxString("mpD3D->CreateDevice() FAILED"));
else
{
wxMessageBox(wxString("mpD3D->CreateDevice() SUCCEEDED"));
initialized = true;
}
}
}
解决方法:
问题可能是CreateDevice将修改FPU状态,除非您传递标志D3DCREATE_FPU_PRESERVE.当我咬它时,我花了很长时间才找到它.
标签:wxwidgets,direct3d,xul,c,dll 来源: https://codeday.me/bug/20190827/1737287.html