From 835f6f56495be85457dbd0201be4e47700bcea7e Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Tue, 22 Dec 2015 12:50:30 +0000 Subject: d3dretrace: Create a single window per HWND. --- retrace/d3d9retrace.py | 7 ++++++- retrace/d3dretrace.hpp | 3 +++ retrace/d3dretrace_ws.cpp | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/retrace/d3d9retrace.py b/retrace/d3d9retrace.py index 7313acc9..ac6af73b 100644 --- a/retrace/d3d9retrace.py +++ b/retrace/d3d9retrace.py @@ -88,7 +88,12 @@ class D3DRetracer(Retracer): # create windows as neccessary if method.name in ('CreateDevice', 'CreateDeviceEx', 'CreateAdditionalSwapChain'): - print r' HWND hWnd = d3dretrace::createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' + print r' HWND hWnd = pPresentationParameters->hDeviceWindow;' + if 'hFocusWindow' in method.argNames(): + print r' if (hWnd == NULL) {' + print r' hWnd = hFocusWindow;' + print r' }' + print r' hWnd = d3dretrace::createWindow(hWnd, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' print r' pPresentationParameters->hDeviceWindow = hWnd;' if 'hFocusWindow' in method.argNames(): print r' hFocusWindow = hWnd;' diff --git a/retrace/d3dretrace.hpp b/retrace/d3dretrace.hpp index 034e6165..d0be5773 100644 --- a/retrace/d3dretrace.hpp +++ b/retrace/d3dretrace.hpp @@ -86,6 +86,9 @@ public: HWND createWindow(int width, int height); +HWND +createWindow(HWND hWnd, int width, int height); + void resizeWindow(HWND hWnd, int width, int height); diff --git a/retrace/d3dretrace_ws.cpp b/retrace/d3dretrace_ws.cpp index 22b973cc..62f3a9c7 100644 --- a/retrace/d3dretrace_ws.cpp +++ b/retrace/d3dretrace_ws.cpp @@ -47,6 +47,28 @@ createWindow(int width, int height) } +typedef std::map HWND_MAP; +static HWND_MAP g_hWndMap; + + +HWND +createWindow(HWND hWnd, int width, int height) +{ + HWND_MAP::iterator it; + it = g_hWndMap.find(hWnd); + if (it == g_hWndMap.end()) { + // Create a new window + hWnd = createWindow(width, height); + g_hWndMap[hWnd] = hWnd; + } else { + // Reuse the existing window + hWnd = it->second; + ws::resizeWindow(hWnd, width, height); + } + return hWnd; +} + + void resizeWindow(HWND hWnd, int width, int height) { -- cgit v1.2.3