13 #include "../util/readtex.c" /* I know, this is a hack. */
15 #define TEXTURE_FILE "../images/girl.rgb"
17 static GLboolean Antialias
= GL_FALSE
;
18 static GLboolean Animate
= GL_FALSE
;
19 static GLint Texture
= 1;
20 static GLboolean Stipple
= GL_FALSE
;
21 static GLfloat LineWidth
= 1.0;
23 static GLfloat Xrot
= -60.0, Yrot
= 0.0, Zrot
= 0.0;
24 static GLfloat DYrot
= 1.0;
25 static GLboolean Points
= GL_FALSE
;
26 static GLfloat Scale
= 1.0;
28 static void Idle( void )
37 static void Display( void )
41 glClear( GL_COLOR_BUFFER_BIT
);
44 glRotatef(Xrot
, 1.0, 0.0, 0.0);
45 glRotatef(Yrot
, 0.0, 1.0, 0.0);
46 glRotatef(Zrot
, 0.0, 0.0, 1.0);
47 glScalef(Scale
, Scale
, Scale
);
54 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
55 for (s
= 0.0; s
<= 1.0; s
+= 0.025) {
60 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, t
, s
);
69 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
74 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 0.0, t
);
79 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 1.0, t
);
91 static void Reshape( int width
, int height
)
93 GLfloat ar
= (float) width
/ height
;
94 glViewport( 0, 0, width
, height
);
95 glMatrixMode( GL_PROJECTION
);
97 glFrustum( -ar
, ar
, -1.0, 1.0, 10.0, 100.0 );
98 glMatrixMode( GL_MODELVIEW
);
100 glTranslatef( 0.0, 0.0, -12.0 );
104 static void Key( unsigned char key
, int x
, int y
)
110 Antialias
= !Antialias
;
112 glEnable(GL_LINE_SMOOTH
);
113 glEnable(GL_POINT_SMOOTH
);
115 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
118 glDisable(GL_LINE_SMOOTH
);
119 glDisable(GL_POINT_SMOOTH
);
128 glActiveTextureARB(GL_TEXTURE0_ARB
);
129 glDisable(GL_TEXTURE_2D
);
130 glActiveTextureARB(GL_TEXTURE1_ARB
);
131 glDisable(GL_TEXTURE_2D
);
133 else if (Texture
== 1) {
134 glActiveTextureARB(GL_TEXTURE0_ARB
);
135 glEnable(GL_TEXTURE_2D
);
136 glActiveTextureARB(GL_TEXTURE1_ARB
);
137 glDisable(GL_TEXTURE_2D
);
140 glActiveTextureARB(GL_TEXTURE0_ARB
);
141 glEnable(GL_TEXTURE_2D
);
142 glActiveTextureARB(GL_TEXTURE1_ARB
);
143 glEnable(GL_TEXTURE_2D
);
148 if (LineWidth
< 0.25)
150 glLineWidth(LineWidth
);
151 glPointSize(LineWidth
);
157 glLineWidth(LineWidth
);
158 glPointSize(LineWidth
);
166 glEnable(GL_LINE_STIPPLE
);
168 glDisable(GL_LINE_STIPPLE
);
181 printf("LineWidth, PointSize = %f\n", LineWidth
);
186 static void SpecialKey( int key
, int x
, int y
)
210 static void Init( int argc
, char *argv
[] )
215 for (u
= 0; u
< 2; u
++) {
216 glActiveTextureARB(GL_TEXTURE0_ARB
+ u
);
217 glBindTexture(GL_TEXTURE_2D
, 10+u
);
219 glEnable(GL_TEXTURE_2D
);
220 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
221 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
222 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
223 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
226 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_REPLACE
);
228 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_ADD
);
230 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
231 if (!LoadRGBMipmaps(TEXTURE_FILE
, GL_RGB
)) {
232 printf("Error: couldn't load texture image\n");
237 glLineStipple(1, 0xff);
239 if (argc
> 1 && strcmp(argv
[1], "-info")==0) {
240 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
241 printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION
));
242 printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR
));
243 printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS
));
246 glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE
, r
);
247 printf("Non-smooth point size range: %g .. %g\n", r
[0], r
[1]);
248 glGetFloatv(GL_POINT_SIZE_RANGE
, r
);
249 printf("Smoothed point size range: %g .. %g\n", r
[0], r
[1]);
250 glGetFloatv(GL_ALIASED_LINE_WIDTH_RANGE
, r
);
251 printf("Non-smooth line width range: %g .. %g\n", r
[0], r
[1]);
252 glGetFloatv(GL_LINE_WIDTH_RANGE
, r
);
253 printf("Smoothed line width range: %g .. %g\n", r
[0], r
[1]);
257 int main( int argc
, char *argv
[] )
259 glutInit( &argc
, argv
);
260 glutInitWindowPosition(0, 0);
261 glutInitWindowSize( 400, 300 );
263 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
265 glutCreateWindow(argv
[0] );
269 glutReshapeFunc( Reshape
);
270 glutKeyboardFunc( Key
);
271 glutSpecialFunc( SpecialKey
);
272 glutDisplayFunc( Display
);
274 glutIdleFunc( Idle
);