- loads tht image into GL's texture memory.
- Writes to stderr and returns False on error.
- */
-Bool
-screen_to_texture (Screen *screen, Window window,
- int desired_width, int desired_height,
- Bool mipmap_p,
- char **filename_return,
- XRectangle *geometry_return,
- int *image_width_return,
- int *image_height_return,
- int *texture_width_return,
- int *texture_height_return)
-{
- Display *dpy = DisplayOfScreen (screen);
- img_closure *data = (img_closure *) calloc (1, sizeof(*data));
- XWindowAttributes xgwa;
- char *filename = 0;
- XRectangle geom = { 0, 0, 0, 0 };
- int wret;
-
- if (! image_width_return)
- image_width_return = &wret;
-
- if (debug_p)
- data->load_time = double_time();
-
- data->texid = -1;
- data->mipmap_p = mipmap_p;
- data->filename_return = filename_return;
- data->geometry_return = geometry_return;
- data->image_width_return = image_width_return;
- data->image_height_return = image_height_return;
- data->texture_width_return = texture_width_return;
- data->texture_height_return = texture_height_return;
-
- XGetWindowAttributes (dpy, window, &xgwa);
- data->pix_width = xgwa.width;
- data->pix_height = xgwa.height;
- data->pix_depth = xgwa.depth;
-
- if (desired_width && desired_width < xgwa.width)
- data->pix_width = desired_width;
- if (desired_height && desired_height < xgwa.height)
- data->pix_height = desired_height;
-
- data->pixmap = XCreatePixmap (dpy, window, data->pix_width, data->pix_height,
- data->pix_depth);
- load_random_image (screen, window, data->pixmap, &filename, &geom);
- screen_to_texture_async_cb (screen, window, data->pixmap, filename, &geom,
- data);
-
- return (*image_width_return != 0);
-}
-
-
-/* Like the above, but the image is loaded in a background process,
- and a callback is run when the loading is complete.