FCT
载入中...
搜索中...
未找到
GLFW_Window.h
浏览该文件的文档.
1//
2// Created by Administrator on 2025/3/22.
3//
4#include "../ThirdParty.h"
5#include "./Window.h"
7#ifndef GLFW_WINDOW_H
8#define GLFW_WINDOW_H
9
10namespace FCT
11{
13 {
14 public:
16 void* getNativeHandler() override
17 {
18 return surface;
19 }
20 private:
21 void* surface;
22
23 };
25 class GLFW_Window : public Window
26 {
27 private:
29 public:
30 friend class GLFW_WindowBehavior;
31 GLFW_Window(GLFW_UICommon* common, Runtime* rt);
33 void invokeResizeCallbacks(int width, int height);
34 void invokeMouseMoveCallbacks(int xpos, int ypos);
35 void invokeMouseCallbacks(int button, int action, int mods);
36 void invokeKeyCallbacks(int key, int scancode, int action, int mods);
37 void invokeScrollCallbacks(int xoffset, int yoffset);
38 void createPlatform();
39 bool isRunning() const override;
40 void swapBuffers() override;
41 int getWidth() override;
42 int getHeight() override;
43 void setCursorPos(int x, int y) override;
44 Image* getImage() const override;
45 GLFWwindow* getWindow() const { return m_window; }
46 Vec2 getCursorPos() const override;
47 void postUiTask(UITaskFunction task,void* param = nullptr,bool waited = true)
48 {
49 m_common->postUiTask(task, param, waited);
50 }
51 uint32_t postTicker(UiTicker ticker)
52 {
53 return m_common->postTicker(ticker);
54 }
55 void sendUiTask(UITaskFunction task,void* param = nullptr,bool waited = true)
56 {
57 m_common->sendUiTask(task, param, waited);
58 }
59 private:
60 GLFWwindow* m_window;
63 void recreateSwapchain(int width, int height);
64#ifdef FCT_USE_VULKAN
65 VkSurfaceKHR m_vkSurface;
66#endif
68 };
69
70 class GLFW_UICommon;
71
72
74 public:
76 void pos(int x,int y)
77 {
78
79 }
80 void size(int w, int h)
81 {
82
83 }
84 void title(const std::string& title)
85 {
86 m_wnd->addRef();
87 m_wnd->m_common->postUiTask([this, title](void*)
88 {
89 glfwSetWindowTitle(m_wnd->m_window, title.c_str());
90 m_wnd->release();
91 },nullptr,false);
92 }
93 private:
95 };
96}
97
98#endif //GLFW_WINDOW_H
GLFW_WindowBehavior(GLFW_Window *wnd)
void title(const std::string &title)
void recreateSwapchain(int width, int height)
void postUiTask(UITaskFunction task, void *param=nullptr, bool waited=true)
Vec2 getCursorPos() const override
void invokeScrollCallbacks(int xoffset, int yoffset)
bool isRunning() const override
friend class GLFW_WindowBehavior
void invokeResizeCallbacks(int width, int height)
GLFW_UICommon * m_common
int getWidth() override
GLFW_Window(GLFW_UICommon *common, Runtime *rt)
void invokeKeyCallbacks(int key, int scancode, int action, int mods)
void setCursorPos(int x, int y) override
GLFWwindow * getWindow() const
void invokeMouseMoveCallbacks(int xpos, int ypos)
void sendUiTask(UITaskFunction task, void *param=nullptr, bool waited=true)
int getHeight() override
SwapchainTargetWrapper * getSwapchainTarget(Context *ctx) override
void swapBuffers() override
uint32_t postTicker(UiTicker ticker)
Image * getImage() const override
VkSurfaceKHR m_vkSurface
void invokeMouseCallbacks(int button, int action, int mods)
GLFWwindow * m_window
std::function< void(void *)> UITaskFunction
std::function< void(void)> UiTicker