FCT
载入中...
搜索中...
未找到
Window.cpp
浏览该文件的文档.
1#include "../FCTAPI.h"
2
4{
5 m_handlers.push_back(handler);
6 handler->addRef();
7}
8
10{
11 auto it = std::find(m_handlers.begin(), m_handlers.end(), handler);
12 if (it != m_handlers.end()) {
13 m_handlers.erase(it);
14 }
15 handler->release();
16}
17
19{
20 for (auto handler : m_handlers) {
21 handler->release();
22 }
23 m_handlers.clear();
24}
25
27{
28 m_swapchain->acquireFirstImage();
29}
30
32{
33 m_ctx = component.ctx;
34 auto surface = getSwapchainTarget(component.ctx);
36 m_swapchain->nativeHandle(surface->getNativeHandler());
38 m_swapchain->create();
39 delete surface;
40 m_swapchain->acquireFirstImage();
41 m_ctx->onWindowBound(this);
43}
44
46{
47 if (m_swapchain)
48 {
49 m_autoViewport = new AutoViewport(Vec2(component.width, component.height), Vec2(component.width, component.height));
50 m_autoViewport->window(this);
52 m_autoViewport->enable(true);
53 } else
54 {
55 m_delayModuleCreate.subscribe<WindowModule::Swapchain>([this,component]()
56 {
57 addModule(component);
58 });
59 }
60}
61
62
64{
65 m_depthBufferFormat = component.format;
67
68 if (m_swapchain)
69 {
70 enableDepthBuffer(component.format);
71 } else
72 {
73 m_delayModuleCreate.subscribe<WindowModule::Swapchain>([this,component]()
74 {
76 });
77 }
78}
79namespace FCT
80{
81
94
96 {
98 }
99}
100
101
void initRender()
std::vector< EventHandler * > m_handlers
bool m_needEnableDepthBuffer
virtual SwapchainTargetWrapper * getSwapchainTarget(Context *ctx)=0
void create(WindowCreateFlags flags=WindowCreateFlag::defaultConfig)
Format m_depthBufferFormat
void addSingleComponent(const WindowModule::Swapchain &component)
void enableDepthBuffer(Format format)
void bind(Context *ctx) override
Context * m_ctx
void addModule(Components &&... components)
virtual int getHeight()=0
virtual int getWidth()=0
AutoViewport * m_autoViewport
RHI::Swapchain * m_swapchain
void registerHandler(EventHandler *handler)
virtual void createPlatform()=0
void unregisterHandler(EventHandler *handler)
EventDispatcher< EventSystemConfig::IdentifierTriggerOnly > m_delayModuleCreate
void clearHandler()