1 /* $Id: texline.c,v 1.1 2003/08/06 17:47:15 keithw Exp $ */
15 #include "../util/readtex.c" /* I know, this is a hack. */
17 #define TEXTURE_FILE "../images/girl.rgb"
19 static GLboolean Antialias
= GL_FALSE
;
20 static GLboolean Animate
= GL_FALSE
;
21 static GLint Texture
= 1;
22 static GLboolean Stipple
= GL_FALSE
;
23 static GLfloat LineWidth
= 1.0;
25 static GLfloat Xrot
= -60.0, Yrot
= 0.0, Zrot
= 0.0;
26 static GLfloat DYrot
= 1.0;
27 static GLboolean Points
= GL_FALSE
;
28 static GLfloat Scale
= 1.0;
30 static void Idle( void )
39 static void Display( void )
43 glClear( GL_COLOR_BUFFER_BIT
);
46 glRotatef(Xrot
, 1.0, 0.0, 0.0);
47 glRotatef(Yrot
, 0.0, 1.0, 0.0);
48 glRotatef(Zrot
, 0.0, 0.0, 1.0);
49 glScalef(Scale
, Scale
, Scale
);
56 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
57 for (s
= 0.0; s
<= 1.0; s
+= 0.025) {
62 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, t
, s
);
71 for (t
= 0.0; t
<= 1.0; t
+= 0.025) {
76 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 0.0, t
);
81 glMultiTexCoord2fARB(GL_TEXTURE1_ARB
, 1.0, t
);
93 static void Reshape( int width
, int height
)
95 GLfloat ar
= (float) width
/ height
;
96 glViewport( 0, 0, width
, height
);
97 glMatrixMode( GL_PROJECTION
);
99 glFrustum( -ar
, ar
, -1.0, 1.0, 10.0, 100.0 );
100 glMatrixMode( GL_MODELVIEW
);
102 glTranslatef( 0.0, 0.0, -12.0 );
106 static void Key( unsigned char key
, int x
, int y
)
112 Antialias
= !Antialias
;
114 glEnable(GL_LINE_SMOOTH
);
115 glEnable(GL_POINT_SMOOTH
);
117 glBlendFunc(GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
120 glDisable(GL_LINE_SMOOTH
);
121 glDisable(GL_POINT_SMOOTH
);
130 glActiveTextureARB(GL_TEXTURE0_ARB
);
131 glDisable(GL_TEXTURE_2D
);
132 glActiveTextureARB(GL_TEXTURE1_ARB
);
133 glDisable(GL_TEXTURE_2D
);
135 else if (Texture
== 1) {
136 glActiveTextureARB(GL_TEXTURE0_ARB
);
137 glEnable(GL_TEXTURE_2D
);
138 glActiveTextureARB(GL_TEXTURE1_ARB
);
139 glDisable(GL_TEXTURE_2D
);
142 glActiveTextureARB(GL_TEXTURE0_ARB
);
143 glEnable(GL_TEXTURE_2D
);
144 glActiveTextureARB(GL_TEXTURE1_ARB
);
145 glEnable(GL_TEXTURE_2D
);
150 if (LineWidth
< 0.25)
152 glLineWidth(LineWidth
);
153 glPointSize(LineWidth
);
159 glLineWidth(LineWidth
);
160 glPointSize(LineWidth
);
168 glEnable(GL_LINE_STIPPLE
);
170 glDisable(GL_LINE_STIPPLE
);
183 printf("LineWidth, PointSize = %f\n", LineWidth
);
188 static void SpecialKey( int key
, int x
, int y
)
212 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
));
248 int main( int argc
, char *argv
[] )
250 glutInit( &argc
, argv
);
251 glutInitWindowSize( 400, 300 );
253 glutInitDisplayMode( GLUT_RGB
| GLUT_DOUBLE
);
255 glutCreateWindow(argv
[0] );
259 glutReshapeFunc( Reshape
);
260 glutKeyboardFunc( Key
);
261 glutSpecialFunc( SpecialKey
);
262 glutDisplayFunc( Display
);
264 glutIdleFunc( Idle
);