-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.cpp
More file actions
181 lines (149 loc) · 5.28 KB
/
Copy pathEngine.cpp
File metadata and controls
181 lines (149 loc) · 5.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#include "Engine.h"
Engine::~Engine()
{
_ffmpeg.ShutDownDecoder();
_framequeue.Shutdown();
_framepool.Shutdown();
if(_DecodeingLoop_Thread.joinable())
{
_DecodeingLoop_Thread.join();
}
}
void Engine::CreateNormalWindowAndRun(HINSTANCE hInstance)
{
_window.InitDebugConsole();
_window.CreateMainWindow(hInstance);
_window.ShowMainWindow();
//_window.MessageLoopRun();
}
void Engine::CreateWindowOnWorkerWAndRun(HINSTANCE hInstance)
{
_window.InitDebugConsole();
_window.CreateMainWindow(hInstance);
_workerW.SpawnWorkerW();
_workerW.FindWorkerW();
_window.AttachHwndToWorkerW(_workerW.GetWorkerW());
_window.ShowMainWindow();
//_window.MessageLoopRun();
}
void Engine::SeeWindowTree()
{
_window.InitDebugConsole();
_workerW.SpawnWorkerW();
_workerW.PrintWindowThree();
}
void Engine::testDx()
{
_window.InitDebugConsole();
_dxdevice.CreateDeviceAndDeviceContext();
}
void Engine::testDXandSwapchin(HINSTANCE hInstance)
{
_window.CreateMainWindow(hInstance);
_dxdevice.CreateDeviceAndDeviceContext();
_swapchin.CreateSwapChin1(
_window.GetWindowHeight(),
_window.GetWindowWidth(),
_dxdevice.GetDevice());
}
void Engine::testDXandswapanddcomp(HINSTANCE hInstance)
{
_window.InitDebugConsole();
_window.CreateMainWindow(hInstance);
_dxdevice.CreateDeviceAndDeviceContext();
_swapchin.CreateSwapChin1(
_window.GetWindowHeight(),
_window.GetWindowWidth(),
_dxdevice.GetDevice());
_swapchin.CreateRTVForBackBuffer(_dxdevice.GetDevice(), _dxdevice.GetDeviceContext());
_DComp.CreateDComp(_window.GetHWND(), _swapchin.GetSwapChin(), _dxdevice.GetDevice());
}
/*
* Just my though ignore this:
* So today is 25th march of 2026.. and i working on this project
* because i want a wallpaper engine but wallpaper engien is not free and not
* Expensive too but i cant Afford because my parent dont really give me money
* for this kinda stuff. soo i start lookinh for other wallpaper engine options but
* other are heavy like really.. some of take like 70 or 100% use of my intel IGPU
* FYI i have a intel iris Xe.. and i want it too like take only 50 or 40% of use my
* GPU okay.. so thats why i started this project. and i test the prototype and it
* Working good i use everyday.. i set it to 'shell:startup' soo now it open as my laptop
* open and also it was not easy i choose to use DX11 and FYI agian i have no idea
* what a Graphic programming even is. and also by this project i learn so many new
* thinks and iam glad that i started this project. i mainly started this project like
* january 7 or 8th (2026) i forget but somethink like that thank you and sorry for my
* bad english 😅
*/
void Engine::MakeWindowRunwhitWorkerWandRunDXandswapchin(HINSTANCE hInstance)
{
_window.InitDebugConsole();
_window.CreateMainWindow(hInstance);
_workerW.SpawnWorkerW();
_workerW.FindWorkerW();
_window.AttachHwndToWorkerW(_workerW.GetWorkerW());
_dxdevice.CreateDeviceAndDeviceContext();
_swapchin.CreateSwapChin1(
_window.GetWindowHeight(),
_window.GetWindowWidth(),
_dxdevice.GetDevice());
_swapchin.CreateRTVForBackBuffer(_dxdevice.GetDevice(), _dxdevice.GetDeviceContext());
_DComp.CreateDComp(_window.GetHWND(), _swapchin.GetSwapChin(), _dxdevice.GetDevice());
_window.ShowMainWindow();
_window.MessageLoopRun([&]() {_render.cleanscreen(_swapchin.GetRTVOfBackBuffer(), _swapchin.GetSwapChin(), _dxdevice.GetDeviceContext()); });
}
void Engine::MakeWindowRunwhitWorkerWandRunDXandswapchinWhitFFmpeg(HINSTANCE hInstance)
{
//_window.InitDebugConsole();
auto args_data = _parse.get_data();
_framequeue.init(args_data.buffer_count);
_framepool.init(_framequeue.GetSizeofBuffer()); //do this because sizeofbuffer need to be clamp
// that happand on _framequeue.init thats why use geter func of sizeofbuffer
_window.CreateMainWindow(hInstance);
_workerW.SpawnWorkerW();
_workerW.FindWorkerW();
_window.AttachHwndToWorkerW(_workerW.GetWorkerW());
_dxdevice.CreateDeviceAndDeviceContext();
_ffmpeg.InitFFmpeg(args_data.video_path.c_str(), _dxdevice.GetDevice(),
_dxdevice.GetDeviceContext(), _framequeue.GetSizeofBuffer());
_DecodeingLoop_Thread = std::thread([this]()
{
_ffmpeg.RunDecoderLoop(
[this](AVFrame* f, double pts) { return _framequeue.push(f, pts); },
[this]() {return _framepool.GetFrame(); },
[this](AVFrame* f) {_framepool.ReturnFrame(f); }
);
});
_swapchin.CreateSwapChin1(
_window.GetWindowHeight(),
_window.GetWindowWidth(),
_dxdevice.GetDevice()
);
_swapchin.CreateRTVForBackBuffer(_dxdevice.GetDevice(), _dxdevice.GetDeviceContext());
_DComp.CreateDComp(_window.GetHWND(), _swapchin.GetSwapChin(), _dxdevice.GetDevice());
_dxva.InitDXVA(
_dxdevice.GetDevice(),
_dxdevice.GetDeviceContext(),
_swapchin.GetBackBuffer(),
_ffmpeg.GetCodecContext(),
_swapchin.GetSwapChinWidth(),
_swapchin.GetSwapChinHeight()
);
_window.ShowMainWindow();
/*
PostMessageW call here!
*/
_mypostmessage.postmessage(args_data.client_hwnd,
WM_ENGINE_SENT_HWND,
0, reinterpret_cast<LPARAM>(_window.GetHWND()));
/*^^^^^^^^^^^^^^^*/
_window.MessageLoopRun([this]()
{
_render.RenderFrame(_swapchin.GetRTVOfBackBuffer(),
_swapchin.GetSwapChin(),
_dxdevice.GetDeviceContext(),
[this](double &pts) { return _framequeue.pop(pts); },
[this](AVFrame* f) { _framepool.ReturnFrame(f); },
[this](AVFrame* f) { return _dxva.ProcessFrame(f); }
);
});
}