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);
133 glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
135 glfwSetWindowUserPointer(
m_window,
this);
136 glfwSetFramebufferSizeCallback(
m_window, [](GLFWwindow* window,
int width,
int height) {
137 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
140 glfwSetMouseButtonCallback(
m_window, [](GLFWwindow* window,
int button,
int action,
int mods) {
141 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
144 glfwSetCursorPosCallback(
m_window, [](GLFWwindow* window,
double xpos,
double ypos) {
145 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));\
148 glfwSetKeyCallback(
m_window, [](GLFWwindow* window,
int key,
int scancode,
int action,
int mods) {
149 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));
152 glfwSetScrollCallback(
m_window, [](GLFWwindow* window,
double xoffset,
double yoffset) {
153 auto* wnd =
static_cast<FCT::GLFW_Window*
>(glfwGetWindowUserPointer(window));
168 return !glfwWindowShouldClose(
m_window);
186 glfwGetWindowSize(
m_window, &width, &height);
193 glfwGetWindowSize(
m_window, &width, &height);
211 glfwGetCursorPos(
m_window, &xpos, &ypos);
212 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)
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