enable vsync by default for sdl3 backend, cleanup headers

This commit is contained in:
asrael 2025-10-18 08:48:14 -05:00
parent 9d183341ae
commit 865a2b4518
3 changed files with 9 additions and 6 deletions

View file

@ -2,20 +2,16 @@
#define PXL8_COPYRIGHT "Copyright (c) 2024-2025 pxl8.org" #define PXL8_COPYRIGHT "Copyright (c) 2024-2025 pxl8.org"
#define PXL8_VERSION "0.1.0" #define PXL8_VERSION "0.1.0"
#include <pthread.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <linenoise.h>
#include "pxl8_cart.h" #include "pxl8_cart.h"
#include "pxl8_game.h" #include "pxl8_game.h"
#include "pxl8_hal.h" #include "pxl8_hal.h"
#include "pxl8_macros.h" #include "pxl8_macros.h"
#include "pxl8_script.h" #include "pxl8_script.h"
#include "pxl8_sdl3.h"
#include "pxl8_types.h" #include "pxl8_types.h"
#include "pxl8_ui.h" #include "pxl8_ui.h"

View file

@ -1,10 +1,13 @@
#include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "pxl8_io.h" #include "pxl8_io.h"
#include "pxl8_types.h" #include "pxl8_types.h"
static inline char pxl8_to_lower(char c) {
return (c >= 'A' && c <= 'Z') ? c + 32 : c;
}
pxl8_result pxl8_io_read_file(const char* path, char** content, size_t* size) { pxl8_result pxl8_io_read_file(const char* path, char** content, size_t* size) {
if (!path || !content || !size) return PXL8_ERROR_NULL_POINTER; if (!path || !content || !size) return PXL8_ERROR_NULL_POINTER;
@ -121,7 +124,7 @@ static i32 pxl8_key_code(const char* key_name) {
char lower_name[64]; char lower_name[64];
size_t i; size_t i;
for (i = 0; i < sizeof(lower_name) - 1 && key_name[i]; i++) { for (i = 0; i < sizeof(lower_name) - 1 && key_name[i]; i++) {
lower_name[i] = (char)tolower((unsigned char)key_name[i]); lower_name[i] = pxl8_to_lower(key_name[i]);
} }
lower_name[i] = '\0'; lower_name[i] = '\0';

View file

@ -57,6 +57,10 @@ static void* sdl3_create(pxl8_color_mode mode, pxl8_resolution resolution,
return NULL; return NULL;
} }
if (!SDL_SetRenderVSync(ctx->renderer, 1)) {
pxl8_error("Failed to enable vsync: %s", SDL_GetError());
}
SDL_SetRenderLogicalPresentation(ctx->renderer, fb_w, fb_h, SDL_SetRenderLogicalPresentation(ctx->renderer, fb_w, fb_h,
SDL_LOGICAL_PRESENTATION_INTEGER_SCALE); SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);