-
Notifications
You must be signed in to change notification settings - Fork 0
/
2d.c
62 lines (46 loc) · 992 Bytes
/
2d.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
/* 2D Template for OpenGL
Sam Foster
*/
#include<stdio.h>
#include<math.h>
#include<GL/glut.h>
#include<stdlib.h>
int a;
double y, x;
GLdouble width = 640, height = 480;
void display(void)
{
// clear all pixels? */
glClear(GL_COLOR_BUFFER_BIT);
// Draw a point
glBegin(GL_POINTS);
glVertex2f(width / 2, height / 2);
glEnd();
glFlush();
}
void init (void)
{
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_SINGLE | GLUT_RGB);
glutInitWindowSize (width, height);
glutInitWindowPosition (100, 100);
glutCreateWindow ("hello");
init ();
glutDisplayFunc(display);
glutMainLoop();
for (a=1; a<25; a++)
{
x = sin(random());
y = sin(random());
printf("%f, %f\n", x, y);
}
return(0);
}