]> git.sesse.net Git - ccbs/blob - bigscreen/tinyptc/test.c
Fixed a misleading comment.
[ccbs] / bigscreen / tinyptc / test.c
1 /*
2  * TinyPTC x11 v0.7.3 Example file
3  * Copyright (C) 2001-2002 Alessandro Gatti <a.gatti@tiscali.it>
4  * Copyright (C) 2000-2001 Glenn Fiedler <gaffer@gaffer.org>
5  *
6  * http://www.sourceforge.net/projects/tinyptc/
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  */
23
24 #include "tinyptc.h"
25
26 #include <stdio.h>
27
28 #define WIDTH 320
29 #define HEIGHT 200
30 #define SIZE WIDTH*HEIGHT
31
32 static int noise;
33 static int carry;
34 static int counter;
35 static int seed = 0x12345;
36 static int pixel[SIZE];
37
38 void
39 ptc_cleanup_callback (void)
40 {
41   fprintf (stderr, "Callback!\n");
42 }
43
44 int
45 main ()
46 {
47   if (!ptc_open ("test", WIDTH, HEIGHT))
48     return 1;
49   for (;;)
50     {
51       for (counter = 0; counter < SIZE; counter++)
52         {
53           noise = seed;
54           noise >>= 3;
55           noise ^= seed;
56           carry = noise & 1;
57           noise >>= 1;
58           seed >>= 1;
59           seed |= (carry << 30);
60           noise &= 0xFF;
61           pixel[counter] = (noise << 16) | (noise << 8) | noise;
62         }
63       ptc_update (pixel);
64     }
65   ptc_close ();
66   return 0;
67 }