517d584e21210f16843a7eda252c4f15fe3f0c29
2 * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that (i) the above copyright notices and this permission notice appear in
7 * all copies of the software and related documentation, and (ii) the name of
8 * Silicon Graphics may not be used in any advertising or
9 * publicity relating to the software without the specific, prior written
10 * permission of Silicon Graphics.
12 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
31 #define OPENGL_WIDTH 24
32 #define OPENGL_HEIGHT 13
35 GLenum rgb
, doubleBuffer
, windType
;
52 GLubyte OpenGL_bits1
[] = {
67 GLubyte OpenGL_bits2
[] = {
82 GLubyte logo_bits
[] = {
103 static void Init(void)
106 glClearColor(0.0, 0.0, 0.0, 0.0);
110 static void Reshape(int width
, int height
)
113 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
115 glMatrixMode(GL_PROJECTION
);
117 gluOrtho2D(-175, 175, -175, 175);
118 glMatrixMode(GL_MODELVIEW
);
121 static void Key(unsigned char key
, int x
, int y
)
130 static void Draw(void)
132 float mapI
[2], mapIA
[2], mapIR
[2];
134 glClear(GL_COLOR_BUFFER_BIT
);
143 glPixelMapfv(GL_PIXEL_MAP_I_TO_R
, 2, mapIR
);
144 glPixelMapfv(GL_PIXEL_MAP_I_TO_G
, 2, mapI
);
145 glPixelMapfv(GL_PIXEL_MAP_I_TO_B
, 2, mapI
);
146 glPixelMapfv(GL_PIXEL_MAP_I_TO_A
, 2, mapIA
);
147 glPixelTransferi(GL_MAP_COLOR
, GL_TRUE
);
149 SetColor(COLOR_WHITE
);
150 glRasterPos3fv(boxA
);
151 glPixelStorei(GL_UNPACK_ROW_LENGTH
, 24);
152 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, 8);
153 glPixelStorei(GL_UNPACK_SKIP_ROWS
, 2);
154 glPixelStorei(GL_UNPACK_LSB_FIRST
, GL_FALSE
);
155 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
156 glBitmap(16, 12, 8.0, 0.0, 0.0, 0.0, logo_bits
);
158 glPixelStorei(GL_UNPACK_ROW_LENGTH
, 0);
159 glPixelStorei(GL_UNPACK_SKIP_PIXELS
, 0);
160 glPixelStorei(GL_UNPACK_SKIP_ROWS
, 0);
161 glPixelStorei(GL_UNPACK_LSB_FIRST
, GL_TRUE
);
162 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
164 SetColor(COLOR_WHITE
);
165 glRasterPos3fv(boxB
);
166 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
168 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
171 SetColor(COLOR_YELLOW
);
172 glRasterPos3fv(boxC
);
173 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
175 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
178 SetColor(COLOR_CYAN
);
179 glRasterPos3fv(boxD
);
180 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
182 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
186 glRasterPos3fv(boxE
);
187 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
189 glBitmap(OPENGL_WIDTH
, OPENGL_HEIGHT
, OPENGL_WIDTH
, 0.0, OPENGL_WIDTH
, 0.0,
199 static GLenum
Args(int argc
, char **argv
)
204 doubleBuffer
= GL_FALSE
;
206 for (i
= 1; i
< argc
; i
++) {
207 if (strcmp(argv
[i
], "-ci") == 0) {
209 } else if (strcmp(argv
[i
], "-rgb") == 0) {
211 } else if (strcmp(argv
[i
], "-sb") == 0) {
212 doubleBuffer
= GL_FALSE
;
213 } else if (strcmp(argv
[i
], "-db") == 0) {
214 doubleBuffer
= GL_TRUE
;
216 printf("%s (Bad option).\n", argv
[i
]);
223 int main(int argc
, char **argv
)
225 glutInit(&argc
, argv
);
227 if (Args(argc
, argv
) == GL_FALSE
) {
231 glutInitWindowPosition(0, 0); glutInitWindowSize( 300, 300);
233 windType
= (rgb
) ? GLUT_RGB
: GLUT_INDEX
;
234 windType
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
235 glutInitDisplayMode(windType
);
237 if (glutCreateWindow("Bitmap Test") == GL_FALSE
) {
245 glutReshapeFunc(Reshape
);
246 glutKeyboardFunc(Key
);
247 glutDisplayFunc(Draw
);