From 59b9305bb847930d609d7f924c720bbf3d6dafa2 Mon Sep 17 00:00:00 2001 From: erysdren Date: Mon, 14 Oct 2024 15:08:21 -0500 Subject: [PATCH] don't use SDL_UpdateTexture() for this --- source/editor.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/editor.cpp b/source/editor.cpp index 7cfc74c..52147a7 100644 --- a/source/editor.cpp +++ b/source/editor.cpp @@ -10,6 +10,8 @@ static SDL_Texture *texture = nullptr; static void editor_yeti_tick(void) { + void *pixels; + int pitch; const bool *keys = SDL_GetKeyboardState(nullptr); yeti.keyboard.state.up = keys[SDL_SCANCODE_UP] || keys[SDL_SCANCODE_W]; @@ -24,7 +26,11 @@ static void editor_yeti_tick(void) game_loop(&yeti); - SDL_UpdateTexture(texture, nullptr, backbuffer, YETI_FRAMEBUFFER_WIDTH * sizeof(u16)); + if (SDL_LockTexture(texture, NULL, &pixels, &pitch)) + { + SDL_memcpy(pixels, (void *)backbuffer, sizeof(backbuffer)); + SDL_UnlockTexture(texture); + } } void editor_init(void)