forked from ExplosionEngine/Explosion
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraphicsWidget.cpp
More file actions
49 lines (40 loc) · 1.33 KB
/
GraphicsWidget.cpp
File metadata and controls
49 lines (40 loc) · 1.33 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
//
// Created by Kindem on 2025/3/16.
//
#include <Editor/Widget/GraphicsWidget.h>
#include <Editor/Widget/moc_GraphicsWidget.cpp> // NOLINT
#include <Render/RenderModule.h>
namespace Editor {
GraphicsWidget::GraphicsWidget(QWidget* inParent)
: QWidget(inParent)
{
setAttribute(Qt::WA_NativeWindow);
setAttribute(Qt::WA_PaintOnScreen);
setAttribute(Qt::WA_NoSystemBackground);
const Render::RenderModule& renderModule = Core::ModuleManager::Get().GetTyped<Render::RenderModule>("Render");
device = renderModule.GetDevice();
Assert(device != nullptr);
surface = device->CreateSurface(
RHI::SurfaceCreateInfo()
.SetWindow(reinterpret_cast<void*>(winId()))); // NOLINT
}
GraphicsWidget::~GraphicsWidget() = default;
RHI::Device& GraphicsWidget::GetDevice() const
{
return *device;
}
RHI::Surface& GraphicsWidget::GetSurface() const
{
return *surface;
}
QPaintEngine* GraphicsWidget::paintEngine() const
{
return nullptr;
}
void GraphicsWidget::WaitDeviceIdle() const
{
const Common::UniquePtr<RHI::Fence> fence = device->CreateFence(false);
device->GetQueue(RHI::QueueType::graphics, 0)->Flush(fence.Get());
fence->Wait();
}
} // namespace Editor