cgloadlib; % loads Cogent Graphics commands - without which cg* commands don't run
start_cogent; % start cogent
cgopen(2,0,0,0); % define how to open (800*600 windowed)
cgfont('Arial',22) % set font type and size

cgpencol(1,1,1); % set pen colour to white
cgtext('black',0,0); % draw

cgflip(1,0,0); % flip buffer on screen, drawing the "new" buffer red
cgpencol(0,1,1);
cgtext('red',0,0);
wait(500);

cgflip(0,1,0); % flip buffer on screen, drawing the "new" buffer green
cgpencol(1,0,1);
cgtext('green',0,0);
wait(500);

% repeat a few times

cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);
cgflip;
wait(500);

cgflip(0,0,0); % flip last buffer on screen, draw "new" buffer black
wait(500);
cgflip(1,1,1); % flip black buffer on screen, draw buffer white
wait(500);

cgpencol(0,0,0);
cgtext('the end', 0,0); % bye bye
cgflip;
wait(500);

stop_cogent; % remember to stop
cgshut; % shuts the cogent window