-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglshell_SHELL.c
More file actions
113 lines (112 loc) · 2.15 KB
/
glshell_SHELL.c
File metadata and controls
113 lines (112 loc) · 2.15 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Torbert, 26 November 2013
//
#include <stdio.h>
#include <GL/glut.h>
//
#define M 800
#define N 600
//
int count = 0 ;
int ascii = 48 ;
//
void idlefunc(void)
{
++count ;
//
if( count == 1000000 )
{
count = 0 ;
//
++ascii ;
//
if( ascii == 58 ) ascii = 65 ;
if( ascii == 91 ) ascii = 97 ;
if( ascii == 123 ) ascii = 48 ;
//
glutPostRedisplay() ;
}
}
//
void displayfunc(void)
{
int xp , yp ;
//
glClear(GL_COLOR_BUFFER_BIT);
//
for( xp = 100 ; xp < M ; xp++ )
{
for( yp = 100 ; yp < N ; yp++ )
{
glColor3f( 0.6 , 0.3 , 0.0 ) ; // brown
//
glBegin(GL_POINTS);
glVertex2f(xp,yp);
glEnd();
}
}
//
glutSwapBuffers() ;
}
void mousefunc(int button,int state,int xscr,int yscr)
{
if(button==GLUT_LEFT_BUTTON && state==GLUT_DOWN)
{
printf("Left mouse clicked.\n");
}
else if(button==GLUT_RIGHT_BUTTON && state==GLUT_DOWN)
{
printf("Right mouse clicked.\n");
}
}
void motionfunc(int xscr,int yscr)
{
printf("Motion ( %d , %d ).\n" , xscr , yscr ) ;
}
void keyfunc(unsigned char key,int xscr,int yscr)
{
printf("Key %c pressed.\n" , key);
}
void specialfunc(int key,int xscr,int yscr)
{
if( key == GLUT_KEY_UP )
{
printf("Up arrow pressed.\n");
}
}
void closefunc(void)
{
printf("Window closed.\n");
}
int main(int argc,char* argv[])
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(M,N);
glutInitWindowPosition(100,50);
glutCreateWindow("");
glClearColor(1.0,1.0,1.0,0.0);
glShadeModel(GL_SMOOTH);
//
glViewport(0,0,(GLsizei)M,(GLsizei)N); // reshape
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,1.0*M,1.0*N,0.0); // invert y-coords
glMatrixMode(GL_MODELVIEW);
//
glutIdleFunc(idlefunc);
glutDisplayFunc(displayfunc);
glutReshapeFunc(NULL);
glutMouseFunc(mousefunc);
glutMotionFunc(motionfunc);
glutKeyboardFunc(keyfunc);
glutSpecialFunc(specialfunc);
glutWMCloseFunc(closefunc);
//
glutMainLoop();
//
return 0;
}
//
// end of file
//