2 /* Copyright (c) Mark J. Kilgard, 1994. */
5 * (c) Copyright 1993, Silicon Graphics, Inc.
7 * Permission to use, copy, modify, and distribute this software for
8 * any purpose and without fee is hereby granted, provided that the above
9 * copyright notice appear in all copies and that both the copyright notice
10 * and this permission notice appear in supporting documentation, and that
11 * the name of Silicon Graphics, Inc. not be used in advertising
12 * or publicity pertaining to distribution of the software without specific,
13 * written prior permission.
15 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
16 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
18 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
20 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
21 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
22 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
23 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
24 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
25 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
26 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
28 * US Government Users Restricted Rights
29 * Use, duplication, or disclosure by the Government is subject to
30 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
31 * (c)(1)(ii) of the Rights in Technical Data and Computer Software
32 * clause at DFARS 252.227-7013 and/or in similar or successor
33 * clauses in the FAR or the DOD or NASA FAR Supplement.
34 * Unpublished-- rights reserved under the copyright laws of the
35 * United States. Contractor/manufacturer is Silicon Graphics,
36 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
38 * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
42 * Demonstrates texture environment modes and internal image formats.
46 * Hacked on, updated by Gareth Hughes <gareth@valinux.com>
56 #define max( a, b ) ((a) >= (b) ? (a) : (b))
57 #define min( a, b ) ((a) <= (b) ? (a) : (b))
59 GLfloat lightCheck
[4] = { 0.7, 0.7, 0.7, 1.0 };
60 GLfloat darkCheck
[4] = { 0.3, 0.3, 0.3, 1.0 };
62 GLfloat labelColor0
[4] = { 1.0, 1.0, 1.0, 1.0 };
63 GLfloat labelColor1
[4] = { 1.0, 1.0, 0.4, 1.0 };
64 GLfloat
*labelInfoColor
= labelColor0
;
65 GLfloat labelLevelColor0
[4] = { 0.8, 0.8, 0.1, 1.0 };
66 GLfloat labelLevelColor1
[4] = { 0.0, 0.0, 0.0, 1.0 };
68 GLboolean doubleBuffered
= GL_TRUE
;
69 GLboolean drawBackground
= GL_FALSE
;
70 GLboolean drawBlended
= GL_TRUE
;
71 GLboolean drawSmooth
= GL_FALSE
;
72 GLboolean drawTextured
= GL_TRUE
;
73 GLboolean displayLevelInfo
= GL_FALSE
;
75 int textureWidth
= 64;
76 int textureHeight
= 64;
78 int winWidth
= 580, winHeight
= 720;
82 GLenum internalFormat
;
86 #define NUM_LUMINANCE_FORMATS (sizeof(luminanceFormats) / sizeof(luminanceFormats[0]))
87 struct formatInfo luminanceFormats
[] =
89 { GL_LUMINANCE
, GL_LUMINANCE
, "LUMINANCE" },
90 { GL_LUMINANCE
, GL_LUMINANCE4
, "LUMINANCE4" },
91 { GL_LUMINANCE
, GL_LUMINANCE8
, "LUMINANCE8" },
92 { GL_LUMINANCE
, GL_LUMINANCE12
, "LUMINANCE12" },
93 { GL_LUMINANCE
, GL_LUMINANCE16
, "LUMINANCE16" },
96 #define NUM_ALPHA_FORMATS (sizeof(alphaFormats) / sizeof(alphaFormats[0]))
97 struct formatInfo alphaFormats
[] =
99 { GL_ALPHA
, GL_ALPHA
, "ALPHA" },
100 { GL_ALPHA
, GL_ALPHA4
, "ALPHA4" },
101 { GL_ALPHA
, GL_ALPHA8
, "ALPHA8" },
102 { GL_ALPHA
, GL_ALPHA12
, "ALPHA12" },
103 { GL_ALPHA
, GL_ALPHA16
, "ALPHA16" },
106 #define NUM_INTENSITY_FORMATS (sizeof(intensityFormats) / sizeof(intensityFormats[0]))
107 struct formatInfo intensityFormats
[] =
109 { GL_INTENSITY
, GL_INTENSITY
, "INTENSITY" },
110 { GL_INTENSITY
, GL_INTENSITY4
, "INTENSITY4" },
111 { GL_INTENSITY
, GL_INTENSITY8
, "INTENSITY8" },
112 { GL_INTENSITY
, GL_INTENSITY12
, "INTENSITY12" },
113 { GL_INTENSITY
, GL_INTENSITY16
, "INTENSITY16" },
116 #define NUM_LUMINANCE_ALPHA_FORMATS (sizeof(luminanceAlphaFormats) / sizeof(luminanceAlphaFormats[0]))
117 struct formatInfo luminanceAlphaFormats
[] =
119 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE_ALPHA
, "LUMINANCE_ALPHA" },
120 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE4_ALPHA4
, "LUMINANCE4_ALPHA4" },
121 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE6_ALPHA2
, "LUMINANCE6_ALPHA2" },
122 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE8_ALPHA8
, "LUMINANCE8_ALPHA8" },
123 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE12_ALPHA4
, "LUMINANCE12_ALPHA4" },
124 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE12_ALPHA12
, "LUMINANCE12_ALPHA12" },
125 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE16_ALPHA16
, "LUMINANCE16_ALPHA16" },
128 #define NUM_RGB_FORMATS (sizeof(rgbFormats) / sizeof(rgbFormats[0]))
129 struct formatInfo rgbFormats
[] =
131 { GL_RGB
, GL_RGB
, "RGB" },
132 { GL_RGB
, GL_R3_G3_B2
, "R3_G3_B2" },
133 { GL_RGB
, GL_RGB4
, "RGB4" },
134 { GL_RGB
, GL_RGB5
, "RGB5" },
135 { GL_RGB
, GL_RGB8
, "RGB8" },
136 { GL_RGB
, GL_RGB10
, "RGB10" },
137 { GL_RGB
, GL_RGB12
, "RGB12" },
138 { GL_RGB
, GL_RGB16
, "RGB16" },
141 #define NUM_RGBA_FORMATS (sizeof(rgbaFormats) / sizeof(rgbaFormats[0]))
142 struct formatInfo rgbaFormats
[] =
144 { GL_RGBA
, GL_RGBA
, "RGBA" },
145 { GL_RGBA
, GL_RGBA2
, "RGBA2" },
146 { GL_RGBA
, GL_RGBA4
, "RGBA4" },
147 { GL_RGBA
, GL_RGB5_A1
, "RGB5_A1" },
148 { GL_RGBA
, GL_RGBA8
, "RGBA8" },
149 { GL_RGBA
, GL_RGB10_A2
, "RGB10_A2" },
150 { GL_RGBA
, GL_RGBA12
, "RGBA12" },
151 { GL_RGBA
, GL_RGBA16
, "RGBA16" },
154 struct baseFormatInfo
{
155 struct formatInfo
*format
;
159 #define NUM_BASE_FORMATS (sizeof(baseFormats) / sizeof(baseFormats[0]))
161 struct baseFormatInfo baseFormats
[] =
163 { luminanceFormats
, 0, NUM_LUMINANCE_FORMATS
},
164 { alphaFormats
, 0, NUM_ALPHA_FORMATS
},
165 { intensityFormats
, 0, NUM_INTENSITY_FORMATS
},
166 { luminanceAlphaFormats
, 0, NUM_LUMINANCE_ALPHA_FORMATS
},
167 { rgbFormats
, 0, NUM_RGB_FORMATS
},
168 { rgbaFormats
, 0, NUM_RGBA_FORMATS
},
171 #define NUM_ENV_COLORS (sizeof(envColors) / sizeof(envColors[0]))
173 GLfloat envColors
[][4] =
175 { 0.0, 0.0, 0.0, 1.0 },
176 { 1.0, 0.0, 0.0, 1.0 },
177 { 0.0, 1.0, 0.0, 1.0 },
178 { 0.0, 0.0, 1.0, 1.0 },
179 { 1.0, 1.0, 1.0, 1.0 },
187 /* allow for run-time check for GL_EXT_texture_env_add */
188 int NUM_ENV_MODES
= 5;
189 struct envModeInfo envModes
[] =
191 { GL_REPLACE
, "REPLACE" },
192 { GL_MODULATE
, "MODULATE" },
193 { GL_BLEND
, "BLEND" },
194 { GL_DECAL
, "DECAL" },
195 #if GL_EXT_texture_env_add
200 static void checkErrors( void )
204 while ( (error
= glGetError()) != GL_NO_ERROR
) {
205 fprintf( stderr
, "Error: %s\n", (char *) gluErrorString( error
) );
209 static void drawString( const char *string
, GLfloat x
, GLfloat y
,
210 const GLfloat color
[4] )
213 glRasterPos2f( x
, y
);
216 glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10
, *string
);
221 static void drawStringOutline( const char *string
, GLfloat x
, GLfloat y
,
222 const GLfloat color
[4],
223 const GLfloat outline
[4] )
225 drawString( string
, x
- 1, y
, outline
);
226 drawString( string
, x
+ 1, y
, outline
);
227 drawString( string
, x
, y
- 1, outline
);
228 drawString( string
, x
, y
+ 1, outline
);
229 drawString( string
, x
, y
, color
);
232 static void begin2D( int width
, int height
)
234 glMatrixMode( GL_PROJECTION
);
239 glOrtho( 0, width
, 0, height
, -1, 1 );
240 glMatrixMode( GL_MODELVIEW
);
246 static void end2D( void )
248 glMatrixMode( GL_PROJECTION
);
250 glMatrixMode( GL_MODELVIEW
);
254 static void initialize( void )
256 glMatrixMode( GL_PROJECTION
);
259 glOrtho( -1.5, 1.5, -1.5, 1.5, -1.5, 1.5 );
261 glMatrixMode(GL_MODELVIEW
);
264 glShadeModel( GL_FLAT
);
268 static void keyboard( unsigned char c
, int x
, int y
)
273 envColor
= envColor
% (int) NUM_ENV_COLORS
;
276 drawBackground
= !drawBackground
;
279 drawBlended
= !drawBlended
;
282 drawSmooth
= !drawSmooth
;
285 drawTextured
= !drawTextured
;
288 displayLevelInfo
= !displayLevelInfo
;
290 case 27: /* Escape key should force exit. */
300 static void special( int key
, int x
, int y
)
304 if ( ++baseFormat
> NUM_BASE_FORMATS
- 1 ) {
309 if ( --baseFormat
< 0 ) {
310 baseFormat
= NUM_BASE_FORMATS
- 1;
314 --baseFormats
[baseFormat
].current
;
315 if ( baseFormats
[baseFormat
].current
< 0 ) {
316 baseFormats
[baseFormat
].current
= baseFormats
[baseFormat
].number
- 1;
320 ++baseFormats
[baseFormat
].current
;
321 if ( baseFormats
[baseFormat
].current
> baseFormats
[baseFormat
].number
- 1 ) {
322 baseFormats
[baseFormat
].current
= 0;
332 reshape( int w
, int h
)
336 /* No need to call glViewPort here since "draw" calls it! */
339 static void loadTexture( int width
, int height
,
340 const struct formatInfo
*format
)
342 int luminanceSize
= 0;
345 GLenum textureFormat
;
346 GLubyte
*texImage
, *p
;
347 int elementsPerGroup
, elementSize
, groupSize
, rowSize
;
350 switch ( format
->baseFormat
) {
353 textureFormat
= GL_LUMINANCE
;
357 textureFormat
= GL_INTENSITY
;
361 textureFormat
= GL_ALPHA
;
363 case GL_LUMINANCE_ALPHA
:
366 textureFormat
= GL_LUMINANCE_ALPHA
;
370 textureFormat
= GL_RGB
;
375 textureFormat
= GL_RGBA
;
378 fprintf(stderr
, "bad internal format info\n");
382 elementsPerGroup
= luminanceSize
+ alphaSize
+ rgbSize
;
383 elementSize
= sizeof(GLubyte
);
384 groupSize
= elementsPerGroup
* elementSize
;
385 rowSize
= width
* groupSize
;
387 if ( (texImage
= (GLubyte
*) malloc( height
* rowSize
) ) == NULL
) {
388 fprintf( stderr
, "texture malloc failed\n" );
392 for ( i
= 0 ; i
< height
; i
++ )
394 p
= texImage
+ i
* rowSize
;
396 for ( j
= 0 ; j
< width
; j
++ )
398 if ( luminanceSize
> 0 )
411 if ( i
> height
/ 2 ) {
412 if ( j
< width
/ 2 ) {
418 if ( j
< width
/ 2 ) {
440 if ( i
> height
/ 2 ) {
441 if ( j
< width
/ 2 ) {
451 if ( j
< width
/ 2 ) {
461 p
+= 3 * elementSize
;
477 int i2
= i
- height
/ 2;
478 int j2
= j
- width
/ 2;
481 if ( -h8
<= i2
&& i2
<= h8
&& -w8
<= j2
&& j2
<= w8
) {
483 } else if ( -2 * h8
<= i2
&& i2
<= 2 * h8
&& -2 * w8
<= j2
&& j2
<= 2 * w8
) {
485 } else if ( -3 * h8
<= i2
&& i2
<= 3 * h8
&& -3 * w8
<= j2
&& j2
<= 3 * w8
) {
495 glTexImage2D( GL_TEXTURE_2D
, 0,
496 format
->internalFormat
, width
, height
, 0,
497 textureFormat
, GL_UNSIGNED_BYTE
, texImage
);
502 static void drawCheck( int w
, int h
, const GLfloat lightCheck
[4],
503 const GLfloat darkCheck
[4] )
509 for ( i
= 0 ; i
< w
; i
++ ) {
510 GLfloat x0
= -1.0 + i
* dw
;
511 GLfloat x1
= x0
+ dw
;
513 glBegin( GL_QUAD_STRIP
);
515 for ( j
= 0 ; j
<= h
; j
++ ) {
516 GLfloat y
= -1.0 + j
* dh
;
519 glColor4fv( lightCheck
);
521 glColor4fv( darkCheck
);
532 static const char *lookupFormat( GLint format
)
542 return "GL_LUMINANCE";
543 case GL_LUMINANCE_ALPHA
:
544 return "GL_LUMINANCE_ALPHA";
546 return "GL_INTENSITY";
548 return "GL_COLOR_INDEX";
554 return "unknown format";
558 static void drawSample( int x
, int y
, int w
, int h
,
559 const struct formatInfo
*format
,
560 const struct envModeInfo
*envMode
)
562 glViewport( x
, y
, w
, h
);
563 glScissor( x
, y
, w
, h
);
565 glClearColor( 0.1, 0.1, 0.1, 1.0 );
566 glClear( GL_COLOR_BUFFER_BIT
);
569 drawString( format
->name
, 10, h
- 15, labelInfoColor
);
570 drawString( envMode
->name
, 10, 5, labelInfoColor
);
573 glTexEnvi( GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, envMode
->mode
);
574 glTexEnvfv( GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, envColors
[envColor
] );
576 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
577 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
579 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP
);
580 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP
);
582 loadTexture( textureWidth
, textureHeight
, format
);
584 if ( drawBackground
) {
585 drawCheck( 15, 15, lightCheck
, darkCheck
);
588 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
589 glEnable( GL_BLEND
);
592 glShadeModel( GL_SMOOTH
);
595 glShadeModel( GL_FLAT
);
596 glColor4f(1, 1, 1, 1);
598 if ( drawTextured
) {
599 glEnable( GL_TEXTURE_2D
);
603 * if (drawSmooth) then draw quad which goes from purple at the
604 * bottom (100% alpha) to green at the top (50% alpha).
607 if ( drawSmooth
) glColor4f( 1.0, 0.0, 1.0, 1.0 );
608 glTexCoord2f( 0.0, 0.0 );
609 glVertex2f( -0.8, -0.8 );
611 if ( drawSmooth
) glColor4f( 1.0, 0.0, 1.0, 1.0 );
612 glTexCoord2f( 1.0, 0.0 );
613 glVertex2f( 0.8, -0.8 );
615 if ( drawSmooth
) glColor4f( 0.0, 1.0, 0.0, 0.5 );
616 glTexCoord2f( 1.0, 1.0 );
617 glVertex2f( 0.8, 0.8 );
619 if ( drawSmooth
) glColor4f( 0.0, 1.0, 0.0, 0.5 );
620 glTexCoord2f( 0.0, 1.0 );
621 glVertex2f( -0.8, 0.8 );
624 glDisable( GL_BLEND
);
625 glShadeModel( GL_FLAT
);
626 glDisable( GL_TEXTURE_2D
);
628 if ( envMode
->mode
== GL_DECAL
&&
629 (format
->baseFormat
== GL_ALPHA
||
630 format
->baseFormat
== GL_LUMINANCE
||
631 format
->baseFormat
== GL_LUMINANCE_ALPHA
||
632 format
->baseFormat
== GL_INTENSITY
)) {
633 /* undefined format/mode combination */
635 drawStringOutline( "UNDEFINED MODE", 15, h
/ 2,
636 labelLevelColor0
, labelLevelColor1
);
639 else if ( displayLevelInfo
) {
640 GLint width
, height
, border
, format
;
641 GLint redSize
, greenSize
, blueSize
, alphaSize
;
642 GLint luminanceSize
, intensitySize
;
645 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_WIDTH
, &width
);
646 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_HEIGHT
, &height
);
647 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_BORDER
, &border
);
648 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_INTERNAL_FORMAT
, &format
);
649 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &redSize
);
650 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_GREEN_SIZE
, &greenSize
);
651 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_BLUE_SIZE
, &blueSize
);
652 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_ALPHA_SIZE
, &alphaSize
);
653 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_LUMINANCE_SIZE
, &luminanceSize
);
654 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_INTENSITY_SIZE
, &intensitySize
);
657 sprintf( buf
, "dimensions: %d x %d", width
, height
);
658 drawStringOutline( buf
, 15, h
/ 2 + 20, labelLevelColor0
, labelLevelColor1
);
660 sprintf( buf
, "border: %d", border
);
661 drawStringOutline( buf
, 15, h
/ 2 + 10, labelLevelColor0
, labelLevelColor1
);
663 sprintf( buf
, "internal format:" );
664 drawStringOutline( buf
, 15, h
/ 2, labelLevelColor0
, labelLevelColor1
);
666 sprintf( buf
, " %s", lookupFormat( format
) );
667 drawStringOutline( buf
, 15, h
/ 2 - 10, labelLevelColor0
, labelLevelColor1
);
669 sprintf( buf
, "sizes:" );
670 drawStringOutline( buf
, 15, h
/ 2 - 20, labelLevelColor0
, labelLevelColor1
);
672 sprintf( buf
, " %d / %d / %d / %d / %d / %d",
673 redSize
, greenSize
, blueSize
, alphaSize
,
674 luminanceSize
, intensitySize
);
675 drawStringOutline( buf
, 15, h
/ 2 - 30, labelLevelColor0
, labelLevelColor1
);
681 static void display( void )
683 int numX
= NUM_ENV_MODES
, numY
= NUM_BASE_FORMATS
;
684 float xBase
= (float) winWidth
* 0.01;
685 float xOffset
= (winWidth
- xBase
) / numX
;
686 float xSize
= max( xOffset
- xBase
, 1 );
687 float yBase
= (float) winHeight
* 0.01;
688 float yOffset
= (winHeight
- yBase
) / numY
;
689 float ySize
= max( yOffset
- yBase
, 1 );
693 glViewport( 0, 0, winWidth
, winHeight
);
694 glDisable( GL_SCISSOR_TEST
);
695 glClearColor( 0.0, 0.0, 0.0, 0.0 );
696 glClear( GL_COLOR_BUFFER_BIT
);
697 glEnable( GL_SCISSOR_TEST
);
700 y
= (winHeight
- 1) - yOffset
;
702 for ( i
= 0 ; i
< NUM_BASE_FORMATS
; i
++ )
704 struct formatInfo
*format
;
706 if ( i
== baseFormat
) {
707 labelInfoColor
= labelColor1
;
709 labelInfoColor
= labelColor0
;
712 format
= &baseFormats
[i
].format
[baseFormats
[i
].current
];
714 for ( j
= 0 ; j
< NUM_ENV_MODES
; j
++ ) {
715 struct envModeInfo
*envMode
;
717 envMode
= &envModes
[j
];
718 drawSample( x
, y
, xSize
, ySize
, format
, envMode
);
726 if ( doubleBuffered
) {
735 static void usage( char *name
)
737 fprintf( stderr
, "usage: %s [ options ]\n", name
);
738 fprintf( stderr
, "\n" );
739 fprintf( stderr
, "options:\n" );
740 fprintf( stderr
, " -sb single buffered\n" );
741 fprintf( stderr
, " -db double buffered\n" );
742 fprintf( stderr
, " -info print OpenGL driver info\n" );
745 static void instructions( void )
747 fprintf( stderr
, "texenv - texture environment and internal format test\n" );
748 fprintf( stderr
, "\n" );
749 fprintf( stderr
, " [c] - cycle through background colors\n" );
750 fprintf( stderr
, " [g] - toggle background\n" );
751 fprintf( stderr
, " [b] - toggle blend\n" );
752 fprintf( stderr
, " [s] - toggle smooth shading\n" );
753 fprintf( stderr
, " [t] - toggle texturing\n" );
754 fprintf( stderr
, " [i] - toggle information display\n" );
755 fprintf( stderr
, " up/down - select row\n" );
756 fprintf( stderr
, " left/right - change row's internal format\n" );
759 int main( int argc
, char *argv
[] )
761 GLboolean info
= GL_FALSE
;
764 glutInit( &argc
, argv
);
766 for ( i
= 1 ; i
< argc
; i
++ ) {
767 if ( !strcmp( "-sb", argv
[i
] ) ) {
768 doubleBuffered
= GL_FALSE
;
769 } else if ( !strcmp( "-db", argv
[i
] ) ) {
770 doubleBuffered
= GL_TRUE
;
771 } else if ( !strcmp( "-info", argv
[i
] ) ) {
779 if ( doubleBuffered
) {
780 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
782 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
);
785 glutInitWindowSize( winWidth
, winHeight
);
786 glutInitWindowPosition( 0, 0 );
787 glutCreateWindow( "Texture Environment Test" );
794 printf( "GL_RENDERER = %s\n", (char *) glGetString( GL_RENDERER
) );
795 printf( "GL_VERSION = %s\n", (char *) glGetString( GL_VERSION
) );
796 printf( "GL_VENDOR = %s\n", (char *) glGetString( GL_VENDOR
) ) ;
797 printf( "GL_EXTENSIONS = %s\n", (char *) glGetString( GL_EXTENSIONS
) );
800 #if GL_EXT_texture_env_add
801 if ( !glutExtensionSupported( "GL_EXT_texture_env_add" ) ) {
802 fprintf( stderr
, "missing extension: GL_EXT_texture_env_add\n" );
807 glutDisplayFunc( display
);
808 glutReshapeFunc( reshape
);
809 glutKeyboardFunc( keyboard
);
810 glutSpecialFunc( special
);