Removed DUSK_ prefix

This commit is contained in:
2025-08-23 10:13:49 -05:00
parent 1bf6fe6eaf
commit 1dfde00317
28 changed files with 148 additions and 101 deletions

View File

@@ -289,7 +289,7 @@ void consoleUpdate() {
exec->cmd->function(exec);
}
// #if DUSK_KEYBOARD_SUPPORT == 1
// #if KEYBOARD_SUPPORT == 1
// uint8_t key;
// while((key = inputKeyboardPop()) != 0) {
// printf("Key pressed: %c\n", key);

View File

@@ -41,7 +41,7 @@ typedef struct {
bool_t visible;
// May move these later
// #if DUSK_KEYBOARD_SUPPORT == 1
// #if KEYBOARD_SUPPORT == 1
// char_t inputBuffer[CONSOLE_LINE_MAX];
// int32_t inputIndex;
// #endif

View File

@@ -37,14 +37,14 @@ void gameUpdate(void) {
// Game logic is tied to 60FPS for now, saves me a lot of hassle with float
// issues
float_t timeSinceLastTick = TIME.time - TIME.lastTick;
while(timeSinceLastTick >= DUSK_TIME_STEP) {
while(timeSinceLastTick >= TIME_STEP) {
sceneUpdate();
uiTextboxUpdate();
eventUpdate();
inputUpdate();
timeSinceLastTick -= DUSK_TIME_STEP;
timeSinceLastTick -= TIME_STEP;
TIME.lastTick = TIME.time;
}

View File

@@ -15,18 +15,18 @@ void timeInit(void) {
memoryZero(&TIME, sizeof(TIME));
// Set these to something non-zero.
TIME.lastTick = DUSK_TIME_STEP;
TIME.delta = TIME.realDelta = DUSK_TIME_STEP;
TIME.realTime = TIME.time = DUSK_TIME_STEP * 2;
TIME.lastTick = TIME_STEP;
TIME.delta = TIME.realDelta = TIME_STEP;
TIME.realTime = TIME.time = TIME_STEP * 2;
}
void timeUpdate(void) {
TIME.realDelta = timeDeltaGet();
#if DUSK_TIME_DYNAMIC
#if TIME_DYNAMIC
TIME.delta = TIME.realDelta;
#else
TIME.delta = DUSK_TIME_PLATFORM_STEP;
TIME.delta = TIME_PLATFORM_STEP;
#endif
assertTrue(TIME.delta >= 0.0f, "Time delta is negative");

View File

@@ -18,15 +18,15 @@ typedef struct {
extern dusktime_t TIME;
#define DUSK_TIME_STEP (1.0f / 60.0f) // Default to 60FPS
#define TIME_STEP (1.0f / 60.0f) // Default to 60FPS
#ifndef DUSK_TIME_DYNAMIC
#define DUSK_TIME_DYNAMIC 1
#ifndef TIME_DYNAMIC
#define TIME_DYNAMIC 1
#endif
#if DUSK_TIME_DYNAMIC == 0
#ifndef DUSK_TIME_PLATFORM_STEP
#define DUSK_TIME_PLATFORM_STEP DUSK_TIME_STEP
#if TIME_DYNAMIC == 0
#ifndef TIME_PLATFORM_STEP
#define TIME_PLATFORM_STEP TIME_STEP
#endif
#endif
@@ -40,7 +40,7 @@ void timeInit(void);
*/
void timeUpdate(void);
#if DUSK_TIME_DYNAMIC == 1
#if TIME_DYNAMIC == 1
/**
* Gets the time delta since the last frame, in seconds. Tied to the
* platform.

View File

@@ -27,7 +27,7 @@ void consoleInit() {
consolePrint(" = Dawn Console = ");
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadInit(&CONSOLE.thread, consoleInputThread);
threadMutexInit(&CONSOLE.execMutex);
threadStartRequest(&CONSOLE.thread);
@@ -75,7 +75,7 @@ void consolePrint(const char_t *message, ...) {
}
void consoleExec(const char_t *line) {
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadMutexLock(&CONSOLE.execMutex);
#endif
@@ -279,13 +279,13 @@ void consoleExec(const char_t *line) {
}
}
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadMutexUnlock(&CONSOLE.execMutex);
#endif
}
void consoleUpdate() {
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadMutexLock(&CONSOLE.execMutex);
#endif
@@ -298,13 +298,13 @@ void consoleUpdate() {
// Clear the exec buffer
CONSOLE.execBufferCount = 0;
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadMutexUnlock(&CONSOLE.execMutex);
#endif
}
void consoleDispose(void) {
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
threadStop(&CONSOLE.thread);
threadMutexDispose(&CONSOLE.execMutex);
#endif
@@ -312,7 +312,7 @@ void consoleDispose(void) {
consolePrint(" = Console shutting down = ");
}
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
void consoleInputThread(thread_t *thread) {
assertNotNull(thread, "Thread cannot be NULL.");
@@ -325,7 +325,7 @@ void consoleDispose(void) {
};
while(!threadShouldStop(thread) && ENGINE.running) {
int32_t rc = poll(&pfd, 1, DUSK_CONSOLE_POSIX_POLL_RATE);
int32_t rc = poll(&pfd, 1, CONSOLE_POSIX_POLL_RATE);
if(rc == 0) continue;
if(rc < 0) {

View File

@@ -9,12 +9,12 @@
#include "consolevar.h"
#include "consolecmd.h"
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
#include "thread/thread.h"
#include <poll.h>
#include <unistd.h>
#define DUSK_CONSOLE_POSIX_POLL_RATE 75
#define CONSOLE_POSIX_POLL_RATE 75
#endif
typedef enum {
@@ -48,7 +48,7 @@ typedef struct {
bool_t visible;
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
char_t inputBuffer[CONSOLE_LINE_MAX];
thread_t thread;
threadmutex_t execMutex;
@@ -114,7 +114,7 @@ void consoleUpdate();
*/
void consoleDispose(void);
#if DUSK_CONSOLE_POSIX
#if CONSOLE_POSIX
/**
* Input thread handler for posix input.
*

View File

@@ -19,17 +19,18 @@ add_subdirectory(texture)
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_DISPLAY_SDL2=1
DISPLAY_SDL2=1
DISPLAY_WINDOW_WIDTH_DEFAULT=960
DISPLAY_WINDOW_HEIGHT_DEFAULT=720
)
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_DISPLAY_SDL2=1
DISPLAY_SDL2=1
DISPLAY_WINDOW_WIDTH_DEFAULT=480
DISPLAY_WINDOW_HEIGHT_DEFAULT=272
DISPLAY_WIDTH=480
DISPLAY_HEIGHT=272
DISPLAY_SIZE_DYNAMIC=0
)
endif()

View File

@@ -30,7 +30,6 @@ void cameraEntityAdded(const ecsid_t id) {
cam->perspective.fov = glm_rad(90.0f);
cam->nearClip = 0.1f;
cam->farClip = 1000.0f;
cam->clearColor = COLOR_CORNFLOWER_BLUE;
}
void cameraPush(const ecsid_t id) {
@@ -67,7 +66,7 @@ void cameraPush(const ecsid_t id) {
);
}
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
mat4 pv;
glm_mat4_mul(projection, view, pv);
@@ -76,21 +75,13 @@ void cameraPush(const ecsid_t id) {
glLoadIdentity();
glLoadMatrixf((const GLfloat*)pv);
glClearColor(
cam->clearColor.r / 255.0f,
cam->clearColor.g / 255.0f,
cam->clearColor.b / 255.0f,
cam->clearColor.a / 255.0f
);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
#endif
}
void cameraPop(void) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glPopMatrix();
#endif
}

View File

@@ -32,7 +32,6 @@ typedef struct {
float_t nearClip;
float_t farClip;
color_t clearColor;
} camera_t;
extern camera_t CAMERA_DATA[ECS_ENTITY_COUNT_MAX];

View File

@@ -16,7 +16,7 @@
display_t DISPLAY;
errorret_t displayInit(void) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER) != 0) {
errorThrow("SDL Failed to Initialize: %s", SDL_GetError());
}
@@ -65,7 +65,7 @@ errorret_t displayInit(void) {
}
errorret_t displayUpdate(void) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
SDL_Event event;
while(SDL_PollEvent(&event)) {
switch(event.type) {
@@ -86,7 +86,7 @@ errorret_t displayUpdate(void) {
rendererRender(CAMERA_MAIN);
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
SDL_GL_SwapWindow(DISPLAY.window);
#endif
@@ -95,7 +95,7 @@ errorret_t displayUpdate(void) {
}
errorret_t displayDispose(void) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(DISPLAY.glContext) {
SDL_GL_DeleteContext(DISPLAY.glContext);
DISPLAY.glContext = NULL;

View File

@@ -8,11 +8,15 @@
#pragma once
#include "error/error.h"
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
#include <SDL2/SDL.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
#ifndef DISPLAY_SIZE_DYNAMIC
#define DISPLAY_SIZE_DYNAMIC 1
#endif
#else
#error "Need to specify display backend."
#endif
@@ -31,8 +35,10 @@
#define DISPLAY_WINDOW_HEIGHT_DEFAULT DISPLAY_HEIGHT
#endif
typedef struct {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
SDL_Window *window;
SDL_GLContext glContext;
#endif

View File

@@ -20,11 +20,15 @@ void frameBufferInitBackbuffer() {
}
int32_t frameBufferGetWidth(const framebuffer_t *framebuffer) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
int32_t windowWidth, windowHeight;
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
return windowWidth;
#if DISPLAY_SIZE_DYNAMIC == 0
return DISPLAY_WIDTH;
#else
int32_t windowWidth, windowHeight;
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
return windowWidth;
#endif
}
assertUnreachable("Framebuffer width not implemented");
@@ -33,11 +37,15 @@ int32_t frameBufferGetWidth(const framebuffer_t *framebuffer) {
}
int32_t frameBufferGetHeight(const framebuffer_t *framebuffer) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
int32_t windowWidth, windowHeight;
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
return windowHeight;
#if DISPLAY_SIZE_DYNAMIC == 0
return DISPLAY_HEIGHT;
#else
int32_t windowWidth, windowHeight;
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
return windowHeight;
#endif
}
assertUnreachable("Framebuffer height not implemented");
@@ -47,7 +55,7 @@ int32_t frameBufferGetHeight(const framebuffer_t *framebuffer) {
void frameBufferBind(const framebuffer_t *framebuffer) {
if(framebuffer == NULL) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
frameBufferBind(&FRAMEBUFFER_BACKBUFFER);
#endif
@@ -56,14 +64,19 @@ void frameBufferBind(const framebuffer_t *framebuffer) {
}
// Bind the framebuffer for rendering
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
#if PSP
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
int32_t windowWidth, windowHeight;
SDL_GetWindowSize(DISPLAY.window, &windowWidth, &windowHeight);
#else
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
#endif
} else {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id);
#if PSP
assertUnreachable("Framebuffers not supported on PSP");
#else
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framebuffer->id);
#endif
}
glViewport(
0, 0,
@@ -74,6 +87,28 @@ void frameBufferBind(const framebuffer_t *framebuffer) {
FRAMEBUFFER_BOUND = framebuffer;
}
void frameBufferClear(uint8_t flags, color_t color) {
#if DISPLAY_SDL2
GLbitfield glFlags = 0;
if(flags & FRAMEBUFFER_CLEAR_COLOR) {
glFlags |= GL_COLOR_BUFFER_BIT;
glClearColor(
color.r / 255.0f,
color.g / 255.0f,
color.b / 255.0f,
color.a / 255.0f
);
}
if(flags & FRAMEBUFFER_CLEAR_DEPTH) {
glFlags |= GL_DEPTH_BUFFER_BIT;
}
glClear(glFlags);
#endif
}
/**
* Disposes of the framebuffer using EXT methods.
*
@@ -82,7 +117,7 @@ void frameBufferBind(const framebuffer_t *framebuffer) {
void frameBufferDispose(framebuffer_t *framebuffer) {
assertNotNull(framebuffer, "Framebuffer cannot be NULL");
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
if(framebuffer == &FRAMEBUFFER_BACKBUFFER) {
assertUnreachable("Cannot dispose of backbuffer");
}

View File

@@ -9,8 +9,11 @@
#include "display/display.h"
#include "display/texture/texture.h"
#define FRAMEBUFFER_CLEAR_COLOR (1 << 0)
#define FRAMEBUFFER_CLEAR_DEPTH (1 << 1)
typedef struct {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
// OpenGL Framebuffer Object ID
GLuint id;
#endif
@@ -45,6 +48,14 @@ int32_t frameBufferGetHeight(const framebuffer_t *framebuffer);
*/
void frameBufferBind(const framebuffer_t *framebuffer);
/**
* Clears the currently bound framebuffer.
*
* @param flags The clear flags.
* @param color The color to clear the color buffer to (if clearing color).
*/
void frameBufferClear(uint8_t flags, color_t color);
/**
* Disposes of the framebuffer using EXT methods.
*

View File

@@ -43,7 +43,7 @@ void meshDraw(
"Vertex offset + count must not exceed vertex count"
);
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
// PSP style pointer legacy OpenGL
const GLsizei stride = sizeof(meshvertex_t);

View File

@@ -7,7 +7,7 @@
#include "display/display.h"
typedef enum {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
MESH_PRIMITIVE_TRIANGLES = GL_TRIANGLES,
MESH_PRIMITIVE_LINES = GL_LINES,
MESH_PRIMITIVE_POINTS = GL_POINTS,
@@ -19,7 +19,7 @@ typedef enum {
#define MESH_VERTEX_POS_SIZE 3
typedef struct {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
GLubyte color[MESH_VERTEX_COLOR_SIZE];
GLfloat uv[MESH_VERTEX_UV_SIZE];
GLfloat pos[MESH_VERTEX_POS_SIZE];

View File

@@ -20,6 +20,10 @@ void rendererRender(const ecsid_t camera) {
meshCount = meshRendererGetAll(meshes);
frameBufferBind(NULL);
frameBufferClear(
FRAMEBUFFER_CLEAR_COLOR | FRAMEBUFFER_CLEAR_DEPTH,
COLOR_CORNFLOWER_BLUE
);
cameraPush(camera);
for(uint32_t i = 0; i < meshCount; i++) {
id = meshes[i];

View File

@@ -37,7 +37,7 @@ void textureInit(
);
#endif
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glGenTextures(1, &texture->id);
glBindTexture(GL_TEXTURE_2D, texture->id);
glTexImage2D(
@@ -58,7 +58,7 @@ void textureBind(const texture_t *texture) {
if(TEXTURE_BOUND == texture) return;
if(texture == NULL) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glDisable(GL_TEXTURE_2D);
#endif
TEXTURE_BOUND = NULL;
@@ -74,7 +74,7 @@ void textureBind(const texture_t *texture) {
"Texture width and height must be greater than 0"
);
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture->id);
#endif
@@ -85,7 +85,7 @@ void textureDispose(texture_t *texture) {
assertNotNull(texture, "Texture cannot be NULL");
assertTrue(texture->id != 0, "Texture ID must not be 0");
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glDeleteTextures(1, &texture->id);
#endif
}

View File

@@ -10,14 +10,14 @@
#include "display/color.h"
typedef enum {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
TEXTURE_FORMAT_RGBA = GL_RGBA,
TEXTURE_FORMAT_ALPHA = GL_ALPHA,
#endif
} textureformat_t;
typedef struct {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
GLuint id;
#endif

View File

@@ -116,14 +116,14 @@ void nodeMatrixPush(const ecsid_t id) {
assertTrue(nodeHas(id), "Not a node component");
node_t *node = nodeGet(id);
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glPushMatrix();
glMultMatrixf((const GLfloat*)node->transform);
#endif
}
void nodeMatrixPop(void) {
#if DUSK_DISPLAY_SDL2
#if DISPLAY_SDL2
glPopMatrix();
#endif
}

View File

@@ -14,11 +14,11 @@ target_sources(${DUSK_TARGET_NAME}
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_THREAD_PTHREAD=1
THREAD_PTHREAD=1
)
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_THREAD_PTHREAD=1
THREAD_PTHREAD=1
)
endif()

View File

@@ -18,7 +18,7 @@ void threadInit(thread_t *thread, const threadcallback_t callback) {
thread->state = THREAD_STATE_STOPPED;
thread->callback = callback;
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
thread->threadId = 0;
#endif
}
@@ -30,7 +30,7 @@ void threadStartRequest(thread_t *thread) {
thread->state = THREAD_STATE_STARTING;
threadMutexUnlock(&thread->stateMutex);
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
assertTrue(thread->threadId == 0, "Thread id not 0.");
pthread_create(
@@ -93,7 +93,7 @@ bool_t threadShouldStop(thread_t *thread) {
return state;
}
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
void * threadHandler(thread_t *thread) {
assertNotNull(thread, "Thread cannot be NULL.");

View File

@@ -8,7 +8,7 @@
#pragma once
#include "thread/threadmutex.h"
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
#include <pthread.h>
#else
#error "At least one threading implementation must be defined."
@@ -40,7 +40,7 @@ typedef struct thread_s {
threadcallback_t callback;
void *data;
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_t threadId;
#endif
} thread_t;
@@ -93,7 +93,7 @@ void threadStop(thread_t *thread);
*/
bool_t threadShouldStop(thread_t *thread);
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
/**
* Handles the thread's lifecycle for pthreads.
* @param thread Pointer to the thread structure to handle.

View File

@@ -8,43 +8,43 @@
#include "threadmutex.h"
void threadMutexInit(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_mutex_init(&lock->mutex, NULL);
#endif
}
void threadMutexLock(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_mutex_lock(&lock->mutex);
#endif
}
bool_t threadMutexTryLock(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
return pthread_mutex_trylock(&lock->mutex) == 0;
#endif
}
void threadMutexUnlock(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_mutex_unlock(&lock->mutex);
#endif
}
void threadMutexWaitLock(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_cond_wait(&lock->cond, &lock->mutex);
#endif
}
void threadMutexSignal(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_cond_signal(&lock->cond);
#endif
}
void threadMutexDispose(threadmutex_t *lock) {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_mutex_destroy(&lock->mutex);
#endif
}

View File

@@ -8,14 +8,14 @@
#pragma once
#include "dusk.h"
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
#include <pthread.h>
#else
#error "At least one threading implementation must be defined."
#endif
typedef struct threadlock_t {
#if DUSK_THREAD_PTHREAD
#if THREAD_PTHREAD
pthread_mutex_t mutex;
pthread_cond_t cond;
#endif

View File

@@ -13,11 +13,11 @@ target_sources(${DUSK_TARGET_NAME}
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_TIME_SDL2=1
TIME_SDL2=1
)
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_TIME_FIXED=1
TIME_FIXED=1
)
endif()

View File

@@ -9,7 +9,7 @@
#include "util/memory.h"
#include "assert/assert.h"
#if DUSK_TIME_SDL2
#if TIME_SDL2
#include <SDL2/SDL.h>
#endif
@@ -19,16 +19,16 @@ void timeInit(void) {
memoryZero(&TIME, sizeof(TIME));
// Set these to something non-zero.
TIME.time = DUSK_TIME_STEP;
TIME.delta = DUSK_TIME_STEP;
TIME.time = TIME_STEP;
TIME.delta = TIME_STEP;
}
void timeUpdate(void) {
float_t delta;
#if DUSK_TIME_SDL2
#if TIME_SDL2
delta = (float_t)SDL_GetTicks() / 1000.0f - TIME.time;
#elif DUSK_TIME_FIXED
delta = DUSK_TIME_PLATFORM_STEP;
#elif TIME_FIXED
delta = TIME_PLATFORM_STEP;
#else
#error "No time platform defined"
#endif

View File

@@ -15,7 +15,7 @@ typedef struct {
extern dusktime_t TIME;
#define DUSK_TIME_STEP (1.0f / 60.0f) // Default to 60FPS
#define TIME_STEP (1.0f / 60.0f) // Default to 60FPS
/**
* Initializes the time system.