summaryrefslogtreecommitdiff
path: root/src/scene01.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/scene01.c')
-rw-r--r--src/scene01.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/scene01.c b/src/scene01.c
index 527e81a..7a6aed1 100644
--- a/src/scene01.c
+++ b/src/scene01.c
@@ -169,35 +169,20 @@ void scene01_free_caca(graphical_env_t *ge, scene01_env_t *se) {
}
int scene01_next_gl(graphical_env_t *ge, scene01_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;
+ SDL_Renderer *r = ge->gl_rndr;
// https://gist.github.com/Twinklebear/8265888
// https://forums.libsdl.org/viewtopic.php?p=51634
- // Render all the stuff on target texture
- SDL_SetRenderTarget(r, ge->sdl_target);
-
- glClear( GL_COLOR_BUFFER_BIT );
- glBindVertexArray( se->vao );
- glDrawArrays( GL_TRIANGLES, 0, 6 );
+ glClear(GL_COLOR_BUFFER_BIT);
+ glBindVertexArray(se->vao);
+ glDrawArrays(GL_TRIANGLES, 0, 6);
+ // [...]
- // Copy the SDL screen 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_GL_SwapWindow(ge->gl_win);
// 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
- caca_set_dither_gamma(ge->d, 1.0);
- 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;
}
@@ -212,6 +197,11 @@ int scene01_next_caca(graphical_env_t *ge, scene01_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_set_dither_gamma(ge->d, 1.0);
+ 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_WHITE, CACA_BLACK);
caca_put_str(cv, (w-17)/2, h/2, "This is a message");