[WIP] Refactor project

There are many problems with the way the current version is provided
and maintained. This commit or series of commits will fix this.
This commit is contained in:
Piotr Krygier committed 2025-06-20 13:44:33 +02:00
1 parent f5ab5f3f27
commit 173a82b9d1
63 files changed
+2663 -2239

No files matched your search

+20 -39
View File
@@ -10,20 +10,15 @@
*/
#include "window.h"
#include <stdint.h>
#include "GLFW/glfw3.h"
#include "locale_window.h"
#include "rse_window_errors.h"
#include "src/vulkan_commons.h"
#include "utilities/localization.h"
#include "window_errors.h"
#include "utilities/logger.h"
#include "utilities/rse_errors_common.h"
#include "utilities/errors_common.h"
#include "vulkan/vulkan_core.h"
#include "vulkan_base.h"
GLFWwindow *g_window_handle = NULL;
uint8_t g_is_frambuffer_resized = 0U;
/**
* @brief GLFW error callback
*
@@ -58,26 +53,27 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
static void framebuffer_resized_callback(GLFWwindow* window, int width, int height)
{
bool* is_frambuffer_resized = (bool*)glfwGetWindowUserPointer(window);
(void)window;
(void)width;
(void)height;
g_is_frambuffer_resized = 1;
*is_frambuffer_resized = 1;
}
rse_err_t window_init()
rse_err_t window_init(GLFWwindow* window_handle, bool* is_framebuffer_resized)
{
/* Initiliaze GLFW AP */
if (GLFW_TRUE != glfwInit())
{
LOGF(window_error_messages[WINDOW_GLFW_INIT_FAILED]);
LOGF(_("GLFW init failed!\n"));
return WINDOW_ERROR_GLFW_INIT_FAILED;
}
/* Check for Vulkan support */
if (GLFW_FALSE == glfwVulkanSupported()) {
LOGF(window_error_messages[WINDOW_VULKAN_NOT_SUPPORTED]);
LOGF(_("Unable to load Vulkan\n"));
return WINDOW_ERROR_VULKAN_NOT_LOADED;
}
@@ -87,48 +83,33 @@ rse_err_t window_init()
/* Create window */
glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
g_window_handle = glfwCreateWindow(640, 480, "RedScarfEngine", NULL, NULL);
window_handle = glfwCreateWindow(640, 480, "RedScarfEngine", NULL, NULL);
if (NULL == g_window_handle) {
LOGF(window_error_messages[WINDOW_NOT_CREATED]);
if (NULL == window_handle) {
LOGF(_("Window context creation failed\n"));
return WINDOW_ERROR_WINDOW_NOT_CREATED;
}
glfwSetKeyCallback(g_window_handle, key_callback);
glfwSetFramebufferSizeCallback(g_window_handle, framebuffer_resized_callback);
glfwSetKeyCallback(window_handle, key_callback);
glfwSetFramebufferSizeCallback(window_handle, framebuffer_resized_callback);
glfwSetWindowUserPointer(window_handle, is_framebuffer_resized);
return RSE_ERROR_NO_ERROR;
}
rse_err_t window_loop()
rse_err_t window_loop(struct graphics_context_t* context)
{
while (!glfwWindowShouldClose(g_window_handle)) {
while (!glfwWindowShouldClose(context->window_handle)) {
glfwPollEvents();
draw_frame();
draw_frame(context);
}
vkDeviceWaitIdle(g_vulkan_state.device);
vkDeviceWaitIdle(context->device);
return RSE_ERROR_NO_ERROR;
}
void window_terminate()
void window_terminate(GLFWwindow* window_handle)
{
glfwDestroyWindow(g_window_handle);
glfwDestroyWindow(window_handle);
glfwTerminate();
}
GLFWwindow* get_window_handle()
{
return g_window_handle;
}
uint8_t is_framebuffer_resized()
{
return g_is_frambuffer_resized;
}
void reset_framebuffer_resized()
{
g_is_frambuffer_resized = 0U;
}