Prepare for event system
Moved stuff around. Create an entry point for RSE. Created base for events module Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode@xyz>
This commit is contained in:
@@ -106,32 +106,20 @@ static rse_err_t render_static_mesh(struct graphics_context_t* context, uint32_t
|
||||
return RSE_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
rse_err_t rse_graphics_init(struct rse_graphics_context_t** context)
|
||||
rse_err_t rse_graphics_init(struct graphics_context_t* context)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
struct rse_graphics_context_t* ctx_ptr = NULL;
|
||||
|
||||
if (*context != NULL) {
|
||||
SDL_LogCritical(SDL_LOG_CATEGORY_GPU, "Graphics already initialized!");
|
||||
return RSE_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
rse_malloc(*context, sizeof(struct rse_graphics_context_t));
|
||||
ctx_ptr = *context;
|
||||
rse_malloc(ctx_ptr->context, sizeof(struct graphics_context_t));
|
||||
rse_memset(ctx_ptr->context, 0, sizeof(struct graphics_context_t));
|
||||
|
||||
STATUS_CHECK(window_init(&ctx_ptr->context->window_handle, &ctx_ptr->context->is_framebuffer_resized));
|
||||
STATUS_CHECK(vulkan_init(ctx_ptr->context));
|
||||
STATUS_CHECK(window_init(&context->window_handle, &context->is_framebuffer_resized));
|
||||
STATUS_CHECK(vulkan_init(context));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
#define TEXTURES_COUNT (2U)
|
||||
rse_err_t rse_graphics_test_function(struct rse_graphics_context_t* rse_context)
|
||||
rse_err_t rse_graphics_test_function(struct graphics_context_t* context)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
struct graphics_context_t* context = rse_context->context;
|
||||
rse_id_t textures[TEXTURES_COUNT] = {0};
|
||||
struct pipeline_t pipeline;
|
||||
rse_id_t descriptor_set_handle = 0;
|
||||
@@ -257,11 +245,9 @@ rse_err_t rse_graphics_test_function(struct rse_graphics_context_t* rse_context)
|
||||
return RSE_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
int rse_graphics_run(void* arg)
|
||||
rse_err_t rse_graphics_main_loop(struct graphics_context_t* context)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
struct rse_graphics_context_t* rse_context = (struct rse_graphics_context_t*)arg;
|
||||
struct graphics_context_t* context = rse_context->context;
|
||||
|
||||
STATUS_CHECK(vulkan_run(context));
|
||||
STATUS_CHECK(window_loop(context));
|
||||
@@ -270,8 +256,6 @@ int rse_graphics_run(void* arg)
|
||||
|
||||
window_terminate(context->window_handle);
|
||||
rse_free(context->debug_overlay.pixels);
|
||||
rse_free(context);
|
||||
rse_free(rse_context);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "SDL3/SDL_log.h"
|
||||
#include "utilities/commons.h"
|
||||
#include "utilities/errors_common.h"
|
||||
#include "utilities/time_utils.h"
|
||||
@@ -43,7 +44,8 @@ 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
|
||||
|
||||
(void)is_framebuffer_resized;; // TODO: Actually use this parameter?
|
||||
(void)is_framebuffer_resized;
|
||||
// TODO: Actually use this parameter?
|
||||
|
||||
*window_handle = SDL_CreateWindow("RedScarfEngine", 1024, 768, SDL_WINDOW_VULKAN);
|
||||
|
||||
@@ -65,8 +67,12 @@ rse_err_t window_loop(struct graphics_context_t* context)
|
||||
|
||||
while (0 == done) {
|
||||
while (SDL_PollEvent(&event)) {
|
||||
if (SDL_EVENT_QUIT == event.type) {
|
||||
done = 1;
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_QUIT:
|
||||
done = 1;
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user