-
Notifications
You must be signed in to change notification settings - Fork 0
/
scratchy.c
82 lines (65 loc) · 1.66 KB
/
scratchy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* Mac OS X use:
* gcc -framework OpenGL -framework GLUT
* Linux use:
* gcc -lglut
* -cmang
*/
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include <time.h>
#include <unistd.h>
#ifdef __APPLE__
#include<GLUT/glut.h>
#else
#include<GL/glut.h>
#endif
#define WIDTH 640
#define HEIGHT 480
int x, y;
double duh, der, extra;
GLdouble width = WIDTH, height = HEIGHT;
double imagemap[WIDTH][HEIGHT];
void display(void)
{
// clear all pixels? */
glClear(GL_COLOR_BUFFER_BIT);
// Draw by points
glBegin(GL_POINTS);
for (x = 0; x < width; x++)
for (y = 0; y < height; y++)
{
extra = extra + 0.00001;
duh = (640.0 + (640.0 * sin(x / 8.0))+ 244.0 + (640.0 * sin(y / 2.0))) / 4002 * sin(extra);
der = (128.0 + (64.0 * sin(sqrt((x - width / 8.0) * (x - width / 8.0) + (y - height / 8.0) * (y - height / 8.0)) / 8.0)))/200; // * sin(extra);
duh = duh + der;
imagemap[(int)x][(int)y] = duh;
glColor3f(imagemap[x][y], imagemap[x][x], imagemap[y][y]);
glVertex2f(x,y);
if (extra > 3.0) extra = 0.00001;
}
glEnd();
glutSwapBuffers();
}
void init (void)
{
extra = 0.00001;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, height, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glDisable(GL_DEPTH_TEST);
}
int main(int argc, char* argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize (width, height);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
glutIdleFunc(display);
init ();
glutDisplayFunc(display);
glutMainLoop();
return(0);
}