Skip to content

Commit 88fa11a

Browse files
committed
调整capture
1 parent 46b4b79 commit 88fa11a

12 files changed

Lines changed: 511 additions & 498 deletions

Lens/Lens.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ xcopy /Y "$(SolutionDir)\3rd\imgui\backends\imgui_impl_win32.cpp" "$(ProjectDir)
185185
<ClInclude Include="include\gui\UIManager.h" />
186186
<ClInclude Include="include\gui\DemoPanel.h" />
187187
<ClInclude Include="include\gui\DebugPanel.h" />
188+
<ClInclude Include="include\gui\CapturePanel.h" />
188189
</ItemGroup>
189190
<ItemGroup>
190191
<ClCompile Include="src\graphics\Buffer.cpp" />
@@ -196,16 +197,16 @@ xcopy /Y "$(SolutionDir)\3rd\imgui\backends\imgui_impl_win32.cpp" "$(ProjectDir)
196197
<ClCompile Include="src\gui\UIManager.cpp" />
197198
<ClCompile Include="src\gui\DemoPanel.cpp" />
198199
<ClCompile Include="src\gui\DebugPanel.cpp" />
200+
<ClCompile Include="src\gui\CapturePanel.cpp" />
199201
<ClCompile Include="src\LensPch.cpp">
200202
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
201203
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
202204
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
203205
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
204206
</ClCompile>
205-
<ClCompile Include="src\main_wgc_test.cpp" />
207+
<ClCompile Include="src\main.cpp" />
206208
<!-- <ClCompile Include="src\main.cpp" /> -->
207209
<ClCompile Include="src\Application.cpp" />
208-
<ClCompile Include="src\WGCTestApp.cpp" />
209210
<!-- 以下为imgui引入需要编译的文件 -->
210211
<ClCompile Include="src\imgui\imgui.cpp">
211212
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>

Lens/imgui.ini

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,23 @@ Pos=60,60
33
Size=400,400
44

55
[Window][Dear ImGui Demo]
6-
Pos=-1,0
6+
Pos=52,23
77
Size=550,658
88
Collapsed=1
99

1010
[Window][Demo Panel]
11-
Pos=60,60
11+
Pos=231,171
1212
Size=219,170
1313

1414
[Window][Debug Info]
15-
Pos=60,60
16-
Size=226,219
15+
Pos=174,106
16+
Size=226,228
17+
18+
[Window][Window Capture]
19+
Pos=618,239
20+
Size=1544,911
21+
22+
[Window][Capture]
23+
Pos=436,239
24+
Size=1608,871
1725

Lens/include/Application.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#pragma once
22
#include <Windows.h>
33
#include "graphics/GraphicsDevice.h"
4+
#include "graphics/Shader.h"
45
#include "ImguiManager.h"
6+
#include "capturer/WGCCapturer.h"
7+
#include <memory>
8+
#include <d3dcompiler.h>
9+
#include <wrl/client.h>
510

611
namespace lens
712
{
@@ -19,8 +24,14 @@ namespace lens
1924

2025
static LRESULT CALLBACK WindowProcProxy(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2126

27+
// Public getter for capturer access from UI panels
28+
capturer::WGCCapturer* GetCapturer() const { return m_capturer.get(); }
29+
2230
private:
2331
bool CreateLenWindow(int width = 800, int height = 600);
32+
bool CreateCaptureShaders();
33+
bool CreateCaptureSampler();
34+
bool CompileShader(const std::string& code, const char* entryPoint, const char* target, Microsoft::WRL::ComPtr<ID3DBlob>& blob);
2435

2536
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2637

@@ -31,6 +42,13 @@ namespace lens
3142
graphics::GraphicsDevice* m_graphicsDevice;
3243
ImguiManager* m_imgui;
3344

45+
// WGC Capture related
46+
std::unique_ptr<capturer::WGCCapturer> m_capturer;
47+
graphics::Shader m_captureShader;
48+
Microsoft::WRL::ComPtr<ID3D11SamplerState> m_captureSampler;
49+
Microsoft::WRL::ComPtr<ID3D11Buffer> m_captureConstantBuffer;
50+
std::shared_ptr<graphics::Texture> m_lastCapturedFrame;
51+
3452
int width;
3553
int height;
3654
std::wstring m_className;

Lens/include/gui/CapturePanel.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include "UIPanel.h"
4+
#include "capturer/WGCCapturer.h"
5+
6+
namespace lens
7+
{
8+
class CapturePanel : public UIPanel
9+
{
10+
private:
11+
bool m_visible = true;
12+
capturer::WGCCapturer* m_capturer;
13+
std::shared_ptr<lens::graphics::Texture> m_lastFrame; // Cache the latest frame
14+
15+
public:
16+
CapturePanel();
17+
virtual ~CapturePanel() = default;
18+
19+
void SetCapturer(capturer::WGCCapturer* capturer) { m_capturer = capturer; }
20+
21+
const char* GetName() const override { return "Capture"; }
22+
bool IsVisible() const override { return m_visible; }
23+
void SetVisible(bool visible) override { m_visible = visible; }
24+
void Render() override;
25+
26+
void Initialize() override;
27+
void Shutdown() override;
28+
};
29+
}

Lens/include/gui/UIManager.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@
88

99
namespace lens
1010
{
11+
// 前向声明
12+
namespace capturer
13+
{
14+
class WGCCapturer;
15+
}
16+
1117
class UIManager
1218
{
1319
private:
1420
std::vector<std::unique_ptr<UIPanel>> m_panels;
1521
std::map<std::string, UIPanel*> m_panelMap;
1622
bool m_showMenu = true;
1723

24+
// 注册所有默认面板
25+
void RegisterDefaultPanels();
26+
void RegisterCorePanels();
27+
void RegisterCapturePanels(capturer::WGCCapturer* capturer);
28+
1829
public:
1930
UIManager() = default;
2031
~UIManager() = default;
2132

33+
// 统一初始化所有面板(推荐使用)
34+
void InitializeAllPanels(capturer::WGCCapturer* capturer = nullptr);
35+
36+
// 手动添加面板的方法
2237
template<typename T, typename... Args>
2338
T* AddPanel(Args&&... args)
2439
{

0 commit comments

Comments
 (0)