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 invokeFileDropCallbacks(int count, const char** paths);
39 void createPlatform();
40 bool isRunning() const override;
41 void swapBuffers() override;
42 int getWidth() override;
43 int getHeight() override;
44 void setCursorPos(int x, int y) override;
45 Image* getImage() const override;
46 GLFWwindow* getWindow() const { return m_window; }
47 Vec2 getCursorPos() const override;
48 void postUiTask(UITaskFunction task,void* param = nullptr,bool waited = true)
49 {
50 m_common->postUiTask(task, param, waited);
51 }
52 uint32_t postTicker(UiTicker ticker)
53 {
54 return m_common->postTicker(ticker);
55 }
56 void sendUiTask(UITaskFunction task,void* param = nullptr,bool waited = true)
57 {
58 m_common->sendUiTask(task, param, waited);
59 }
60 private:
61 GLFWwindow* m_window;
64 void recreateSwapchain(int width, int height);
65#ifdef FCT_USE_VULKAN
66 VkSurfaceKHR m_vkSurface;
67#endif
69 };
70
71 class GLFW_UICommon;
72
73
75 public:
77 void pos(int x,int y)
78 {
79
80 }
81 void size(int w, int h)
82 {
83
84 }
85 void title(const std::string& title)
86 {
87 m_wnd->addRef();
88 m_wnd->m_common->postUiTask([this, title](void*)
89 {
90 glfwSetWindowTitle(m_wnd->m_window, title.c_str());
91 m_wnd->release();
92 },nullptr,false);
93 }
94 private:
96 };
97}
98
99#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)
void invokeFileDropCallbacks(int count, const char **paths)
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