summaryrefslogtreecommitdiff
path: root/src/scene00.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scene00.c')
-rw-r--r--src/scene00.c18
1 files changed, 8 insertions, 10 deletions
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");