ref: 9ad38e532689b5ed8581f0f57c7f9ba458c10119
parent: 0eabd603f8768063fb423d7b065fe1124837e2f2
author: Jacob Moody <moody@posixcafe.org>
date: Sat Aug 26 09:09:48 EDT 2023
sdl2: add SDL_LockTexture and SDL_UnlockTexture
--- a/include/npe/SDL2/SDL.h
+++ b/include/npe/SDL2/SDL.h
@@ -159,6 +159,8 @@
int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors);
int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);
int SDL_SoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect);
+int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, int *pitch);
+int SDL_UnlockTexture(SDL_Texture *texture);
enum {
SDL_QUERY = -1,
--- a/libnpe_sdl2/sdl2.c
+++ b/libnpe_sdl2/sdl2.c
@@ -254,6 +254,24 @@
}
int
+SDL_LockTexture(SDL_Texture *t, const SDL_Rect *re, void **pixels, int *pitch)
+{
+ Rectangle r;
+
+ r = re ? Rect(re->x, re->y, re->x+re->w, re->y+re->h) : t->m->r;
+ *pitch = Dx(r)*(t->m->depth/8);
+ *pixels = t->m->data->bdata;
+ return 0;
+}
+
+int
+SDL_UnlockTexture(SDL_Texture *t)
+{
+ USED(t);
+ return 0;
+}
+
+int
SDL_UpdateTexture(SDL_Texture *t, SDL_Rect *re, void *pixels, int pitch)
{
Rectangle r;