+setup_random_texture (ModeInfo *mi, texture *texture)
+{
+ int width = 0, height = 0;
+ char buf[1024];
+ unsigned char *my_data = NULL;
+#if 0
+ int i, j, c;
+ int style;
+ int r0, g0, b0, a0, r1, g1, b1, a1;
+#endif
+
+#ifdef DEBUG
+ printf("RandomTexture\n");
+#endif
+
+ /* use this texture */
+ glBindTexture(GL_TEXTURE_2D, texture->id);
+
+ clear_gl_error();
+
+ /*
+ * code for various generated patterns - noise, stripes, checks etc.
+ * random geometric shapes looked the best.
+ */
+
+#if 0
+ style = random() & 0x3;
+ r0 = random() & 0xff;
+ g0 = random() & 0xff;
+ b0 = random() & 0xff;
+ a0 = 0xff;
+ r1 = random() & 0xff;
+ g1 = random() & 0xff;
+ b1 = random() & 0xff;
+ a1 = 0xff;
+
+ switch (style) {
+ case 0: /* random */
+ printf("Random0\n");
+ height = width = TEXTURE_SIZE;
+ my_data = (void *)malloc(width * height * 4);
+ for (i = 0 ; i < width ; i += 2) {
+ for (j = 0 ; j < height ; j += 2) {
+ r0 = random() & 0xff;
+ g0 = random() & 0xff;
+ b0 = random() & 0xff;
+ a0 = 0xff;
+ plot2(my_data, i, j, r0, g0, b0, a0);
+ }
+ }
+ break;
+
+ case 1: /* shapes */
+#endif
+#ifdef DEBUG
+ printf("Shapes\n");
+#endif
+ height = width = TEXTURE_SIZE;
+ my_data = (void *)malloc(width * height * 4);
+ draw_shapes(my_data);
+#if 0
+ break;
+
+ case 2: /* check */
+ printf("Check\n");
+ height = width = TEXTURE_SIZE;
+ my_data = (void *)malloc(width * height * 4);
+ for (i = 0 ; i < height ; i += 2) {
+ for (j = 0 ; j < width ; j += 2) {
+ if (((i + j) & 0x3) == 0) {
+ plot2(my_data, i, j, r0, g0, b0, a0);
+ } else {
+ plot2(my_data, i, j, r1, g1, b1, a1);
+ }
+ }
+ }
+ break;
+
+ case 3: /* random stripes */
+ printf("Stripes 2\n");
+ height = width = TEXTURE_SIZE;
+ my_data = (void *)malloc(width * height * 4);
+ for (i = 0 ; i < height ; i += 2) {
+ r0 = random() & 0xff;
+ g0 = random() & 0xff;
+ b0 = random() & 0xff;
+ a0 = 0xff;
+ for (j = 0 ; j < width ; j += 2) {
+ plot2(my_data, i, j, r0, g0, b0, a0);
+ }
+ }
+ break;
+ }
+#endif
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
+ width, height, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, my_data);
+ sprintf (buf, "random texture: (%dx%d)",
+ width, height);
+ check_gl_error(buf);
+
+ /* setup parameters for texturing */
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
+
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
+ if (random() & 0x1) {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ } else {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ }
+
+ if (my_data != NULL) {
+ free(my_data);
+ my_data = NULL;
+ }
+
+ /* use full texture */
+ /* acd - was 1.0 */
+ texture->min_tx = 0.0;
+ texture->max_tx = 2.0;
+ texture->min_ty = 0.0;
+ texture->max_ty = 2.0;
+ texture->start_time = time((time_t *)0);
+}
+
+static Bool
+setup_file_texture (ModeInfo *mi, char *filename, texture *texture)