2 * Copyright © 2008 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
30 #include "glut_wrap.h"
32 static int win_width
, win_height
;
35 line(GLfloat x1
, GLfloat y1
, GLfloat x2
, GLfloat y2
)
44 line3(GLfloat x1
, GLfloat y1
, GLfloat z1
, GLfloat x2
, GLfloat y2
, GLfloat z2
)
47 glVertex3f(x1
, y1
, z1
);
48 glVertex3f(x2
, y2
, z2
);
55 glClearColor(0.0, 0.0, 0.0, 0.0);
56 glClear(GL_COLOR_BUFFER_BIT
);
58 glColor3f(1.0, 0.0, 0.0);
59 /* 2 lines clipped along xmin */
60 line(-20, win_height
/ 2 - 20,
61 20, win_height
/ 2 - 20);
62 line( 20, win_height
/ 2 + 20,
63 -20, win_height
/ 2 + 20);
65 glColor3f(0.0, 1.0, 0.0);
66 /* 2 lines clipped along ymax */
67 line(win_width
/ 2 - 20, win_height
+ 20,
68 win_width
/ 2 - 20, win_height
- 20);
69 line(win_width
/ 2 + 20, win_height
- 20,
70 win_width
/ 2 + 20, win_height
+ 20);
72 glColor3f(0.0, 0.0, 1.0);
73 /* 2 lines clipped along xmax */
74 line(win_width
- 20, win_height
/ 2 - 20,
75 win_width
+ 20, win_height
/ 2 - 20);
76 line(win_width
+ 20, win_height
/ 2 + 20,
77 win_width
- 20, win_height
/ 2 + 20);
79 glColor3f(1.0, 1.0, 1.0);
80 /* 2 lines clipped along ymin */
81 line(win_width
/ 2 - 20, 20,
82 win_width
/ 2 - 20, -20);
83 line(win_width
/ 2 + 20, -20,
84 win_width
/ 2 + 20, 20);
86 /* 2 lines clipped along near */
87 glColor3f(1.0, 0.0, 1.0);
88 line3(win_width
/ 2 - 20 - 20, win_height
/ 2, 0.5,
89 win_width
/ 2 - 20 + 20, win_height
/ 2, -0.5);
90 line3(win_width
/ 2 - 20, win_height
/ 2 - 20, -0.5,
91 win_width
/ 2 - 20, win_height
/ 2 + 20, 0.5);
93 /* 2 lines clipped along far */
94 glColor3f(0.0, 1.0, 1.0);
95 line3(win_width
/ 2 + 20 - 20, win_height
/ 2, 1.5,
96 win_width
/ 2 + 20 + 20, win_height
/ 2, 0.5);
97 line3(win_width
/ 2 + 20, win_height
/ 2 - 20, 0.5,
98 win_width
/ 2 + 20, win_height
/ 2 + 20, 1.5);
100 /* entirely clipped along near/far */
101 glColor3f(.5, .5, .5);
102 line3(win_width
/ 2, win_height
/ 2 - 20, -0.5,
103 win_width
/ 2, win_height
/ 2 + 20, -0.5);
104 glColor3f(.5, .5, .5);
105 line3(win_width
/ 2, win_height
/ 2 - 20, 1.5,
106 win_width
/ 2, win_height
/ 2 + 20, 1.5);
108 glColor3f(1.0, 1.0, 0.0);
109 /* lines clipped along both x and y limits */
111 20, -5); /* xmin, ymin */
112 line(-5, win_height
- 20,
113 20, win_height
+ 5); /* xmin, ymax */
114 line(win_width
- 20, -5,
115 win_width
+ 5, 20); /* xmax, ymin */
116 line(win_width
- 20, win_height
+ 5,
117 win_width
+ 5, win_height
- 20); /* xmax, ymax */
123 reshape(int width
, int height
)
127 glViewport(0, 0, width
, height
);
129 glMatrixMode(GL_PROJECTION
);
131 glOrtho(0, win_width
, 0, win_height
, 0.0, -1.0);
133 glMatrixMode(GL_MODELVIEW
);
135 glTranslatef(.25, .25, 0);
138 static void key( unsigned char key
, int x
, int y
)
158 main(int argc
, char *argv
[])
163 glutInit(&argc
, argv
);
164 glutInitWindowPosition(0, 0);
165 glutInitWindowSize(win_width
, win_height
);
166 glutInitDisplayMode(GLUT_RGB
| GLUT_DOUBLE
| GLUT_DEPTH
);
167 glutCreateWindow(argv
[0]);
169 glutReshapeFunc(reshape
);
170 glutKeyboardFunc(key
);
171 glutDisplayFunc(display
);