/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    dbuff1.c
    usage of the double buffer
*/

#include <tscope.h>

int main()
{

    // first of all, switch the double buffer on
    ts_doublebuff(ON);
    ts_init();
    ts_bgcolor(BLUE);

    // set the double buffer as target for
    // text or drawing functions
    ts_tobuff();

    // draw your stimulus on the double buffer
    ts_fgcolor(GREEN);
    ts_fill(TRUE);
    ts_circle(0, 0, 100);
    ts_floodfill(0, 0);

    // put some text on the screen
    ts_toscr();
    ts_fgcolor(WHITE);
    ts_printf_centre(0, 105, "double buffer example");
    ts_printf_centre(0, 75, "at this moment, the double buffer");
    ts_printf_centre(0, 60, "contains a circle");

    ts_printf_centre(0, 30, "we don't see anything yet");
    ts_button(XMAX - 20, -YMAX + 20);

    // blit the double buffer
    ts_blitbuff();

    // put some more text on the screen
    ts_printf_centre(0, 105, "now we blit the double buffer");
    ts_printf_centre(0, 90, "to the screen");
    ts_button(XMAX - 20, -YMAX + 20);

    // clear the buffer, no changes on the screen
    ts_clrbuff();
    ts_printf_centre(0, 60, "when we clear the double buffer");
    ts_printf_centre(0, 45, "the screen image remains");
    ts_button(XMAX - 20, -YMAX + 20);

    // blit the empty buffer
    ts_blitbuff();
    ts_printf_centre(0, 105, "if we blit the buffer again");
    ts_printf_centre(0, 90, "we can see that it's empty");

    ts_button(XMAX - 20, -YMAX + 20);
    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information