get rid of g_window use in ptk.c
This commit is contained in:
parent
8d017e2268
commit
22f41e1172
3 changed files with 14 additions and 8 deletions
16
src/ptk.c
16
src/ptk.c
|
@ -107,16 +107,16 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const
|
|||
|
||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
|
||||
|
||||
g_window = glfwCreateWindow(width, height, title, NULL, NULL);
|
||||
GLFWwindow *window = glfwCreateWindow(width, height, title, NULL, NULL);
|
||||
|
||||
if (g_window == NULL) {
|
||||
if (window == NULL) {
|
||||
PTK_ERR("failed creating GLFW window");
|
||||
return false;
|
||||
}
|
||||
|
||||
glfwSetFramebufferSizeCallback(g_window, vk_framebuffer_resized);
|
||||
glfwSetKeyCallback(g_window, key_callback);
|
||||
glfwSetMouseButtonCallback(g_window, mouse_button_callback);
|
||||
glfwSetFramebufferSizeCallback(window, vk_framebuffer_resized);
|
||||
glfwSetKeyCallback(window, key_callback);
|
||||
glfwSetMouseButtonCallback(window, mouse_button_callback);
|
||||
|
||||
vk_init_vertices();
|
||||
|
||||
|
@ -128,9 +128,9 @@ bool ptk_init(const size_t width, const size_t height, const char *title, const
|
|||
// this fixes an issue where components would get drawn squished
|
||||
// and their hitboxes wouldn't match up with them visually
|
||||
int actual_width = 0, actual_height = 0;
|
||||
glfwGetFramebufferSize(g_window, &actual_width, &actual_height);
|
||||
glfwGetFramebufferSize(window, &actual_width, &actual_height);
|
||||
|
||||
if (!vk_init(g_window, actual_width, actual_height, title, application_version)) {
|
||||
if (!vk_init(window, actual_width, actual_height, title, application_version)) {
|
||||
PTK_ERR("failed initializing vulkan");
|
||||
return false;
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ PtkHandle ptk_clickable(PtkHandle hitbox, const MouseButtonCallback on_press) {
|
|||
int ptk_run(PtkHandle root) {
|
||||
vk_init_components(root);
|
||||
|
||||
while (!glfwWindowShouldClose(g_window)) {
|
||||
while (!vk_is_done()) {
|
||||
glfwPollEvents();
|
||||
if (!vk_draw_frame()) {
|
||||
break;
|
||||
|
|
|
@ -342,6 +342,10 @@ bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool vk_is_done(void) {
|
||||
return glfwWindowShouldClose(g_window);
|
||||
}
|
||||
|
||||
void vk_cleanup(void) {
|
||||
vk_cleanup_swapchain(g_dev);
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ extern VkRenderPass g_render_pass;
|
|||
|
||||
bool vk_init(GLFWwindow *window, const size_t width, const size_t height, const char *title, const PtkVersion version);
|
||||
|
||||
bool vk_is_done(void);
|
||||
|
||||
bool vk_transfer_vertex_data(void);
|
||||
|
||||
bool vk_record_command_buffer(const VkCommandBuffer command_buffer, const uint32_t image_index);
|
||||
|
|
Loading…
Reference in a new issue