José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2012 Jose Fonseca |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | * |
| 24 | **************************************************************************/ |
| 25 | |
Jose Fonseca | 9653f95 | 2015-05-19 16:32:43 +0100 | [diff] [blame] | 26 | #pragma once |
José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 27 | |
José Fonseca | 5b130ba | 2012-05-13 09:45:04 +0100 | [diff] [blame] | 28 | |
| 29 | #include <windows.h> |
| 30 | |
José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 31 | #include "retrace.hpp" |
José Fonseca | 5773beb | 2012-11-14 11:46:58 +0000 | [diff] [blame] | 32 | #include "d3dstate.hpp" |
José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 33 | |
| 34 | |
| 35 | namespace d3dretrace { |
| 36 | |
| 37 | |
José Fonseca | 50c2a14 | 2015-01-15 13:10:46 +0000 | [diff] [blame] | 38 | extern const retrace::Entry ddraw_callbacks[]; |
José Fonseca | 73341c2 | 2012-11-24 13:04:42 +0000 | [diff] [blame] | 39 | extern const retrace::Entry d3d8_callbacks[]; |
José Fonseca | fbcb5d9 | 2012-11-13 09:28:23 +0000 | [diff] [blame] | 40 | extern const retrace::Entry d3d9_callbacks[]; |
José Fonseca | 73341c2 | 2012-11-24 13:04:42 +0000 | [diff] [blame] | 41 | extern const retrace::Entry dxgi_callbacks[]; |
José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 42 | |
| 43 | |
José Fonseca | 5773beb | 2012-11-14 11:46:58 +0000 | [diff] [blame] | 44 | template< class Device > |
| 45 | class D3DDumper : public retrace::Dumper { |
| 46 | public: |
| 47 | Device *pLastDevice; |
| 48 | |
| 49 | D3DDumper() : |
| 50 | pLastDevice(NULL) |
| 51 | {} |
| 52 | |
Rob Clark | d4bf220 | 2017-01-30 13:10:36 -0500 | [diff] [blame] | 53 | int |
| 54 | getSnapshotCount(void) override { |
| 55 | return 1; |
| 56 | } |
| 57 | |
José Fonseca | 5773beb | 2012-11-14 11:46:58 +0000 | [diff] [blame] | 58 | image::Image * |
Rob Clark | d4bf220 | 2017-01-30 13:10:36 -0500 | [diff] [blame] | 59 | getSnapshot(int n) { |
| 60 | if ((n != 0) || !pLastDevice) { |
José Fonseca | 5773beb | 2012-11-14 11:46:58 +0000 | [diff] [blame] | 61 | return NULL; |
| 62 | } |
| 63 | return d3dstate::getRenderTargetImage(pLastDevice); |
| 64 | } |
| 65 | |
| 66 | bool |
Jose Fonseca | e8ba079 | 2015-05-01 12:38:03 +0100 | [diff] [blame] | 67 | canDump(void) { |
| 68 | return pLastDevice; |
| 69 | } |
| 70 | |
| 71 | void |
| 72 | dumpState(StateWriter &writer) { |
| 73 | d3dstate::dumpDevice(writer, pLastDevice); |
José Fonseca | 5773beb | 2012-11-14 11:46:58 +0000 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | inline void |
| 77 | bindDevice(Device *pDevice) { |
| 78 | pLastDevice = pDevice; |
| 79 | retrace::dumper = this; |
| 80 | } |
| 81 | |
| 82 | inline void |
| 83 | unbindDevice(Device *pDevice) { |
| 84 | if (pLastDevice == pDevice) { |
| 85 | pLastDevice = NULL; |
| 86 | } |
| 87 | } |
| 88 | }; |
| 89 | |
| 90 | |
José Fonseca | 5b130ba | 2012-05-13 09:45:04 +0100 | [diff] [blame] | 91 | HWND |
| 92 | createWindow(int width, int height); |
| 93 | |
Jose Fonseca | 835f6f5 | 2015-12-22 12:50:30 +0000 | [diff] [blame] | 94 | HWND |
| 95 | createWindow(HWND hWnd, int width, int height); |
| 96 | |
José Fonseca | 0dd1f3d | 2012-08-03 16:47:54 +0100 | [diff] [blame] | 97 | void |
| 98 | resizeWindow(HWND hWnd, int width, int height); |
| 99 | |
José Fonseca | 0a02e6f | 2012-08-03 19:56:23 +0100 | [diff] [blame] | 100 | bool |
| 101 | processEvents(void); |
| 102 | |
José Fonseca | 5b130ba | 2012-05-13 09:45:04 +0100 | [diff] [blame] | 103 | |
José Fonseca | 8e3c2c0 | 2012-01-23 00:30:35 +0000 | [diff] [blame] | 104 | } /* namespace d3dretrace */ |
| 105 | |
| 106 | |