0);
to->data = (char *) calloc (to->height, to->bytes_per_line);
+ /* Set the bit order in the XImage structure to whatever the
+ local host's native bit order is.
+ */
+ to->bitmap_bit_order =
+ to->byte_order =
+ (bigendian() ? MSBFirst : LSBFirst);
+
if (visual_class (screen, visual) == PseudoColor ||
visual_class (screen, visual) == GrayScale)
{
We use this when mipmapping fails on large textures.
*/
static void
-halve_image (XImage *ximage)
+halve_image (XImage *ximage, XRectangle *geom)
{
int w2 = ximage->width/2;
int h2 = ximage->height/2;
*ximage = *ximage2;
ximage2->data = 0;
XFree (ximage2);
+
+ if (geom)
+ {
+ geom->x /= 2;
+ geom->y /= 2;
+ geom->width /= 2;
+ geom->height /= 2;
+ }
}
GLint type, GLint format,
int *width_return,
int *height_return,
+ XRectangle *geometry,
Bool mipmap_p)
{
int max_reduction = 7;
if (debug_p)
fprintf (stderr, "%s: mipmap error (%dx%d): %s\n",
progname, ximage->width, ximage->height, s);
- halve_image (ximage);
+ halve_image (ximage, geometry);
goto AGAIN;
}
}
glBindTexture (GL_TEXTURE_2D, dd.texid);
glPixelStorei (GL_UNPACK_ALIGNMENT, ximage->bitmap_pad / 8);
- ok = ximage_to_texture (ximage, type, format, &tw, &th, dd.mipmap_p);
+ ok = ximage_to_texture (ximage, type, format, &tw, &th, geometry,
+ dd.mipmap_p);
+ if (ok)
+ {
+ iw = ximage->width; /* in case the image was shrunk */
+ ih = ximage->height;
+ }
}
if (ximage) XDestroyImage (ximage);