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;
84 GLenum internalFormat
;
88 #define NUM_LUMINANCE_FORMATS (sizeof(luminanceFormats) / sizeof(luminanceFormats[0]))
89 struct formatInfo luminanceFormats
[] =
91 { GL_LUMINANCE
, GL_LUMINANCE
, "LUMINANCE" },
92 { GL_LUMINANCE
, GL_LUMINANCE4
, "LUMINANCE4" },
93 { GL_LUMINANCE
, GL_LUMINANCE8
, "LUMINANCE8" },
94 { GL_LUMINANCE
, GL_LUMINANCE12
, "LUMINANCE12" },
95 { GL_LUMINANCE
, GL_LUMINANCE16
, "LUMINANCE16" },
98 #define NUM_ALPHA_FORMATS (sizeof(alphaFormats) / sizeof(alphaFormats[0]))
99 struct formatInfo alphaFormats
[] =
101 { GL_ALPHA
, GL_ALPHA
, "ALPHA" },
102 { GL_ALPHA
, GL_ALPHA4
, "ALPHA4" },
103 { GL_ALPHA
, GL_ALPHA8
, "ALPHA8" },
104 { GL_ALPHA
, GL_ALPHA12
, "ALPHA12" },
105 { GL_ALPHA
, GL_ALPHA16
, "ALPHA16" },
108 #define NUM_INTENSITY_FORMATS (sizeof(intensityFormats) / sizeof(intensityFormats[0]))
109 struct formatInfo intensityFormats
[] =
111 { GL_INTENSITY
, GL_INTENSITY
, "INTENSITY" },
112 { GL_INTENSITY
, GL_INTENSITY4
, "INTENSITY4" },
113 { GL_INTENSITY
, GL_INTENSITY8
, "INTENSITY8" },
114 { GL_INTENSITY
, GL_INTENSITY12
, "INTENSITY12" },
115 { GL_INTENSITY
, GL_INTENSITY16
, "INTENSITY16" },
118 #define NUM_LUMINANCE_ALPHA_FORMATS (sizeof(luminanceAlphaFormats) / sizeof(luminanceAlphaFormats[0]))
119 struct formatInfo luminanceAlphaFormats
[] =
121 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE_ALPHA
, "LUMINANCE_ALPHA" },
122 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE4_ALPHA4
, "LUMINANCE4_ALPHA4" },
123 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE6_ALPHA2
, "LUMINANCE6_ALPHA2" },
124 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE8_ALPHA8
, "LUMINANCE8_ALPHA8" },
125 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE12_ALPHA4
, "LUMINANCE12_ALPHA4" },
126 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE12_ALPHA12
, "LUMINANCE12_ALPHA12" },
127 { GL_LUMINANCE_ALPHA
, GL_LUMINANCE16_ALPHA16
, "LUMINANCE16_ALPHA16" },
130 #define NUM_RGB_FORMATS (sizeof(rgbFormats) / sizeof(rgbFormats[0]))
131 struct formatInfo rgbFormats
[] =
133 { GL_RGB
, GL_RGB
, "RGB" },
134 { GL_RGB
, GL_R3_G3_B2
, "R3_G3_B2" },
135 { GL_RGB
, GL_RGB4
, "RGB4" },
136 { GL_RGB
, GL_RGB5
, "RGB5" },
137 { GL_RGB
, GL_RGB8
, "RGB8" },
138 { GL_RGB
, GL_RGB10
, "RGB10" },
139 { GL_RGB
, GL_RGB12
, "RGB12" },
140 { GL_RGB
, GL_RGB16
, "RGB16" },
143 #define NUM_RGBA_FORMATS (sizeof(rgbaFormats) / sizeof(rgbaFormats[0]))
144 struct formatInfo rgbaFormats
[] =
146 { GL_RGBA
, GL_RGBA
, "RGBA" },
147 { GL_RGBA
, GL_RGBA2
, "RGBA2" },
148 { GL_RGBA
, GL_RGBA4
, "RGBA4" },
149 { GL_RGBA
, GL_RGB5_A1
, "RGB5_A1" },
150 { GL_RGBA
, GL_RGBA8
, "RGBA8" },
151 { GL_RGBA
, GL_RGB10_A2
, "RGB10_A2" },
152 { GL_RGBA
, GL_RGBA12
, "RGBA12" },
153 { GL_RGBA
, GL_RGBA16
, "RGBA16" },
156 struct baseFormatInfo
{
157 struct formatInfo
*format
;
161 #define NUM_BASE_FORMATS (sizeof(baseFormats) / sizeof(baseFormats[0]))
163 struct baseFormatInfo baseFormats
[] =
165 { luminanceFormats
, 0, NUM_LUMINANCE_FORMATS
},
166 { alphaFormats
, 0, NUM_ALPHA_FORMATS
},
167 { intensityFormats
, 0, NUM_INTENSITY_FORMATS
},
168 { luminanceAlphaFormats
, 0, NUM_LUMINANCE_ALPHA_FORMATS
},
169 { rgbFormats
, 0, NUM_RGB_FORMATS
},
170 { rgbaFormats
, 0, NUM_RGBA_FORMATS
},
173 #define NUM_ENV_COLORS (sizeof(envColors) / sizeof(envColors[0]))
175 GLfloat envColors
[][4] =
177 { 0.0, 0.0, 0.0, 1.0 },
178 { 1.0, 0.0, 0.0, 1.0 },
179 { 0.0, 1.0, 0.0, 1.0 },
180 { 0.0, 0.0, 1.0, 1.0 },
181 { 1.0, 1.0, 1.0, 1.0 },
189 /* allow for run-time check for GL_EXT_texture_env_add */
190 int NUM_ENV_MODES
= 5;
191 struct envModeInfo envModes
[] =
193 { GL_REPLACE
, "REPLACE" },
194 { GL_MODULATE
, "MODULATE" },
195 { GL_BLEND
, "BLEND" },
196 { GL_DECAL
, "DECAL" },
197 #if GL_EXT_texture_env_add
202 static void checkErrors( void )
206 while ( (error
= glGetError()) != GL_NO_ERROR
) {
207 fprintf( stderr
, "Error: %s\n", (char *) gluErrorString( error
) );
211 static void drawString( const char *string
, GLfloat x
, GLfloat y
,
212 const GLfloat color
[4] )
215 glRasterPos2f( x
, y
);
218 glutBitmapCharacter( GLUT_BITMAP_TIMES_ROMAN_10
, *string
);
223 static void drawStringOutline( const char *string
, GLfloat x
, GLfloat y
,
224 const GLfloat color
[4],
225 const GLfloat outline
[4] )
227 drawString( string
, x
- 1, y
, outline
);
228 drawString( string
, x
+ 1, y
, outline
);
229 drawString( string
, x
, y
- 1, outline
);
230 drawString( string
, x
, y
+ 1, outline
);
231 drawString( string
, x
, y
, color
);
234 static void begin2D( int width
, int height
)
236 glMatrixMode( GL_PROJECTION
);
241 glOrtho( 0, width
, 0, height
, -1, 1 );
242 glMatrixMode( GL_MODELVIEW
);
248 static void end2D( void )
250 glMatrixMode( GL_PROJECTION
);
252 glMatrixMode( GL_MODELVIEW
);
256 static void initialize( void )
258 glMatrixMode( GL_PROJECTION
);
261 glOrtho( -1.5, 1.5, -1.5, 1.5, -1.5, 1.5 );
263 glMatrixMode(GL_MODELVIEW
);
266 glShadeModel( GL_FLAT
);
270 static void keyboard( unsigned char c
, int x
, int y
)
275 envColor
= envColor
% (int) NUM_ENV_COLORS
;
278 drawBackground
= !drawBackground
;
281 drawBlended
= !drawBlended
;
284 drawSmooth
= !drawSmooth
;
287 drawTextured
= !drawTextured
;
290 displayLevelInfo
= !displayLevelInfo
;
292 case 27: /* Escape key should force exit. */
293 glutDestroyWindow(Win
);
303 static void special( int key
, int x
, int y
)
307 if ( ++baseFormat
> NUM_BASE_FORMATS
- 1 ) {
312 if ( --baseFormat
< 0 ) {
313 baseFormat
= NUM_BASE_FORMATS
- 1;
317 --baseFormats
[baseFormat
].current
;
318 if ( baseFormats
[baseFormat
].current
< 0 ) {
319 baseFormats
[baseFormat
].current
= baseFormats
[baseFormat
].number
- 1;
323 ++baseFormats
[baseFormat
].current
;
324 if ( baseFormats
[baseFormat
].current
> baseFormats
[baseFormat
].number
- 1 ) {
325 baseFormats
[baseFormat
].current
= 0;
335 reshape( int w
, int h
)
339 /* No need to call glViewPort here since "draw" calls it! */
342 static void loadTexture( int width
, int height
,
343 const struct formatInfo
*format
)
345 int luminanceSize
= 0;
348 GLenum textureFormat
;
349 GLubyte
*texImage
, *p
;
350 int elementsPerGroup
, elementSize
, groupSize
, rowSize
;
353 switch ( format
->baseFormat
) {
356 textureFormat
= GL_LUMINANCE
;
360 /* Note: format=GL_INTENSITY for glTexImage is not legal */
361 textureFormat
= GL_LUMINANCE
;
365 textureFormat
= GL_ALPHA
;
367 case GL_LUMINANCE_ALPHA
:
370 textureFormat
= GL_LUMINANCE_ALPHA
;
374 textureFormat
= GL_RGB
;
379 textureFormat
= GL_RGBA
;
382 fprintf(stderr
, "bad internal format info\n");
386 elementsPerGroup
= luminanceSize
+ alphaSize
+ rgbSize
;
387 elementSize
= sizeof(GLubyte
);
388 groupSize
= elementsPerGroup
* elementSize
;
389 rowSize
= width
* groupSize
;
391 if ( (texImage
= (GLubyte
*) malloc( height
* rowSize
) ) == NULL
) {
392 fprintf( stderr
, "texture malloc failed\n" );
396 for ( i
= 0 ; i
< height
; i
++ )
398 p
= texImage
+ i
* rowSize
;
400 for ( j
= 0 ; j
< width
; j
++ )
402 if ( luminanceSize
> 0 )
415 if ( i
> height
/ 2 ) {
416 if ( j
< width
/ 2 ) {
422 if ( j
< width
/ 2 ) {
444 if ( i
> height
/ 2 ) {
445 if ( j
< width
/ 2 ) {
455 if ( j
< width
/ 2 ) {
465 p
+= 3 * elementSize
;
481 int i2
= i
- height
/ 2;
482 int j2
= j
- width
/ 2;
485 if ( -h8
<= i2
&& i2
<= h8
&& -w8
<= j2
&& j2
<= w8
) {
487 } else if ( -2 * h8
<= i2
&& i2
<= 2 * h8
&& -2 * w8
<= j2
&& j2
<= 2 * w8
) {
489 } else if ( -3 * h8
<= i2
&& i2
<= 3 * h8
&& -3 * w8
<= j2
&& j2
<= 3 * w8
) {
499 glTexImage2D( GL_TEXTURE_2D
, 0,
500 format
->internalFormat
, width
, height
, 0,
501 textureFormat
, GL_UNSIGNED_BYTE
, texImage
);
506 static void drawCheck( int w
, int h
, const GLfloat lightCheck
[4],
507 const GLfloat darkCheck
[4] )
513 for ( i
= 0 ; i
< w
; i
++ ) {
514 GLfloat x0
= -1.0 + i
* dw
;
515 GLfloat x1
= x0
+ dw
;
517 glBegin( GL_QUAD_STRIP
);
519 for ( j
= 0 ; j
<= h
; j
++ ) {
520 GLfloat y
= -1.0 + j
* dh
;
523 glColor4fv( lightCheck
);
525 glColor4fv( darkCheck
);
536 static const char *lookupFormat( GLint format
)
546 return "GL_LUMINANCE";
547 case GL_LUMINANCE_ALPHA
:
548 return "GL_LUMINANCE_ALPHA";
550 return "GL_INTENSITY";
552 return "GL_COLOR_INDEX";
558 return "unknown format";
562 static void drawSample( int x
, int y
, int w
, int h
,
563 const struct formatInfo
*format
,
564 const struct envModeInfo
*envMode
)
566 glViewport( x
, y
, w
, h
);
567 glScissor( x
, y
, w
, h
);
569 glClearColor( 0.1, 0.1, 0.1, 1.0 );
570 glClear( GL_COLOR_BUFFER_BIT
);
573 drawString( format
->name
, 10, h
- 15, labelInfoColor
);
574 drawString( envMode
->name
, 10, 5, labelInfoColor
);
577 glTexEnvi( GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, envMode
->mode
);
578 glTexEnvfv( GL_TEXTURE_ENV
, GL_TEXTURE_ENV_COLOR
, envColors
[envColor
] );
580 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
581 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
583 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_S
, GL_CLAMP
);
584 glTexParameteri( GL_TEXTURE_2D
, GL_TEXTURE_WRAP_T
, GL_CLAMP
);
586 loadTexture( textureWidth
, textureHeight
, format
);
588 if ( drawBackground
) {
589 drawCheck( 15, 15, lightCheck
, darkCheck
);
592 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
593 glEnable( GL_BLEND
);
596 glShadeModel( GL_SMOOTH
);
599 glShadeModel( GL_FLAT
);
600 glColor4f(1, 1, 1, 1);
602 if ( drawTextured
) {
603 glEnable( GL_TEXTURE_2D
);
607 * if (drawSmooth) then draw quad which goes from purple at the
608 * bottom (100% alpha) to green at the top (50% alpha).
611 if ( drawSmooth
) glColor4f( 1.0, 0.0, 1.0, 1.0 );
612 glTexCoord2f( 0.0, 0.0 );
613 glVertex2f( -0.8, -0.8 );
615 if ( drawSmooth
) glColor4f( 1.0, 0.0, 1.0, 1.0 );
616 glTexCoord2f( 1.0, 0.0 );
617 glVertex2f( 0.8, -0.8 );
619 if ( drawSmooth
) glColor4f( 0.0, 1.0, 0.0, 0.5 );
620 glTexCoord2f( 1.0, 1.0 );
621 glVertex2f( 0.8, 0.8 );
623 if ( drawSmooth
) glColor4f( 0.0, 1.0, 0.0, 0.5 );
624 glTexCoord2f( 0.0, 1.0 );
625 glVertex2f( -0.8, 0.8 );
628 glDisable( GL_BLEND
);
629 glShadeModel( GL_FLAT
);
630 glDisable( GL_TEXTURE_2D
);
632 if ( envMode
->mode
== GL_DECAL
&&
633 (format
->baseFormat
== GL_ALPHA
||
634 format
->baseFormat
== GL_LUMINANCE
||
635 format
->baseFormat
== GL_LUMINANCE_ALPHA
||
636 format
->baseFormat
== GL_INTENSITY
)) {
637 /* undefined format/mode combination */
639 drawStringOutline( "UNDEFINED MODE", 15, h
/ 2,
640 labelLevelColor0
, labelLevelColor1
);
643 else if ( displayLevelInfo
) {
644 GLint width
, height
, border
, format
;
645 GLint redSize
, greenSize
, blueSize
, alphaSize
;
646 GLint luminanceSize
, intensitySize
;
649 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_WIDTH
, &width
);
650 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_HEIGHT
, &height
);
651 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_BORDER
, &border
);
652 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_INTERNAL_FORMAT
, &format
);
653 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_RED_SIZE
, &redSize
);
654 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_GREEN_SIZE
, &greenSize
);
655 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_BLUE_SIZE
, &blueSize
);
656 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_ALPHA_SIZE
, &alphaSize
);
657 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_LUMINANCE_SIZE
, &luminanceSize
);
658 glGetTexLevelParameteriv( GL_TEXTURE_2D
, 0, GL_TEXTURE_INTENSITY_SIZE
, &intensitySize
);
661 sprintf( buf
, "dimensions: %d x %d", width
, height
);
662 drawStringOutline( buf
, 15, h
/ 2 + 20, labelLevelColor0
, labelLevelColor1
);
664 sprintf( buf
, "border: %d", border
);
665 drawStringOutline( buf
, 15, h
/ 2 + 10, labelLevelColor0
, labelLevelColor1
);
667 sprintf( buf
, "internal format:" );
668 drawStringOutline( buf
, 15, h
/ 2, labelLevelColor0
, labelLevelColor1
);
670 sprintf( buf
, " %s", lookupFormat( format
) );
671 drawStringOutline( buf
, 15, h
/ 2 - 10, labelLevelColor0
, labelLevelColor1
);
673 sprintf( buf
, "sizes:" );
674 drawStringOutline( buf
, 15, h
/ 2 - 20, labelLevelColor0
, labelLevelColor1
);
676 sprintf( buf
, " %d / %d / %d / %d / %d / %d",
677 redSize
, greenSize
, blueSize
, alphaSize
,
678 luminanceSize
, intensitySize
);
679 drawStringOutline( buf
, 15, h
/ 2 - 30, labelLevelColor0
, labelLevelColor1
);
685 static void display( void )
687 int numX
= NUM_ENV_MODES
, numY
= NUM_BASE_FORMATS
;
688 float xBase
= (float) winWidth
* 0.01;
689 float xOffset
= (winWidth
- xBase
) / numX
;
690 float xSize
= max( xOffset
- xBase
, 1 );
691 float yBase
= (float) winHeight
* 0.01;
692 float yOffset
= (winHeight
- yBase
) / numY
;
693 float ySize
= max( yOffset
- yBase
, 1 );
697 glViewport( 0, 0, winWidth
, winHeight
);
698 glDisable( GL_SCISSOR_TEST
);
699 glClearColor( 0.0, 0.0, 0.0, 0.0 );
700 glClear( GL_COLOR_BUFFER_BIT
);
701 glEnable( GL_SCISSOR_TEST
);
704 y
= (winHeight
- 1) - yOffset
;
706 for ( i
= 0 ; i
< NUM_BASE_FORMATS
; i
++ )
708 struct formatInfo
*format
;
710 if ( i
== baseFormat
) {
711 labelInfoColor
= labelColor1
;
713 labelInfoColor
= labelColor0
;
716 format
= &baseFormats
[i
].format
[baseFormats
[i
].current
];
718 for ( j
= 0 ; j
< NUM_ENV_MODES
; j
++ ) {
719 struct envModeInfo
*envMode
;
721 envMode
= &envModes
[j
];
722 drawSample( x
, y
, xSize
, ySize
, format
, envMode
);
730 if ( doubleBuffered
) {
739 static void usage( char *name
)
741 fprintf( stderr
, "usage: %s [ options ]\n", name
);
742 fprintf( stderr
, "\n" );
743 fprintf( stderr
, "options:\n" );
744 fprintf( stderr
, " -sb single buffered\n" );
745 fprintf( stderr
, " -db double buffered\n" );
746 fprintf( stderr
, " -info print OpenGL driver info\n" );
749 static void instructions( void )
751 fprintf( stderr
, "texenv - texture environment and internal format test\n" );
752 fprintf( stderr
, "\n" );
753 fprintf( stderr
, " [c] - cycle through background colors\n" );
754 fprintf( stderr
, " [g] - toggle background\n" );
755 fprintf( stderr
, " [b] - toggle blend\n" );
756 fprintf( stderr
, " [s] - toggle smooth shading\n" );
757 fprintf( stderr
, " [t] - toggle texturing\n" );
758 fprintf( stderr
, " [i] - toggle information display\n" );
759 fprintf( stderr
, " up/down - select row\n" );
760 fprintf( stderr
, " left/right - change row's internal format\n" );
763 int main( int argc
, char *argv
[] )
765 GLboolean info
= GL_FALSE
;
768 glutInit( &argc
, argv
);
770 for ( i
= 1 ; i
< argc
; i
++ ) {
771 if ( !strcmp( "-sb", argv
[i
] ) ) {
772 doubleBuffered
= GL_FALSE
;
773 } else if ( !strcmp( "-db", argv
[i
] ) ) {
774 doubleBuffered
= GL_TRUE
;
775 } else if ( !strcmp( "-info", argv
[i
] ) ) {
783 if ( doubleBuffered
) {
784 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
786 glutInitDisplayMode( GLUT_RGB
| GLUT_SINGLE
);
789 glutInitWindowSize( winWidth
, winHeight
);
790 glutInitWindowPosition( 0, 0 );
791 Win
= glutCreateWindow( "Texture Environment Test" );
798 printf( "GL_RENDERER = %s\n", (char *) glGetString( GL_RENDERER
) );
799 printf( "GL_VERSION = %s\n", (char *) glGetString( GL_VERSION
) );
800 printf( "GL_VENDOR = %s\n", (char *) glGetString( GL_VENDOR
) ) ;
801 printf( "GL_EXTENSIONS = %s\n", (char *) glGetString( GL_EXTENSIONS
) );
804 #if GL_EXT_texture_env_add
805 if ( !glutExtensionSupported( "GL_EXT_texture_env_add" ) ) {
806 fprintf( stderr
, "missing extension: GL_EXT_texture_env_add\n" );
811 glutDisplayFunc( display
);
812 glutReshapeFunc( reshape
);
813 glutKeyboardFunc( keyboard
);
814 glutSpecialFunc( special
);