Files
RedScarfEngine/graphics/src/window.c
T
2025-08-29 10:02:14 +02:00

63 lines
1.4 KiB
C

/**
* @file window.cxx
* @author Piotr Krygier (everyonencancode@gmail.com)
* @brief
* @version 0.1
* @date 2022-02-15
*
* @copyright Copyright (c) 2022
*
*/
#include "window.h"
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_init.h>
#include <SDL3/SDL_video.h>
#include <stdint.h>
#include "utilities/commons.h"
#include "utilities/localization.h"
#include "window_errors.h"
#include "utilities/logger.h"
#include "utilities/errors_common.h"
#include "vulkan/vulkan_core.h"
#include "vulkan_base.h"
rse_err_t window_init(SDL_Window **window_handle, bool *is_framebuffer_resized)
{
SDL_Init(SDL_INIT_VIDEO); //TODO: Move to initial phase of RSE initialization
*window_handle = SDL_CreateWindow("RedScarfEngine", 640, 480, SDL_WINDOW_VULKAN);
if (NULL == *window_handle) {
LOGF(_("Window context creation failed\n"));
return WINDOW_ERROR_WINDOW_NOT_CREATED;
}
return RSE_ERROR_NO_ERROR;
}
rse_err_t window_loop(struct graphics_context_t* context)
{
uint8_t done = 0;
SDL_Event event;
while (0 == done) {
while (SDL_PollEvent(&event)) {
if (SDL_EVENT_QUIT == event.type) {
done = 1;
}
}
draw_frame(context);
}
vkDeviceWaitIdle(context->device);
return RSE_ERROR_NO_ERROR;
}
void window_terminate(SDL_Window* window_handle)
{
SDL_DestroyWindow(window_handle);
}