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
| #include <glut.h>
#include <gl.h>
#include <math.h>
#define xmax 10.0
#define xmin -10.0
#define ymax 10.0
#define ymin -10.0
#define w 500.0
#define h 500.0
void display(void)
{
GLubyte N[256];
GLubyte SN[256]= {0x0f, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x0f, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x0f, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x0f, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xff,0xff,0xff,
0x00, 0xf0,0x00,0x0f, 0x00,0xff,0xff,0xff,
0x00, 0xf0,0x00,0x0f, 0x00,0xff,0xff,0xff,
0x00, 0xf0,0x00,0x0f, 0x00,0xff,0xff,0xff,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xf0,0x00,0x0f, 0x00,0xf0,0x00,0x0f,
0x00, 0xff,0xff,0xff, 0x00,0xf0,0x00,0x0f,
0x00, 0xff,0xff,0xff, 0x00,0xff,0xff,0xff,
0x00, 0xff,0xff,0xff, 0x00,0xff,0xff,0xff,
0x00, 0xff,0xff,0xff, 0x00,0xff,0xff,0xff,
0x00, 0xff,0xff,0xff, 0x00,0xff,0xff,0xff};
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(0.0, 255.0, 0.0, 255.0);
glRasterPos2f(0.0f, 0.0f);
glBitmap(64, 32, 0, 0, 0, 0, SN);
glRasterPos2f(2.0f, 2.0f);
glDrawBuffer(GL_LEFT);
glReadBuffer(GL_LEFT);
glCopyPixels(0, 0, 32, 32, GL_COLOR);
glPixelZoom(2.0, 2.0);
glReadPixels(0, 0, 64, 32, GL_RGBA, GL_UNSIGNED_BYTE, *N);
glRasterPos2f(3.0f, 3.0f);
glDrawPixels(64, 32, GL_RGBA, GL_UNSIGNED_BYTE, N);
glFlush();
}
void setWindowMir(float left, float right, float bottom, float top)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left, right, bottom, top);
}
void setViewEkr(int left, int right, int bottom, int top)
{
glViewport(left, bottom, right - left, top - bottom);
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0, 0.0, 0.0);
glPointSize(2.0);
}
void myReshape(GLsizei W, GLsizei H)
{
float R = (xmax-xmin)/(ymax-ymin);
if(R > W/H)
setViewEkr(0, W, 0, W/R);
else
setViewEkr(0, H*R, 0, H);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(w, h);
glutInitWindowPosition(100, 150);
glutCreateWindow("Graphic Constructor");
setWindowMir(xmin, xmax, ymin, ymax);
setViewEkr(0, 0, w, h);
glutDisplayFunc(display);
glutReshapeFunc(myReshape);
glutMainLoop();
return 0;
} |