diff --git a/archive/dusk/console/console.c b/archive/dusk/console/console.c index e412d76..5c9e532 100644 --- a/archive/dusk/console/console.c +++ b/archive/dusk/console/console.c @@ -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); diff --git a/archive/dusk/console/console.h b/archive/dusk/console/console.h index a4ec9e9..41f248a 100644 --- a/archive/dusk/console/console.h +++ b/archive/dusk/console/console.h @@ -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 diff --git a/archive/dusk/game.c b/archive/dusk/game.c index 9ee1ead..e37b45a 100644 --- a/archive/dusk/game.c +++ b/archive/dusk/game.c @@ -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; } diff --git a/archive/dusk/time.c b/archive/dusk/time.c index 6056a42..0205a85 100644 --- a/archive/dusk/time.c +++ b/archive/dusk/time.c @@ -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"); diff --git a/archive/dusk/time.h b/archive/dusk/time.h index 7c878c8..32c1cbb 100644 --- a/archive/dusk/time.h +++ b/archive/dusk/time.h @@ -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. diff --git a/src/console/console.c b/src/console/console.c index 675517a..99576a9 100644 --- a/src/console/console.c +++ b/src/console/console.c @@ -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) { diff --git a/src/console/console.h b/src/console/console.h index c2c5833..2653ecd 100644 --- a/src/console/console.h +++ b/src/console/console.h @@ -9,12 +9,12 @@ #include "consolevar.h" #include "consolecmd.h" -#if DUSK_CONSOLE_POSIX +#if CONSOLE_POSIX #include "thread/thread.h" #include #include - #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. * diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 1643b6e..af12776 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/src/display/camera.c b/src/display/camera.c index 4cdc9ed..79622fd 100644 --- a/src/display/camera.c +++ b/src/display/camera.c @@ -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 } \ No newline at end of file diff --git a/src/display/camera.h b/src/display/camera.h index a795f2f..1317ffa 100644 --- a/src/display/camera.h +++ b/src/display/camera.h @@ -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]; diff --git a/src/display/display.c b/src/display/display.c index b15359d..4cf3f7e 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -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; diff --git a/src/display/display.h b/src/display/display.h index f34c152..154f6e5 100644 --- a/src/display/display.h +++ b/src/display/display.h @@ -8,11 +8,15 @@ #pragma once #include "error/error.h" -#if DUSK_DISPLAY_SDL2 +#if DISPLAY_SDL2 #include #define GL_GLEXT_PROTOTYPES #include #include + + #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 diff --git a/src/display/framebuffer/framebuffer.c b/src/display/framebuffer/framebuffer.c index 2b51cd6..120f497 100644 --- a/src/display/framebuffer/framebuffer.c +++ b/src/display/framebuffer/framebuffer.c @@ -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"); } diff --git a/src/display/framebuffer/framebuffer.h b/src/display/framebuffer/framebuffer.h index f34bd70..2bce751 100644 --- a/src/display/framebuffer/framebuffer.h +++ b/src/display/framebuffer/framebuffer.h @@ -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. * diff --git a/src/display/mesh/mesh.c b/src/display/mesh/mesh.c index d5b09d4..636d5f0 100644 --- a/src/display/mesh/mesh.c +++ b/src/display/mesh/mesh.c @@ -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); diff --git a/src/display/mesh/mesh.h b/src/display/mesh/mesh.h index a9a4439..0b576a7 100644 --- a/src/display/mesh/mesh.h +++ b/src/display/mesh/mesh.h @@ -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]; diff --git a/src/display/renderer.c b/src/display/renderer.c index 4db9d6f..8242d2d 100644 --- a/src/display/renderer.c +++ b/src/display/renderer.c @@ -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]; diff --git a/src/display/texture/texture.c b/src/display/texture/texture.c index 0f028c6..7afb522 100644 --- a/src/display/texture/texture.c +++ b/src/display/texture/texture.c @@ -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 } \ No newline at end of file diff --git a/src/display/texture/texture.h b/src/display/texture/texture.h index b92078a..d73884f 100644 --- a/src/display/texture/texture.h +++ b/src/display/texture/texture.h @@ -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 diff --git a/src/scene/node.c b/src/scene/node.c index 9e35b1f..6557200 100644 --- a/src/scene/node.c +++ b/src/scene/node.c @@ -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 } \ No newline at end of file diff --git a/src/thread/CMakeLists.txt b/src/thread/CMakeLists.txt index 9287173..89404af 100644 --- a/src/thread/CMakeLists.txt +++ b/src/thread/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/src/thread/thread.c b/src/thread/thread.c index b62b7ac..83a22de 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -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."); diff --git a/src/thread/thread.h b/src/thread/thread.h index 2672b91..8235f33 100644 --- a/src/thread/thread.h +++ b/src/thread/thread.h @@ -8,7 +8,7 @@ #pragma once #include "thread/threadmutex.h" -#if DUSK_THREAD_PTHREAD +#if THREAD_PTHREAD #include #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. diff --git a/src/thread/threadmutex.c b/src/thread/threadmutex.c index e0b4807..e19164a 100644 --- a/src/thread/threadmutex.c +++ b/src/thread/threadmutex.c @@ -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 } \ No newline at end of file diff --git a/src/thread/threadmutex.h b/src/thread/threadmutex.h index 8cd7e3c..4a684a2 100644 --- a/src/thread/threadmutex.h +++ b/src/thread/threadmutex.h @@ -8,14 +8,14 @@ #pragma once #include "dusk.h" -#if DUSK_THREAD_PTHREAD +#if THREAD_PTHREAD #include #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 diff --git a/src/time/CMakeLists.txt b/src/time/CMakeLists.txt index 4db9ca4..80797bd 100644 --- a/src/time/CMakeLists.txt +++ b/src/time/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/src/time/time.c b/src/time/time.c index 05e455b..52b4828 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -9,7 +9,7 @@ #include "util/memory.h" #include "assert/assert.h" -#if DUSK_TIME_SDL2 +#if TIME_SDL2 #include #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 diff --git a/src/time/time.h b/src/time/time.h index 36a0784..63dde6a 100644 --- a/src/time/time.h +++ b/src/time/time.h @@ -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.