blob: d5fc848fb77c8b6b326f42e471a951ad06d389e9 [file] [log] [blame]
José Fonseca8e3c2c02012-01-23 00:30:35 +00001/**************************************************************************
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 Fonseca9653f952015-05-19 16:32:43 +010026#pragma once
José Fonseca8e3c2c02012-01-23 00:30:35 +000027
José Fonseca5b130ba2012-05-13 09:45:04 +010028
29#include <windows.h>
30
José Fonseca8e3c2c02012-01-23 00:30:35 +000031#include "retrace.hpp"
José Fonseca5773beb2012-11-14 11:46:58 +000032#include "d3dstate.hpp"
José Fonseca8e3c2c02012-01-23 00:30:35 +000033
34
35namespace d3dretrace {
36
37
José Fonseca50c2a142015-01-15 13:10:46 +000038extern const retrace::Entry ddraw_callbacks[];
José Fonseca73341c22012-11-24 13:04:42 +000039extern const retrace::Entry d3d8_callbacks[];
José Fonsecafbcb5d92012-11-13 09:28:23 +000040extern const retrace::Entry d3d9_callbacks[];
José Fonseca73341c22012-11-24 13:04:42 +000041extern const retrace::Entry dxgi_callbacks[];
José Fonseca8e3c2c02012-01-23 00:30:35 +000042
43
José Fonseca5773beb2012-11-14 11:46:58 +000044template< class Device >
45class D3DDumper : public retrace::Dumper {
46public:
47 Device *pLastDevice;
48
49 D3DDumper() :
50 pLastDevice(NULL)
51 {}
52
Rob Clarkd4bf2202017-01-30 13:10:36 -050053 int
54 getSnapshotCount(void) override {
55 return 1;
56 }
57
José Fonseca5773beb2012-11-14 11:46:58 +000058 image::Image *
Rob Clarkd4bf2202017-01-30 13:10:36 -050059 getSnapshot(int n) {
60 if ((n != 0) || !pLastDevice) {
José Fonseca5773beb2012-11-14 11:46:58 +000061 return NULL;
62 }
63 return d3dstate::getRenderTargetImage(pLastDevice);
64 }
65
66 bool
Jose Fonsecae8ba0792015-05-01 12:38:03 +010067 canDump(void) {
68 return pLastDevice;
69 }
70
71 void
72 dumpState(StateWriter &writer) {
73 d3dstate::dumpDevice(writer, pLastDevice);
José Fonseca5773beb2012-11-14 11:46:58 +000074 }
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é Fonseca5b130ba2012-05-13 09:45:04 +010091HWND
92createWindow(int width, int height);
93
Jose Fonseca835f6f52015-12-22 12:50:30 +000094HWND
95createWindow(HWND hWnd, int width, int height);
96
José Fonseca0dd1f3d2012-08-03 16:47:54 +010097void
98resizeWindow(HWND hWnd, int width, int height);
99
José Fonseca0a02e6f2012-08-03 19:56:23 +0100100bool
101processEvents(void);
102
José Fonseca5b130ba2012-05-13 09:45:04 +0100103
José Fonseca8e3c2c02012-01-23 00:30:35 +0000104} /* namespace d3dretrace */
105
106