From 25effd17ef1a1a05d671382b9a51be29734226a0 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sat, 7 Sep 2019 10:49:21 +0200 Subject: Multi-process done. GL has to be done cleanly now. --- src/scene00.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/scene00.c') diff --git a/src/scene00.c b/src/scene00.c index b1e4e57..f8df185 100644 --- a/src/scene00.c +++ b/src/scene00.c @@ -51,11 +51,7 @@ int scene00_next_gl(graphical_env_t *ge, scene00_env_t *se) { int scene00_next_sdl(graphical_env_t *ge, scene00_env_t *se) { // Shorthands - caca_canvas_t *cv = ge->cv; - int w = ge->w, h = ge->h; SDL_Renderer *r = ge->sdl_rndr; - // Local vars - int res; // https://gist.github.com/Twinklebear/8265888 // https://forums.libsdl.org/viewtopic.php?p=51634 @@ -65,17 +61,16 @@ int scene00_next_sdl(graphical_env_t *ge, scene00_env_t *se) { SDL_RenderCopy(r, se->eo1, NULL, NULL); // [...] - // Copy the SDL screen to SDL debug window (and display it, not mandatory) +#ifdef DEBUG + // Copy the target texture to SDL debug window (and display it, not mandatory) SDL_SetRenderTarget(r, NULL); SDL_RenderCopy(r, ge->sdl_target, NULL, NULL); SDL_RenderPresent(r); + SDL_SetRenderTarget(r, ge->sdl_target); +#endif // Download the rendered texture from videocard to main memory - SDL_SetRenderTarget(r, ge->sdl_target); - res = SDL_RenderReadPixels(r, NULL, 0, ge->raw_target, 256*4); - - // "convert" the raw pixel stream to ASCII art on caca canevas - if ( res == 0 ) caca_dither_bitmap(cv, 0, 0, w, h, ge->d, ge->raw_target); + SDL_RenderReadPixels(r, NULL, 0, ge->raw_target, FBUF_W*4); return 0; } @@ -86,6 +81,9 @@ int scene00_next_caca(graphical_env_t *ge, scene00_env_t *se) { int w = ge->w, h = ge->h; Uint32 frame = ge->sc_framecount; + // "convert" the raw pixel stream from SDL to ASCII art on caca canevas + caca_dither_bitmap(cv, 0, 0, w, h, ge->d, ge->raw_target); + // Add things on top of caca canvas caca_set_color_ansi(cv, CACA_BLACK, CACA_WHITE); caca_put_str(cv, (w-17)/2, h/2, "This is a message"); -- cgit v1.2.3