Fix time and subprojects
Moved SDL3 to subprojects. Fixed time calculation. Signed-off-by: Piotr Krygier <piotrkrygier@everyonecancode.xyz>
This commit is contained in:
1 parent
ca1477b500
commit
eff8c43224
6 files changed
+42
-12
No files matched your search
@@ -17,7 +17,7 @@ rse_graphics_sources = [
|
||||
|
||||
vulkan_dep = dependency('Vulkan')
|
||||
|
||||
sdl3_dep = dependency('sdl3', version: '>=3.4.0')
|
||||
sdl3_dep = dependency('sdl3', version: '>=3.4.0', default_options : ['warning_level=0', 'werror=false'])
|
||||
|
||||
freetype_dep = dependency('freetype2', version: '>=22.1.16')
|
||||
glm_dep = dependency('cglm', version: '>=0.9.6', method: 'cmake')
|
||||
@@ -30,6 +30,10 @@ stb = dependency('stb',
|
||||
rse_graphics_lib = shared_library(
|
||||
'rse_graphics',
|
||||
rse_graphics_sources,
|
||||
override_options: [
|
||||
'warning_level=3',
|
||||
'werror=true'
|
||||
],
|
||||
include_directories: ['../'],
|
||||
dependencies: [
|
||||
vulkan_dep,
|
||||
@@ -51,4 +55,4 @@ rse_graphics_lib_dep = declare_dependency(
|
||||
glm_dep
|
||||
],
|
||||
include_directories: include_directories('.')
|
||||
)
|
||||
)
|
||||
@@ -1,8 +1,17 @@
|
||||
#include "rse_graphics.h"
|
||||
|
||||
#ifdef __unix__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||
#endif
|
||||
#include <SDL3/SDL_init.h>
|
||||
#include <SDL3/SDL_error.h>
|
||||
#include <SDL3/SDL_log.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
#ifdef __unix__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#include <cglm/util.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
@@ -110,6 +119,8 @@ rse_err_t rse_graphics_init(struct graphics_context_t* context)
|
||||
{
|
||||
rse_err_t status = RSE_ERROR_NO_ERROR;
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
STATUS_CHECK(window_init(&context->window_handle, &context->is_framebuffer_resized));
|
||||
STATUS_CHECK(vulkan_init(context));
|
||||
|
||||
|
||||
@@ -225,7 +225,9 @@ static rse_err_t create_instance(VkInstance* instance)
|
||||
}
|
||||
|
||||
/* Check if selected extensions are supported*/
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_GPU, "Enabled extensions names:");
|
||||
for (i = 0; i < enabled_instance_extensions_count; ++i) {
|
||||
SDL_LogDebug(SDL_LOG_CATEGORY_GPU, "\t-%s", enabled_instance_extensions_names[i]);
|
||||
for (j = 0; j < extensionCount; ++j) {
|
||||
if (strcmp(extensions_properties[j].extensionName, enabled_instance_extensions_names[i]) == 0) {
|
||||
supported = 1;
|
||||
|
||||
+2
-5
@@ -1,12 +1,9 @@
|
||||
project('RedScarfEngine',
|
||||
['c', 'cpp'],
|
||||
version: '0.0.1',
|
||||
default_options: [
|
||||
'warning_level=3',
|
||||
'werror=true'
|
||||
])
|
||||
)
|
||||
|
||||
add_project_arguments('-DWAYLAND=1', language : 'c')
|
||||
# add_project_arguments('-DWAYLAND=1', language : 'c')
|
||||
|
||||
subdir('utilities')
|
||||
subdir('graphics')
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
[wrap-file]
|
||||
directory = SDL3-3.4.12
|
||||
source_url = https://github.com/libsdl-org/SDL/releases/download/release-3.4.12/SDL3-3.4.12.tar.gz
|
||||
source_filename = SDL3-3.4.12.tar.gz
|
||||
source_hash = f07b958a9ac5020fb7a44cadb957f658b2149c3c8abb4f63145fac9303249db7
|
||||
source_fallback_url = https://wrapdb.mesonbuild.com/v2/sdl3_3.4.12-1/get_source/SDL3-3.4.12.tar.gz
|
||||
patch_filename = sdl3_3.4.12-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/sdl3_3.4.12-1/get_patch
|
||||
patch_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl3_3.4.12-1/sdl3_3.4.12-1_patch.zip
|
||||
patch_hash = 67e859d280c9cc2de422efebc4f1edf954984b59e79eddf6c92ab61d89cd874d
|
||||
wrapdb_version = 3.4.12-1
|
||||
|
||||
[provide]
|
||||
dependency_names = sdl3
|
||||
@@ -5,11 +5,14 @@
|
||||
#include "errors_common.h"
|
||||
|
||||
#define NS_TO_S(time) (time/1000000000)
|
||||
float g_time = 0.0f;
|
||||
float g_dt = 0.0f;
|
||||
double g_last_time = 0.0;
|
||||
|
||||
rse_err_t time_init(void)
|
||||
{
|
||||
g_last_time = NS_TO_S((double)SDL_GetTicksNS());
|
||||
g_time = g_last_time;
|
||||
|
||||
return RSE_ERROR_NO_ERROR;
|
||||
}
|
||||
@@ -21,13 +24,12 @@ double time_get_sec_from_start(void)
|
||||
|
||||
void time_update(void)
|
||||
{
|
||||
g_last_time = NS_TO_S((double)SDL_GetTicksNS());
|
||||
g_last_time = g_time;
|
||||
g_time = NS_TO_S((double)SDL_GetTicksNS());
|
||||
g_dt = g_time - g_last_time;
|
||||
}
|
||||
|
||||
double time_get_dt(void)
|
||||
{
|
||||
float time = NS_TO_S((double)SDL_GetTicksNS());
|
||||
float dt = time - g_last_time;
|
||||
|
||||
return dt;
|
||||
return g_dt;
|
||||
}
|
||||
Reference in new issue
Block a user