Tscope5
Main Page
Related Pages
Files
Examples
display02.c
////////////////////////////////////////////////////////////////////////////////
//
// __ ______
// / /_______________ ____ ___ / ____/
// / __/ ___/ ___/ __ \/ __ \/ _ \ /___ )
// / /_(__ ) /__/ /_/ / /_/ / __/ ____/ /
// \__/____/\___/\____/ .___/\___/ /_____/
// /_/
//
// display02.c
// - Open a windowed display.
// - Count back from 10 to 0:
// - Draw on a bitmap.
// - Then display the bitmap.
// - Wait for a click.
//
// - The visual output of this example is identical to display01.c.
// - This functionality is mainly useful if it takes a long time
// to draw your stimuli.
////////////////////////////////////////////////////////////////////////////////
#include <tscope5.h>
int
main()
{
// open a display
ts5_install_display
();
// query the display size of the first display
double
w, h;
ts5_get_display_size
(1, &w, &h);
// allocate a bitmap, same size as the display
TS5_BITMAP *map =
ts5_alloc_bitmap
(w, h);
int
i;
for
(i=10; i>=0; i--) {
// set the bitmap as the drawing target
// clear it
// and print the number on the bitmap
ts5_set_drawing_target
(map);
ts5_clear_display
();
ts5_printf
(0.0, 0.0,
"%d"
, i);
// set the first display as the drawing target
// draw the bitmap
ts5_set_active_display
(1);
ts5_draw_bitmap
(map, 0.0, 0.0);
ts5_flip_display
();
ts5_wait
(0.5);
ts5_clear_display
();
}
// always free the objects you allocated!
ts5_free_bitmap
(map);
// wait for a click
ts5_draw_mouse_button
(0.0,0.0);
return
0;
}