From 94639d4714f165b6768db66c5be8fad79fc04d03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Fri, 6 Apr 2012 07:49:45 +0100 Subject: [PATCH] Create window on d3dretrace. --- d3dretrace.py | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/d3dretrace.py b/d3dretrace.py index 21c87b9..e8b63b0 100644 --- a/d3dretrace.py +++ b/d3dretrace.py @@ -36,6 +36,19 @@ class D3DRetracer(Retracer): table_name = 'd3dretrace::d3d9_callbacks' + def invokeInterfaceMethod(self, interface, method): + if interface.name == 'IDirect3D9' and method.name == 'CreateDevice': + print 'HWND hWnd = createWindow(pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' + print 'pPresentationParameters->hDeviceWindow = hWnd;' + print 'hFocusWindow = hWnd;' + + Retracer.invokeInterfaceMethod(self, interface, method) + + if str(method.type) == 'HRESULT': + print r' if (__result != S_OK) {' + print r' retrace::warning(call) << "failed\n";' + print r' }' + if __name__ == '__main__': print r''' @@ -47,6 +60,79 @@ if __name__ == '__main__': #include "d3dretrace.hpp" +// XXX: Don't duplicate this code. + +static LRESULT CALLBACK +WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + MINMAXINFO *pMMI; + switch (uMsg) { + case WM_GETMINMAXINFO: + // Allow to create a window bigger than the desktop + pMMI = (MINMAXINFO *)lParam; + pMMI->ptMaxSize.x = 60000; + pMMI->ptMaxSize.y = 60000; + pMMI->ptMaxTrackSize.x = 60000; + pMMI->ptMaxTrackSize.y = 60000; + break; + default: + break; + } + + return DefWindowProc(hWnd, uMsg, wParam, lParam); +} + + +static HWND +createWindow(int width, int height) { + static bool first = TRUE; + RECT rect; + + if (first) { + WNDCLASS wc; + memset(&wc, 0, sizeof wc); + wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1); + wc.hCursor = LoadCursor(NULL, IDC_ARROW); + wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wc.lpfnWndProc = WndProc; + wc.lpszClassName = "d3dretrace"; + wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW; + RegisterClass(&wc); + first = FALSE; + } + + DWORD dwExStyle; + DWORD dwStyle; + HWND hWnd; + + dwExStyle = 0; + dwStyle = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_OVERLAPPEDWINDOW; + + int x = 0, y = 0; + + rect.left = x; + rect.top = y; + rect.right = rect.left + width; + rect.bottom = rect.top + height; + + AdjustWindowRectEx(&rect, dwStyle, FALSE, dwExStyle); + + hWnd = CreateWindowEx(dwExStyle, + "d3dretrace", /* wc.lpszClassName */ + NULL, + dwStyle, + 0, /* x */ + 0, /* y */ + rect.right - rect.left, /* width */ + rect.bottom - rect.top, /* height */ + NULL, + NULL, + NULL, + NULL); + ShowWindow(hWnd, SW_SHOW); + return hWnd; +} + ''' retracer = D3DRetracer() retracer.retraceApi(d3d9) -- 2.45.2