35 ferr <<
"Failed to create Vulkan surface. Error code: " << res << std::endl;
42 ferr <<
"没有受支持的context" << std::endl;
78 cb->onResize(
this, width, height);
85 cb->onMouseMove(
this,
static_cast<int>(xpos),
static_cast<int>(ypos));
92 glfwGetCursorPos(
m_window, &xpos, &ypos);
95 if (action == GLFW_PRESS) {
96 if (button == GLFW_MOUSE_BUTTON_LEFT) {
97 cb->onLButtonDown(
this,
static_cast<int>(xpos),
static_cast<int>(ypos));
98 }
else if (button == GLFW_MOUSE_BUTTON_RIGHT) {
99 cb->onRButtonDown(
this,
static_cast<int>(xpos),
static_cast<int>(ypos));
101 }
else if (action == GLFW_RELEASE) {
102 if (button == GLFW_MOUSE_BUTTON_LEFT) {
103 cb->onLButtonUp(
this,
static_cast<int>(xpos),
static_cast<int>(ypos));
104 }
else if (button == GLFW_MOUSE_BUTTON_RIGHT) {
105 cb->onRButtonUp(
this,
static_cast<int>(xpos),
static_cast<int>(ypos));
114 if (action == GLFW_PRESS) {
115 cb->onKeyDown(
this, key);
116 }
else if (action == GLFW_RELEASE) {
117 cb->onKeyUp(
this, key);
125 cb->onMouseWheel(
this, yoffset);
131 std::vector<std::string> filePaths;
132 for (
int i = 0; i <
count; ++i)
133 filePaths.push_back(paths[i]);
135 cb->onFileDrop(
this, filePaths);
143 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
145 glfwSetWindowUserPointer(
m_window,
this);
146 glfwSetFramebufferSizeCallback(
m_window, [](GLFWwindow* window,
int width,
int height) {
147 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
150 glfwSetMouseButtonCallback(
m_window, [](GLFWwindow* window,
int button,
int action,
int mods) {
151 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
154 glfwSetCursorPosCallback(
m_window, [](GLFWwindow* window,
double xpos,
double ypos) {
155 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
158 glfwSetKeyCallback(
m_window, [](GLFWwindow* window,
int key,
int scancode,
int action,
int mods) {
159 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));
162 glfwSetScrollCallback(
m_window, [](GLFWwindow* window,
double xoffset,
double yoffset) {
163 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));
166 glfwSetDropCallback(
m_window, [](GLFWwindow* window,
int count,
const char** paths) {
167 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));
182 return !glfwWindowShouldClose(
m_window);
200 glfwGetWindowSize(
m_window, &width, &height);
207 glfwGetWindowSize(
m_window, &width, &height);
225 glfwGetCursorPos(
m_window, &xpos, &ypos);
226 return FCT::Vec2(
static_cast<float>(xpos),
static_cast<float>(ypos));
#define FCT_SAFE_RELEASE(obj)
void recreateSwapchain(int width, int height)
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_Window(GLFW_UICommon *common, Runtime *rt)
void invokeKeyCallbacks(int key, int scancode, int action, int mods)
void setCursorPos(int x, int y) override
void invokeMouseMoveCallbacks(int xpos, int ypos)
SwapchainTargetWrapper * getSwapchainTarget(Context *ctx) override
void swapBuffers() override
void * m_swapchainNativeHandle
Image * getImage() const override
void invokeMouseCallbacks(int button, int action, int mods)
std::vector< EventHandler * > m_handlers
WindowBehavior * m_behavior
RHI::Swapchain * m_swapchain