Debian Codegraph @

src/gui/render/renderDX11.h

raw
1 /**
2 * Furnace Tracker - multi-system chiptune tracker
3 * Copyright (C) 2021-2025 tildearrow and contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "../gui.h"
21 #ifdef INCLUDE_D3D11
22 #include <d3d11.h>
23 #else
24 typedef void ID3D11DeviceContext;
25 typedef void ID3D11RenderTargetView;
26 typedef void ID3D11Buffer;
27 typedef void ID3D11RasterizerState;
28 typedef void ID3D11BlendState;
29 typedef void ID3D11VertexShader;
30 typedef void ID3D11PixelShader;
31 typedef void ID3D11InputLayout;
32 typedef void IDXGISwapChain;
33 #endif
34
35 class FurnaceGUIRenderDX11: public FurnaceGUIRender {
36 ID3D11Device* device;
37 ID3D11DeviceContext* context;
38 ID3D11RenderTargetView* renderTarget;
39 IDXGISwapChain* swapchain;
40 ID3D11RasterizerState* rsState;
41 ID3D11BlendState* omBlendState;
42
43 ID3D11Buffer* quadVertex;
44 int outW, outH, swapInterval;
45
46 bool dead;
47
48 // SHADERS //
49 // -> wipe
50 ID3D11VertexShader* sh_wipe_vertex;
51 ID3D11PixelShader* sh_wipe_fragment;
52 ID3D11InputLayout* sh_wipe_inputLayout;
53 ID3D11Buffer* sh_wipe_uniform;
54 struct WipeUniform {
55 float alpha;
56 float padding[7];
57 };
58
59 int maxWidth, maxHeight;
60 String vendorName, deviceName, apiVersion;
61
62 bool destroyRenderTarget();
63 bool createRenderTarget();
64
65 public:
66 ImTextureID getTextureID(FurnaceGUITexture* which);
67 FurnaceGUITextureFormat getTextureFormat(FurnaceGUITexture* which);
68 bool lockTexture(FurnaceGUITexture* which, void** data, int* pitch);
69 bool unlockTexture(FurnaceGUITexture* which);
70 bool updateTexture(FurnaceGUITexture* which, void* data, int pitch);
71 FurnaceGUITexture* createTexture(bool dynamic, int width, int height, bool interpolate=true, FurnaceGUITextureFormat format=GUI_TEXFORMAT_ABGR32);
72 bool destroyTexture(FurnaceGUITexture* which);
73 void setTextureBlendMode(FurnaceGUITexture* which, FurnaceGUIBlendMode mode);
74 void setBlendMode(FurnaceGUIBlendMode mode);
75 void resized(const SDL_Event& ev);
76 void clear(ImVec4 color);
77 void newFrame();
78 bool canVSync();
79 void renderGUI();
80 void wipe(float alpha);
81 void present();
82 bool getOutputSize(int& w, int& h);
83 int getWindowFlags();
84 int getMaxTextureWidth();
85 int getMaxTextureHeight();
86 unsigned int getTextureFormats();
87 const char* getBackendName();
88 const char* getVendorName();
89 const char* getDeviceName();
90 const char* getAPIVersion();
91 void setSwapInterval(int swapInterval);
92 void preInit(const DivConfig& conf);
93 bool init(SDL_Window* win, int swapInterval);
94 void initGUI(SDL_Window* win);
95 void quitGUI();
96 bool quit();
97 bool isDead();
98 FurnaceGUIRenderDX11():
99 device(NULL),
100 context(NULL),
101 renderTarget(NULL),
102 swapchain(NULL),
103 rsState(NULL),
104 omBlendState(NULL),
105 quadVertex(NULL),
106 outW(0),
107 outH(0),
108 swapInterval(1),
109 dead(false),
110 sh_wipe_vertex(NULL),
111 sh_wipe_fragment(NULL),
112 sh_wipe_inputLayout(NULL),
113 sh_wipe_uniform(NULL),
114 maxWidth(8192),
115 maxHeight(8192) {
116 }
117 };