14 #include "../util/readtex.c" /* I know, this is a hack. */
16 #define TEXTURE_FILE "../images/girl.rgb"
18 static GLboolean Antialias
= GL_FALSE
;
19 static GLboolean Animate
= GL_FALSE
;
20 static GLint Texture
= 1;
21 static GLboolean Stipple
= GL_FALSE
;
22 static GLfloat LineWidth
= 1.0;
24 static GLfloat Xrot
= -60.0, Yrot
= 0.0, Zrot
= 0.0;
25 static GLfloat DYrot
= 1.0;
26 static GLboolean Points
= GL_FALSE
;
27 static GLfloat Scale
= 1.0;
29 static void Idle( void )
38 static void Display( void )
42 glClear( GL_COLOR_BUFFER_BIT
);
45 glRotatef(Xrot
, 1.0, 0.0, 0.0);
46 glRotatef(Yrot
, 0.0, 1.0, 0.0);
47 glRotatef(Zrot
, 0.0, 0.0, 1.0);
48 glScalef(Scale
, Scale
, Scale
);
55 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
56 for (s
= 0.0; s
<= 1.0; s
+= 0.025) {
61 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, t
, s
);
70 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
75 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 0.0, t
);
80 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 1.0, t
);
92 static void Reshape( int width
, int height
)
94 GLfloat ar
= (float) width
/ height
;
95 glViewport( 0, 0, width
, height
);
96 glMatrixMode( GL_PROJECTION
);
98 glFrustum( -ar
, ar
, -1.0, 1.0, 10.0, 100.0 );
99 glMatrixMode( GL_MODELVIEW
);
101 glTranslatef( 0.0, 0.0, -12.0 );
105 static void Key( unsigned char key
, int x
, int y
)
111 Antialias
= !Antialias
;
113 glEnable(GL_LINE_SMOOTH
);
114 glEnable(GL_POINT_SMOOTH
);
116 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
119 glDisable(GL_LINE_SMOOTH
);
120 glDisable(GL_POINT_SMOOTH
);
129 glActiveTextureARB(GL_TEXTURE0_ARB
);
130 glDisable(GL_TEXTURE_2D
);
131 glActiveTextureARB(GL_TEXTURE1_ARB
);
132 glDisable(GL_TEXTURE_2D
);
134 else if (Texture
== 1) {
135 glActiveTextureARB(GL_TEXTURE0_ARB
);
136 glEnable(GL_TEXTURE_2D
);
137 glActiveTextureARB(GL_TEXTURE1_ARB
);
138 glDisable(GL_TEXTURE_2D
);
141 glActiveTextureARB(GL_TEXTURE0_ARB
);
142 glEnable(GL_TEXTURE_2D
);
143 glActiveTextureARB(GL_TEXTURE1_ARB
);
144 glEnable(GL_TEXTURE_2D
);
149 if (LineWidth
< 0.25)
151 glLineWidth(LineWidth
);
152 glPointSize(LineWidth
);
158 glLineWidth(LineWidth
);
159 glPointSize(LineWidth
);
167 glEnable(GL_LINE_STIPPLE
);
169 glDisable(GL_LINE_STIPPLE
);
182 printf("LineWidth, PointSize = %f\n", LineWidth
);
187 static void SpecialKey( int key
, int x
, int y
)
211 static void Init( int argc
, char *argv
[] )
214 for (u
= 0; u
< 2; u
++) {
215 glActiveTextureARB(GL_TEXTURE0_ARB
+ u
);
216 glBindTexture(GL_TEXTURE_2D
, 10+u
);
218 glEnable(GL_TEXTURE_2D
);
219 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
220 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
221 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
222 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
225 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_REPLACE
);
227 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_ADD
);
229 glPixelStorei(GL_UNPACK_ALIGNMENT
, 1);
230 if (!LoadRGBMipmaps(TEXTURE_FILE
, GL_RGB
)) {
231 printf("Error: couldn't load texture image\n");
236 glLineStipple(1, 0xff);
238 if (argc
> 1 && strcmp(argv
[1], "-info")==0) {
239 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
240 printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION
));
241 printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR
));
242 printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS
));
247 int main( int argc
, char *argv
[] )
249 glutInit( &argc
, argv
);
250 glutInitWindowSize( 400, 300 );
252 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
254 glutCreateWindow(argv
[0] );
258 glutReshapeFunc( Reshape
);
259 glutKeyboardFunc( Key
);
260 glutSpecialFunc( SpecialKey
);
261 glutDisplayFunc( Display
);
263 glutIdleFunc( Idle
);