ReactOS 0.4.15-dev-7918-g2a2556c
mipmap.c File Reference
#include "gluos.h"
#include <assert.h>
#include <GL/glu.h>
#include <math.h>
Include dependency graph for mipmap.c:

Go to the source code of this file.

Classes

union  Type_Widget
 
struct  PixelStorageModes
 

Macros

#define __GLU_SWAP_2_BYTES(s)   (GLushort)(((GLushort)((const GLubyte*)(s))[1])<<8 | ((const GLubyte*)(s))[0])
 
#define __GLU_SWAP_4_BYTES(s)
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define BOX2   2
 
#define __GLU_INIT_SWAP_IMAGE   void *tmpImage
 
#define __GLU_SWAP_IMAGE(a, b)   tmpImage = a; a = b; b = tmpImage;
 
#define BOX4   4
 
#define BOX2   2
 
#define BOX2   2
 
#define gluTexImage3D   glTexImage3D
 
#define BOX8   8
 
#define BOX8   8
 

Functions

static int gluBuild1DMipmapLevelsCore (GLenum, GLint, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
 
static int gluBuild2DMipmapLevelsCore (GLenum, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
 
static int gluBuild3DMipmapLevelsCore (GLenum, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
 
static GLfloat bytes_per_element (GLenum type)
 
static GLint elements_per_group (GLenum format, GLenum type)
 
static GLint is_index (GLenum format)
 
static GLint image_size (GLint width, GLint height, GLenum format, GLenum type)
 
static void fill_image (const PixelStorageModes *, GLint width, GLint height, GLenum format, GLenum type, GLboolean index_format, const void *userdata, GLushort *newimage)
 
static void empty_image (const PixelStorageModes *, GLint width, GLint height, GLenum format, GLenum type, GLboolean index_format, const GLushort *oldimage, void *userdata)
 
static void scale_internal (GLint components, GLint widthin, GLint heightin, const GLushort *datain, GLint widthout, GLint heightout, GLushort *dataout)
 
static void scale_internal_ubyte (GLint components, GLint widthin, GLint heightin, const GLubyte *datain, GLint widthout, GLint heightout, GLubyte *dataout, GLint element_size, GLint ysize, GLint group_size)
 
static void scale_internal_byte (GLint components, GLint widthin, GLint heightin, const GLbyte *datain, GLint widthout, GLint heightout, GLbyte *dataout, GLint element_size, GLint ysize, GLint group_size)
 
static void scale_internal_ushort (GLint components, GLint widthin, GLint heightin, const GLushort *datain, GLint widthout, GLint heightout, GLushort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void scale_internal_short (GLint components, GLint widthin, GLint heightin, const GLshort *datain, GLint widthout, GLint heightout, GLshort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void scale_internal_uint (GLint components, GLint widthin, GLint heightin, const GLuint *datain, GLint widthout, GLint heightout, GLuint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void scale_internal_int (GLint components, GLint widthin, GLint heightin, const GLint *datain, GLint widthout, GLint heightout, GLint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void scale_internal_float (GLint components, GLint widthin, GLint heightin, const GLfloat *datain, GLint widthout, GLint heightout, GLfloat *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static int checkMipmapArgs (GLenum, GLenum, GLenum)
 
static GLboolean legalFormat (GLenum)
 
static GLboolean legalType (GLenum)
 
static GLboolean isTypePackedPixel (GLenum)
 
static GLboolean isLegalFormatForPackedPixelType (GLenum, GLenum)
 
static GLboolean isLegalLevels (GLint, GLint, GLint, GLint)
 
static void closestFit (GLenum, GLint, GLint, GLint, GLenum, GLenum, GLint *, GLint *)
 
static GLdouble extractUbyte (int, const void *)
 
static void shoveUbyte (GLdouble, int, void *)
 
static GLdouble extractSbyte (int, const void *)
 
static void shoveSbyte (GLdouble, int, void *)
 
static GLdouble extractUshort (int, const void *)
 
static void shoveUshort (GLdouble, int, void *)
 
static GLdouble extractSshort (int, const void *)
 
static void shoveSshort (GLdouble, int, void *)
 
static GLdouble extractUint (int, const void *)
 
static void shoveUint (GLdouble, int, void *)
 
static GLdouble extractSint (int, const void *)
 
static void shoveSint (GLdouble, int, void *)
 
static GLdouble extractFloat (int, const void *)
 
static void shoveFloat (GLdouble, int, void *)
 
static void halveImageSlice (int, GLdouble(*)(int, const void *), void(*)(GLdouble, int, void *), GLint, GLint, GLint, const void *, void *, GLint, GLint, GLint, GLint, GLint)
 
static void halveImage3D (int, GLdouble(*)(int, const void *), void(*)(GLdouble, int, void *), GLint, GLint, GLint, const void *, void *, GLint, GLint, GLint, GLint, GLint)
 
static void extract332 (int, const void *, GLfloat[])
 
static void shove332 (const GLfloat[], int, void *)
 
static void extract233rev (int, const void *, GLfloat[])
 
static void shove233rev (const GLfloat[], int, void *)
 
static void extract565 (int, const void *, GLfloat[])
 
static void shove565 (const GLfloat[], int, void *)
 
static void extract565rev (int, const void *, GLfloat[])
 
static void shove565rev (const GLfloat[], int, void *)
 
static void extract4444 (int, const void *, GLfloat[])
 
static void shove4444 (const GLfloat[], int, void *)
 
static void extract4444rev (int, const void *, GLfloat[])
 
static void shove4444rev (const GLfloat[], int, void *)
 
static void extract5551 (int, const void *, GLfloat[])
 
static void shove5551 (const GLfloat[], int, void *)
 
static void extract1555rev (int, const void *, GLfloat[])
 
static void shove1555rev (const GLfloat[], int, void *)
 
static void extract8888 (int, const void *, GLfloat[])
 
static void shove8888 (const GLfloat[], int, void *)
 
static void extract8888rev (int, const void *, GLfloat[])
 
static void shove8888rev (const GLfloat[], int, void *)
 
static void extract1010102 (int, const void *, GLfloat[])
 
static void shove1010102 (const GLfloat[], int, void *)
 
static void extract2101010rev (int, const void *, GLfloat[])
 
static void shove2101010rev (const GLfloat[], int, void *)
 
static void scaleInternalPackedPixel (int, void(*)(int, const void *, GLfloat[]), void(*)(const GLfloat[], int, void *), GLint, GLint, const void *, GLint, GLint, void *, GLint, GLint, GLint)
 
static void halveImagePackedPixel (int, void(*)(int, const void *, GLfloat[]), void(*)(const GLfloat[], int, void *), GLint, GLint, const void *, void *, GLint, GLint, GLint)
 
static void halve1DimagePackedPixel (int, void(*)(int, const void *, GLfloat[]), void(*)(const GLfloat[], int, void *), GLint, GLint, const void *, void *, GLint, GLint, GLint)
 
static void halve1Dimage_ubyte (GLint, GLuint, GLuint, const GLubyte *, GLubyte *, GLint, GLint, GLint)
 
static void halve1Dimage_byte (GLint, GLuint, GLuint, const GLbyte *, GLbyte *, GLint, GLint, GLint)
 
static void halve1Dimage_ushort (GLint, GLuint, GLuint, const GLushort *, GLushort *, GLint, GLint, GLint, GLint)
 
static void halve1Dimage_short (GLint, GLuint, GLuint, const GLshort *, GLshort *, GLint, GLint, GLint, GLint)
 
static void halve1Dimage_uint (GLint, GLuint, GLuint, const GLuint *, GLuint *, GLint, GLint, GLint, GLint)
 
static void halve1Dimage_int (GLint, GLuint, GLuint, const GLint *, GLint *, GLint, GLint, GLint, GLint)
 
static void halve1Dimage_float (GLint, GLuint, GLuint, const GLfloat *, GLfloat *, GLint, GLint, GLint, GLint)
 
static GLint imageSize3D (GLint, GLint, GLint, GLenum, GLenum)
 
static void fillImage3D (const PixelStorageModes *, GLint, GLint, GLint, GLenum, GLenum, GLboolean, const void *, GLushort *)
 
static void emptyImage3D (const PixelStorageModes *, GLint, GLint, GLint, GLenum, GLenum, GLboolean, const GLushort *, void *)
 
static void scaleInternal3D (GLint, GLint, GLint, GLint, const GLushort *, GLint, GLint, GLint, GLushort *)
 
static void retrieveStoreModes (PixelStorageModes *psm)
 
static void retrieveStoreModes3D (PixelStorageModes *psm)
 
static int computeLog (GLuint value)
 
static int nearestPower (GLuint value)
 
static void halveImage (GLint components, GLuint width, GLuint height, const GLushort *datain, GLushort *dataout)
 
static void halveImage_ubyte (GLint components, GLuint width, GLuint height, const GLubyte *datain, GLubyte *dataout, GLint element_size, GLint ysize, GLint group_size)
 
static void halveImage_byte (GLint components, GLuint width, GLuint height, const GLbyte *datain, GLbyte *dataout, GLint element_size, GLint ysize, GLint group_size)
 
static void halveImage_ushort (GLint components, GLuint width, GLuint height, const GLushort *datain, GLushort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void halveImage_short (GLint components, GLuint width, GLuint height, const GLshort *datain, GLshort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void halveImage_uint (GLint components, GLuint width, GLuint height, const GLuint *datain, GLuint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void halveImage_int (GLint components, GLuint width, GLuint height, const GLint *datain, GLint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
static void halveImage_float (GLint components, GLuint width, GLuint height, const GLfloat *datain, GLfloat *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
 
GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei widthin, GLsizei heightin, GLenum typein, const void *datain, GLsizei widthout, GLsizei heightout, GLenum typeout, void *dataout)
 
GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint userLevel, GLint baseLevel, GLint maxLevel, const void *data)
 
GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data)
 
static int bitmapBuild2DMipmaps (GLenum target, GLint internalFormat, GLint width, GLint height, GLenum format, GLenum type, const void *data)
 
GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint userLevel, GLint baseLevel, GLint maxLevel, const void *data)
 
GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data)
 
static int gluScaleImage3D (GLenum format, GLint widthIn, GLint heightIn, GLint depthIn, GLenum typeIn, const void *dataIn, GLint widthOut, GLint heightOut, GLint depthOut, GLenum typeOut, void *dataOut)
 
static void closestFit3D (GLenum target, GLint width, GLint height, GLint depth, GLint internalFormat, GLenum format, GLenum type, GLint *newWidth, GLint *newHeight, GLint *newDepth)
 
static void halveImagePackedPixelSlice (int components, void(*extractPackedPixel)(int, const void *, GLfloat[]), void(*shovePackedPixel)(const GLfloat[], int, void *), GLint width, GLint height, GLint depth, const void *dataIn, void *dataOut, GLint pixelSizeInBytes, GLint rowSizeInBytes, GLint imageSizeInBytes, GLint isSwap)
 
static void halveImagePackedPixel3D (int components, void(*extractPackedPixel)(int, const void *, GLfloat[]), void(*shovePackedPixel)(const GLfloat[], int, void *), GLint width, GLint height, GLint depth, const void *dataIn, void *dataOut, GLint pixelSizeInBytes, GLint rowSizeInBytes, GLint imageSizeInBytes, GLint isSwap)
 
GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint userLevel, GLint baseLevel, GLint maxLevel, const void *data)
 
GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data)
 

Macro Definition Documentation

◆ __GLU_INIT_SWAP_IMAGE

#define __GLU_INIT_SWAP_IMAGE   void *tmpImage

Definition at line 3799 of file mipmap.c.

◆ __GLU_SWAP_2_BYTES

#define __GLU_SWAP_2_BYTES (   s)    (GLushort)(((GLushort)((const GLubyte*)(s))[1])<<8 | ((const GLubyte*)(s))[0])

Definition at line 331 of file mipmap.c.

◆ __GLU_SWAP_4_BYTES

#define __GLU_SWAP_4_BYTES (   s)
Value:
(GLuint)(((GLuint)((const GLubyte*)(s))[3])<<24 | \
((GLuint)((const GLubyte*)(s))[2])<<16 | \
((GLuint)((const GLubyte*)(s))[1])<<8 | ((const GLubyte*)(s))[0])
unsigned char GLubyte
Definition: gl.h:157
GLdouble s
Definition: gl.h:2039
unsigned int GLuint
Definition: gl.h:159

Definition at line 334 of file mipmap.c.

◆ __GLU_SWAP_IMAGE

#define __GLU_SWAP_IMAGE (   a,
  b 
)    tmpImage = a; a = b; b = tmpImage;

Definition at line 3800 of file mipmap.c.

◆ BOX2 [1/12]

#define BOX2   2

◆ BOX2 [2/12]

#define BOX2   2

◆ BOX2 [3/12]

#define BOX2   2

◆ BOX2 [4/12]

#define BOX2   2

◆ BOX2 [5/12]

#define BOX2   2

◆ BOX2 [6/12]

#define BOX2   2

◆ BOX2 [7/12]

#define BOX2   2

◆ BOX2 [8/12]

#define BOX2   2

◆ BOX2 [9/12]

#define BOX2   2

◆ BOX2 [10/12]

#define BOX2   2

◆ BOX2 [11/12]

#define BOX2   2

◆ BOX2 [12/12]

#define BOX2   2

◆ BOX4

#define BOX4   4

◆ BOX8 [1/2]

#define BOX8   8

◆ BOX8 [2/2]

#define BOX8   8

◆ gluTexImage3D

#define gluTexImage3D   glTexImage3D

Definition at line 6669 of file mipmap.c.

Function Documentation

◆ bitmapBuild2DMipmaps()

static int bitmapBuild2DMipmaps ( GLenum  target,
GLint  internalFormat,
GLint  width,
GLint  height,
GLenum  format,
GLenum  type,
const void data 
)
static

Definition at line 3696 of file mipmap.c.

3699{
3700 GLint newwidth, newheight;
3702 GLushort *newImage;
3703 GLint newImage_width;
3704 GLint newImage_height;
3705 GLushort *otherImage;
3706 GLushort *imageTemp;
3707 GLint memreq;
3708 GLint cmpts;
3710
3711 retrieveStoreModes(&psm);
3712
3713#if 0
3715 newwidth = nearestPower(width);
3716 if (newwidth > maxsize) newwidth = maxsize;
3717 newheight = nearestPower(height);
3718 if (newheight > maxsize) newheight = maxsize;
3719#else
3721 &newwidth,&newheight);
3722#endif
3723 levels = computeLog(newwidth);
3724 level = computeLog(newheight);
3725 if (level > levels) levels=level;
3726
3727 otherImage = NULL;
3728 newImage = (GLushort *)
3730 newImage_width = width;
3731 newImage_height = height;
3732 if (newImage == NULL) {
3733 return GLU_OUT_OF_MEMORY;
3734 }
3735
3737 data, newImage);
3738
3744 /*
3745 ** If swap_bytes was set, swapping occurred in fill_image.
3746 */
3748
3749 for (level = 0; level <= levels; level++) {
3750 if (newImage_width == newwidth && newImage_height == newheight) { /* Use newImage for this level */
3751 glTexImage2D(target, level, internalFormat, newImage_width,
3752 newImage_height, 0, format, GL_UNSIGNED_SHORT,
3753 (void *) newImage);
3754 } else {
3755 if (otherImage == NULL) {
3756 memreq =
3757 image_size(newwidth, newheight, format, GL_UNSIGNED_SHORT);
3758 otherImage = (GLushort *) malloc(memreq);
3759 if (otherImage == NULL) {
3765 free(newImage);
3766 return GLU_OUT_OF_MEMORY;
3767 }
3768 }
3769 scale_internal(cmpts, newImage_width, newImage_height, newImage,
3770 newwidth, newheight, otherImage);
3771 /* Swap newImage and otherImage */
3772 imageTemp = otherImage;
3773 otherImage = newImage;
3774 newImage = imageTemp;
3775
3776 newImage_width = newwidth;
3777 newImage_height = newheight;
3778 glTexImage2D(target, level, internalFormat, newImage_width,
3779 newImage_height, 0, format, GL_UNSIGNED_SHORT,
3780 (void *) newImage);
3781 }
3782 if (newwidth > 1) newwidth /= 2;
3783 if (newheight > 1) newheight /= 2;
3784 }
3790
3791 free((GLbyte *) newImage);
3792 if (otherImage) {
3793 free((GLbyte *) otherImage);
3794 }
3795 return 0;
3796}
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define GLU_OUT_OF_MEMORY
Definition: glu.h:90
signed char GLbyte
Definition: gl.h:154
#define GL_MAX_TEXTURE_SIZE
Definition: gl.h:510
#define GL_UNPACK_SWAP_BYTES
Definition: gl.h:637
GLint level
Definition: gl.h:1546
GLAPI void GLAPIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_UNSIGNED_SHORT
Definition: gl.h:180
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define GL_UNPACK_SKIP_PIXELS
Definition: gl.h:635
#define GL_UNPACK_ALIGNMENT
Definition: gl.h:632
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define GL_UNPACK_SKIP_ROWS
Definition: gl.h:636
#define GL_FALSE
Definition: gl.h:173
unsigned short GLushort
Definition: gl.h:158
int GLint
Definition: gl.h:156
GLint GLint GLsizei width
Definition: gl.h:1546
GLAPI void GLAPIENTRY glPixelStorei(GLenum pname, GLint param)
GLAPI void GLAPIENTRY glGetIntegerv(GLenum pname, GLint *params)
#define GL_UNPACK_ROW_LENGTH
Definition: gl.h:634
GLsizei levels
Definition: glext.h:7884
GLenum internalFormat
Definition: glext.h:8404
GLenum target
Definition: glext.h:7315
static void scale_internal(GLint components, GLint widthin, GLint heightin, const GLushort *datain, GLint widthout, GLint heightout, GLushort *dataout)
Definition: mipmap.c:1289
static int nearestPower(GLuint value)
Definition: mipmap.c:311
static GLint elements_per_group(GLenum format, GLenum type)
Definition: mipmap.c:4770
static int computeLog(GLuint value)
Definition: mipmap.c:287
static GLint is_index(GLenum format)
Definition: mipmap.c:4849
static void fill_image(const PixelStorageModes *, GLint width, GLint height, GLenum format, GLenum type, GLboolean index_format, const void *userdata, GLushort *newimage)
Definition: mipmap.c:4878
static void retrieveStoreModes(PixelStorageModes *psm)
Definition: mipmap.c:249
static void closestFit(GLenum, GLint, GLint, GLint, GLenum, GLenum, GLint *, GLint *)
Definition: mipmap.c:3410
static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
Definition: mipmap.c:4858
GLint unpack_skip_pixels
Definition: mipmap.c:64
GLint unpack_skip_rows
Definition: mipmap.c:63
GLint unpack_row_length
Definition: mipmap.c:62
GLint unpack_swap_bytes
Definition: mipmap.c:66
GLint unpack_alignment
Definition: mipmap.c:61

Referenced by gluBuild2DMipmapLevelsCore().

◆ bytes_per_element()

static GLfloat bytes_per_element ( GLenum  type)
static

Definition at line 4807 of file mipmap.c.

4808{
4809 /*
4810 * Return the number of bytes per element, based on the element type
4811 */
4812 switch(type) {
4813 case GL_BITMAP:
4814 return 1.0 / 8.0;
4815 case GL_UNSIGNED_SHORT:
4816 return(sizeof(GLushort));
4817 case GL_SHORT:
4818 return(sizeof(GLshort));
4819 case GL_UNSIGNED_BYTE:
4820 return(sizeof(GLubyte));
4821 case GL_BYTE:
4822 return(sizeof(GLbyte));
4823 case GL_INT:
4824 return(sizeof(GLint));
4825 case GL_UNSIGNED_INT:
4826 return(sizeof(GLuint));
4827 case GL_FLOAT:
4828 return(sizeof(GLfloat));
4831 return(sizeof(GLubyte));
4838 return(sizeof(GLushort));
4843 return(sizeof(GLuint));
4844 default:
4845 return 4;
4846 }
4847}
#define GL_INT
Definition: gl.h:181
short GLshort
Definition: gl.h:155
#define GL_UNSIGNED_SHORT_4_4_4_4_REV
Definition: gl.h:1491
float GLfloat
Definition: gl.h:161
#define GL_UNSIGNED_SHORT_5_6_5_REV
Definition: gl.h:1489
#define GL_UNSIGNED_INT_10_10_10_2
Definition: gl.h:1496
#define GL_UNSIGNED_SHORT_5_5_5_1
Definition: gl.h:1492
#define GL_BYTE
Definition: gl.h:177
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define GL_BITMAP
Definition: gl.h:497
#define GL_FLOAT
Definition: gl.h:183
#define GL_SHORT
Definition: gl.h:179
#define GL_UNSIGNED_BYTE
Definition: gl.h:178
#define GL_UNSIGNED_INT_8_8_8_8
Definition: gl.h:1494
#define GL_UNSIGNED_BYTE_3_3_2
Definition: gl.h:1486
#define GL_UNSIGNED_SHORT_4_4_4_4
Definition: gl.h:1490
#define GL_UNSIGNED_SHORT_1_5_5_5_REV
Definition: gl.h:1493
#define GL_UNSIGNED_INT_8_8_8_8_REV
Definition: gl.h:1495
#define GL_UNSIGNED_BYTE_2_3_3_REV
Definition: gl.h:1487
#define GL_UNSIGNED_SHORT_5_6_5
Definition: gl.h:1488
#define GL_UNSIGNED_INT_2_10_10_10_REV
Definition: gl.h:1497

Referenced by empty_image(), emptyImage3D(), fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), gluBuild3DMipmapLevelsCore(), image_size(), and imageSize3D().

◆ checkMipmapArgs()

static int checkMipmapArgs ( GLenum  internalFormat,
GLenum  format,
GLenum  type 
)
static

Definition at line 3270 of file mipmap.c.

3271{
3272 if (!legalFormat(format) || !legalType(type)) {
3273 return GLU_INVALID_ENUM;
3274 }
3275 if (format == GL_STENCIL_INDEX) {
3276 return GLU_INVALID_ENUM;
3277 }
3278
3280 return GLU_INVALID_OPERATION;
3281 }
3282
3283 return 0;
3284} /* checkMipmapArgs() */
#define GLU_INVALID_ENUM
Definition: glu.h:88
#define GLU_INVALID_OPERATION
Definition: glu.h:92
#define GL_STENCIL_INDEX
Definition: gl.h:458
static GLboolean isLegalFormatForPackedPixelType(GLenum, GLenum)
Definition: mipmap.c:3361
static GLboolean legalFormat(GLenum)
Definition: mipmap.c:3286
static GLboolean legalType(GLenum)
Definition: mipmap.c:3309

Referenced by gluBuild1DMipmapLevels(), gluBuild1DMipmapLevelsCore(), gluBuild1DMipmaps(), gluBuild2DMipmapLevels(), gluBuild2DMipmapLevelsCore(), gluBuild2DMipmaps(), gluBuild3DMipmapLevels(), gluBuild3DMipmapLevelsCore(), and gluBuild3DMipmaps().

◆ closestFit()

static void closestFit ( GLenum  target,
GLint  width,
GLint  height,
GLint  internalFormat,
GLenum  format,
GLenum  type,
GLint newWidth,
GLint newHeight 
)
static

Definition at line 3410 of file mipmap.c.

3413{
3414 /* Use proxy textures if OpenGL version is >= 1.1 */
3415 if ( (strtod((const char *)glGetString(GL_VERSION),NULL) >= 1.1)
3416 ) {
3417 GLint widthPowerOf2= nearestPower(width);
3418 GLint heightPowerOf2= nearestPower(height);
3419 GLint proxyWidth;
3420
3421 do {
3422 /* compute level 1 width & height, clamping each at 1 */
3423 GLint widthAtLevelOne= (widthPowerOf2 > 1) ?
3424 widthPowerOf2 >> 1 :
3425 widthPowerOf2;
3426 GLint heightAtLevelOne= (heightPowerOf2 > 1) ?
3427 heightPowerOf2 >> 1 :
3428 heightPowerOf2;
3429 GLenum proxyTarget;
3430 assert(widthAtLevelOne > 0); assert(heightAtLevelOne > 0);
3431
3432 /* does width x height at level 1 & all their mipmaps fit? */
3434 proxyTarget = GL_PROXY_TEXTURE_2D;
3435 glTexImage2D(proxyTarget, 1, /* must be non-zero */
3437 widthAtLevelOne,heightAtLevelOne,0,format,type,NULL);
3438 } else
3439#if defined(GL_ARB_texture_cube_map)
3446 proxyTarget = GL_PROXY_TEXTURE_CUBE_MAP_ARB;
3447 glTexImage2D(proxyTarget, 1, /* must be non-zero */
3449 widthAtLevelOne,heightAtLevelOne,0,format,type,NULL);
3450 } else
3451#endif /* GL_ARB_texture_cube_map */
3452 {
3454 proxyTarget = GL_PROXY_TEXTURE_1D;
3455 glTexImage1D(proxyTarget, 1, /* must be non-zero */
3456 internalFormat,widthAtLevelOne,0,format,type,NULL);
3457 }
3458 glGetTexLevelParameteriv(proxyTarget, 1,GL_TEXTURE_WIDTH,&proxyWidth);
3459 /* does it fit??? */
3460 if (proxyWidth == 0) { /* nope, so try again with these sizes */
3461 if (widthPowerOf2 == 1 && heightPowerOf2 == 1) {
3462 /* An 1x1 texture couldn't fit for some reason, so
3463 * break out. This should never happen. But things
3464 * happen. The disadvantage with this if-statement is
3465 * that we will never be aware of when this happens
3466 * since it will silently branch out.
3467 */
3468 goto noProxyTextures;
3469 }
3470 widthPowerOf2= widthAtLevelOne;
3471 heightPowerOf2= heightAtLevelOne;
3472 }
3473 /* else it does fit */
3474 } while (proxyWidth == 0);
3475 /* loop must terminate! */
3476
3477 /* return the width & height at level 0 that fits */
3478 *newWidth= widthPowerOf2;
3479 *newHeight= heightPowerOf2;
3480/*printf("Proxy Textures\n");*/
3481 } /* if gluCheckExtension() */
3482 else { /* no texture extension, so do this instead */
3483 GLint maxsize;
3484
3485noProxyTextures:
3486
3488 /* clamp user's texture sizes to maximum sizes, if necessary */
3489 *newWidth = nearestPower(width);
3490 if (*newWidth > maxsize) *newWidth = maxsize;
3491 *newHeight = nearestPower(height);
3492 if (*newHeight > maxsize) *newHeight = maxsize;
3493/*printf("NO proxy textures\n");*/
3494 }
3495} /* closestFit() */
#define assert(x)
Definition: debug.h:53
#define GL_TEXTURE_WIDTH
Definition: gl.h:657
GLAPI void GLAPIENTRY glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint *params)
#define GL_VERSION
Definition: gl.h:689
#define GL_PROXY_TEXTURE_2D
Definition: gl.h:727
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_2D
Definition: gl.h:645
GLAPI void GLAPIENTRY glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_PROXY_TEXTURE_1D
Definition: gl.h:726
GLAPI const GLubyte *GLAPIENTRY glGetString(GLenum name)
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
Definition: glext.h:1237
#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
Definition: glext.h:1232
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB
Definition: glext.h:1234
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB
Definition: glext.h:1235
#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB
Definition: glext.h:1236
#define GL_PROXY_TEXTURE_CUBE_MAP_ARB
Definition: glext.h:1238
#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB
Definition: glext.h:1233
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)

Referenced by bitmapBuild2DMipmaps(), gluBuild1DMipmaps(), and gluBuild2DMipmaps().

◆ closestFit3D()

static void closestFit3D ( GLenum  target,
GLint  width,
GLint  height,
GLint  depth,
GLint  internalFormat,
GLenum  format,
GLenum  type,
GLint newWidth,
GLint newHeight,
GLint newDepth 
)
static

Definition at line 7412 of file mipmap.c.

7415{
7416 GLint widthPowerOf2= nearestPower(width);
7417 GLint heightPowerOf2= nearestPower(height);
7418 GLint depthPowerOf2= nearestPower(depth);
7419 GLint proxyWidth;
7420
7421 do {
7422 /* compute level 1 width & height & depth, clamping each at 1 */
7423 GLint widthAtLevelOne= (widthPowerOf2 > 1) ?
7424 widthPowerOf2 >> 1 :
7425 widthPowerOf2;
7426 GLint heightAtLevelOne= (heightPowerOf2 > 1) ?
7427 heightPowerOf2 >> 1 :
7428 heightPowerOf2;
7429 GLint depthAtLevelOne= (depthPowerOf2 > 1) ?
7430 depthPowerOf2 >> 1 :
7431 depthPowerOf2;
7432 GLenum proxyTarget = GL_PROXY_TEXTURE_3D;
7433 assert(widthAtLevelOne > 0);
7434 assert(heightAtLevelOne > 0);
7435 assert(depthAtLevelOne > 0);
7436
7437 /* does width x height x depth at level 1 & all their mipmaps fit? */
7439 gluTexImage3D(proxyTarget, 1, /* must be non-zero */
7441 widthAtLevelOne,heightAtLevelOne,depthAtLevelOne,
7442 0,format,type,NULL);
7443 glGetTexLevelParameteriv(proxyTarget, 1,GL_TEXTURE_WIDTH,&proxyWidth);
7444 /* does it fit??? */
7445 if (proxyWidth == 0) { /* nope, so try again with these sizes */
7446 if (widthPowerOf2 == 1 && heightPowerOf2 == 1 &&
7447 depthPowerOf2 == 1) {
7448 *newWidth= *newHeight= *newDepth= 1; /* must fit 1x1x1 texture */
7449 return;
7450 }
7451 widthPowerOf2= widthAtLevelOne;
7452 heightPowerOf2= heightAtLevelOne;
7453 depthPowerOf2= depthAtLevelOne;
7454 }
7455 /* else it does fit */
7456 } while (proxyWidth == 0);
7457 /* loop must terminate! */
7458
7459 /* return the width & height at level 0 that fits */
7460 *newWidth= widthPowerOf2;
7461 *newHeight= heightPowerOf2;
7462 *newDepth= depthPowerOf2;
7463/*printf("Proxy Textures\n");*/
7464} /* closestFit3D() */
#define GL_PROXY_TEXTURE_3D
Definition: gl.h:1516
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define gluTexImage3D
Definition: mipmap.c:6669

Referenced by gluBuild3DMipmaps().

◆ computeLog()

static int computeLog ( GLuint  value)
static

Definition at line 287 of file mipmap.c.

288{
289 int i;
290
291 i = 0;
292
293 /* Error! */
294 if (value == 0) return -1;
295
296 for (;;) {
297 if (value & 1) {
298 /* Error ! */
299 if (value != 1) return -1;
300 return i;
301 }
302 value = value >> 1;
303 i++;
304 }
305}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
Definition: pdh_main.c:94

Referenced by bitmapBuild2DMipmaps(), gluBuild1DMipmapLevels(), gluBuild1DMipmapLevelsCore(), gluBuild1DMipmaps(), gluBuild2DMipmapLevels(), gluBuild2DMipmapLevelsCore(), gluBuild2DMipmaps(), gluBuild3DMipmapLevels(), gluBuild3DMipmapLevelsCore(), and gluBuild3DMipmaps().

◆ elements_per_group()

static GLint elements_per_group ( GLenum  format,
GLenum  type 
)
static

Definition at line 4770 of file mipmap.c.

4771{
4772 /*
4773 * Return the number of elements per group of a specified format
4774 */
4775
4776 /* If the type is packedpixels then answer is 1 (ignore format) */
4789 return 1;
4790 }
4791
4792 /* Types are not packed pixels, so get elements per group */
4793 switch(format) {
4794 case GL_RGB:
4795 case GL_BGR:
4796 return 3;
4797 case GL_LUMINANCE_ALPHA:
4798 return 2;
4799 case GL_RGBA:
4800 case GL_BGRA:
4801 return 4;
4802 default:
4803 return 1;
4804 }
4805}
#define GL_BGR
Definition: gl.h:1484
#define GL_LUMINANCE_ALPHA
Definition: gl.h:485
#define GL_BGRA
Definition: gl.h:1485
#define GL_RGB
Definition: gl.h:502
#define GL_RGBA
Definition: gl.h:503

Referenced by bitmapBuild2DMipmaps(), empty_image(), emptyImage3D(), fill_image(), fillImage3D(), gluBuild1DMipmapLevelsCore(), gluBuild2DMipmapLevelsCore(), gluBuild3DMipmapLevelsCore(), gluScaleImage(), gluScaleImage3D(), image_size(), and imageSize3D().

◆ empty_image()

static void empty_image ( const PixelStorageModes psm,
GLint  width,
GLint  height,
GLenum  format,
GLenum  type,
GLboolean  index_format,
const GLushort oldimage,
void userdata 
)
static

Definition at line 5141 of file mipmap.c.

5145{
5147 GLint element_size;
5148 GLint rowsize;
5149 GLint padding;
5150 GLint groups_per_line;
5151 GLint group_size;
5152 GLint elements_per_line;
5153 GLubyte *start;
5154 GLubyte *iter;
5155 const GLushort *iter2;
5156 GLint i, j, k;
5157 GLint myswap_bytes;
5158
5159 myswap_bytes = psm->pack_swap_bytes;
5161 if (psm->pack_row_length > 0) {
5162 groups_per_line = psm->pack_row_length;
5163 } else {
5164 groups_per_line = width;
5165 }
5166
5167 /* All formats except GL_BITMAP fall out trivially */
5168 if (type == GL_BITMAP) {
5169 GLint bit_offset;
5170 GLint current_bit;
5171
5172 rowsize = (groups_per_line * components + 7) / 8;
5173 padding = (rowsize % psm->pack_alignment);
5174 if (padding) {
5175 rowsize += psm->pack_alignment - padding;
5176 }
5177 start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize +
5178 (psm->pack_skip_pixels * components / 8);
5179 elements_per_line = width * components;
5180 iter2 = oldimage;
5181 for (i = 0; i < height; i++) {
5182 iter = start;
5183 bit_offset = (psm->pack_skip_pixels * components) % 8;
5184 for (j = 0; j < elements_per_line; j++) {
5185 if (index_format) {
5186 current_bit = iter2[0] & 1;
5187 } else {
5188 if (iter2[0] > 32767) {
5189 current_bit = 1;
5190 } else {
5191 current_bit = 0;
5192 }
5193 }
5194
5195 if (current_bit) {
5196 if (psm->pack_lsb_first) {
5197 *iter |= (1 << bit_offset);
5198 } else {
5199 *iter |= (1 << (7 - bit_offset));
5200 }
5201 } else {
5202 if (psm->pack_lsb_first) {
5203 *iter &= ~(1 << bit_offset);
5204 } else {
5205 *iter &= ~(1 << (7 - bit_offset));
5206 }
5207 }
5208
5209 bit_offset++;
5210 if (bit_offset == 8) {
5211 bit_offset = 0;
5212 iter++;
5213 }
5214 iter2++;
5215 }
5216 start += rowsize;
5217 }
5218 } else {
5219 float shoveComponents[4];
5220
5221 element_size = bytes_per_element(type);
5222 group_size = element_size * components;
5223 if (element_size == 1) myswap_bytes = 0;
5224
5225 rowsize = groups_per_line * group_size;
5226 padding = (rowsize % psm->pack_alignment);
5227 if (padding) {
5228 rowsize += psm->pack_alignment - padding;
5229 }
5230 start = (GLubyte *) userdata + psm->pack_skip_rows * rowsize +
5231 psm->pack_skip_pixels * group_size;
5232 elements_per_line = width * components;
5233
5234 iter2 = oldimage;
5235 for (i = 0; i < height; i++) {
5236 iter = start;
5237 for (j = 0; j < elements_per_line; j++) {
5238 Type_Widget widget;
5239
5240 switch(type) {
5242 for (k = 0; k < 3; k++) {
5243 shoveComponents[k]= *iter2++ / 65535.0;
5244 }
5245 shove332(shoveComponents,0,(void *)iter);
5246 break;
5248 for (k = 0; k < 3; k++) {
5249 shoveComponents[k]= *iter2++ / 65535.0;
5250 }
5251 shove233rev(shoveComponents,0,(void *)iter);
5252 break;
5253 case GL_UNSIGNED_BYTE:
5254 if (index_format) {
5255 *iter = *iter2++;
5256 } else {
5257 *iter = *iter2++ >> 8;
5258 }
5259 break;
5260 case GL_BYTE:
5261 if (index_format) {
5262 *((GLbyte *) iter) = *iter2++;
5263 } else {
5264 *((GLbyte *) iter) = *iter2++ >> 9;
5265 }
5266 break;
5268 for (k = 0; k < 3; k++) {
5269 shoveComponents[k]= *iter2++ / 65535.0;
5270 }
5271 shove565(shoveComponents,0,(void *)&widget.us[0]);
5272 if (myswap_bytes) {
5273 iter[0] = widget.ub[1];
5274 iter[1] = widget.ub[0];
5275 }
5276 else {
5277 *(GLushort *)iter = widget.us[0];
5278 }
5279 break;
5281 for (k = 0; k < 3; k++) {
5282 shoveComponents[k]= *iter2++ / 65535.0;
5283 }
5284 shove565rev(shoveComponents,0,(void *)&widget.us[0]);
5285 if (myswap_bytes) {
5286 iter[0] = widget.ub[1];
5287 iter[1] = widget.ub[0];
5288 }
5289 else {
5290 *(GLushort *)iter = widget.us[0];
5291 }
5292 break;
5294 for (k = 0; k < 4; k++) {
5295 shoveComponents[k]= *iter2++ / 65535.0;
5296 }
5297 shove4444(shoveComponents,0,(void *)&widget.us[0]);
5298 if (myswap_bytes) {
5299 iter[0] = widget.ub[1];
5300 iter[1] = widget.ub[0];
5301 } else {
5302 *(GLushort *)iter = widget.us[0];
5303 }
5304 break;
5306 for (k = 0; k < 4; k++) {
5307 shoveComponents[k]= *iter2++ / 65535.0;
5308 }
5309 shove4444rev(shoveComponents,0,(void *)&widget.us[0]);
5310 if (myswap_bytes) {
5311 iter[0] = widget.ub[1];
5312 iter[1] = widget.ub[0];
5313 } else {
5314 *(GLushort *)iter = widget.us[0];
5315 }
5316 break;
5318 for (k = 0; k < 4; k++) {
5319 shoveComponents[k]= *iter2++ / 65535.0;
5320 }
5321 shove5551(shoveComponents,0,(void *)&widget.us[0]);
5322 if (myswap_bytes) {
5323 iter[0] = widget.ub[1];
5324 iter[1] = widget.ub[0];
5325 } else {
5326 *(GLushort *)iter = widget.us[0];
5327 }
5328 break;
5330 for (k = 0; k < 4; k++) {
5331 shoveComponents[k]= *iter2++ / 65535.0;
5332 }
5333 shove1555rev(shoveComponents,0,(void *)&widget.us[0]);
5334 if (myswap_bytes) {
5335 iter[0] = widget.ub[1];
5336 iter[1] = widget.ub[0];
5337 } else {
5338 *(GLushort *)iter = widget.us[0];
5339 }
5340 break;
5341 case GL_UNSIGNED_SHORT:
5342 case GL_SHORT:
5343 if (type == GL_SHORT) {
5344 if (index_format) {
5345 widget.s[0] = *iter2++;
5346 } else {
5347 widget.s[0] = *iter2++ >> 1;
5348 }
5349 } else {
5350 widget.us[0] = *iter2++;
5351 }
5352 if (myswap_bytes) {
5353 iter[0] = widget.ub[1];
5354 iter[1] = widget.ub[0];
5355 } else {
5356 iter[0] = widget.ub[0];
5357 iter[1] = widget.ub[1];
5358 }
5359 break;
5361 for (k = 0; k < 4; k++) {
5362 shoveComponents[k]= *iter2++ / 65535.0;
5363 }
5364 shove8888(shoveComponents,0,(void *)&widget.ui);
5365 if (myswap_bytes) {
5366 iter[3] = widget.ub[0];
5367 iter[2] = widget.ub[1];
5368 iter[1] = widget.ub[2];
5369 iter[0] = widget.ub[3];
5370 } else {
5371 *(GLuint *)iter= widget.ui;
5372 }
5373
5374 break;
5376 for (k = 0; k < 4; k++) {
5377 shoveComponents[k]= *iter2++ / 65535.0;
5378 }
5379 shove8888rev(shoveComponents,0,(void *)&widget.ui);
5380 if (myswap_bytes) {
5381 iter[3] = widget.ub[0];
5382 iter[2] = widget.ub[1];
5383 iter[1] = widget.ub[2];
5384 iter[0] = widget.ub[3];
5385 } else {
5386 *(GLuint *)iter= widget.ui;
5387 }
5388 break;
5390 for (k = 0; k < 4; k++) {
5391 shoveComponents[k]= *iter2++ / 65535.0;
5392 }
5393 shove1010102(shoveComponents,0,(void *)&widget.ui);
5394 if (myswap_bytes) {
5395 iter[3] = widget.ub[0];
5396 iter[2] = widget.ub[1];
5397 iter[1] = widget.ub[2];
5398 iter[0] = widget.ub[3];
5399 } else {
5400 *(GLuint *)iter= widget.ui;
5401 }
5402 break;
5404 for (k = 0; k < 4; k++) {
5405 shoveComponents[k]= *iter2++ / 65535.0;
5406 }
5407 shove2101010rev(shoveComponents,0,(void *)&widget.ui);
5408 if (myswap_bytes) {
5409 iter[3] = widget.ub[0];
5410 iter[2] = widget.ub[1];
5411 iter[1] = widget.ub[2];
5412 iter[0] = widget.ub[3];
5413 } else {
5414 *(GLuint *)iter= widget.ui;
5415 }
5416 break;
5417 case GL_INT:
5418 case GL_UNSIGNED_INT:
5419 case GL_FLOAT:
5420 if (type == GL_FLOAT) {
5421 if (index_format) {
5422 widget.f = *iter2++;
5423 } else {
5424 widget.f = *iter2++ / (float) 65535.0;
5425 }
5426 } else if (type == GL_UNSIGNED_INT) {
5427 if (index_format) {
5428 widget.ui = *iter2++;
5429 } else {
5430 widget.ui = (unsigned int) *iter2++ * 65537;
5431 }
5432 } else {
5433 if (index_format) {
5434 widget.i = *iter2++;
5435 } else {
5436 widget.i = ((unsigned int) *iter2++ * 65537)/2;
5437 }
5438 }
5439 if (myswap_bytes) {
5440 iter[3] = widget.ub[0];
5441 iter[2] = widget.ub[1];
5442 iter[1] = widget.ub[2];
5443 iter[0] = widget.ub[3];
5444 } else {
5445 iter[0] = widget.ub[0];
5446 iter[1] = widget.ub[1];
5447 iter[2] = widget.ub[2];
5448 iter[3] = widget.ub[3];
5449 }
5450 break;
5451 }
5452 iter += element_size;
5453 } /* for j */
5454 start += rowsize;
5455#if 1
5456 /* want 'iter' pointing at start, not within, row for assertion
5457 * purposes
5458 */
5459 iter= start;
5460#endif
5461 } /* for i */
5462
5463 /* iterators should be one byte past end */
5464 if (!isTypePackedPixel(type)) {
5465 assert(iter2 == &oldimage[width*height*components]);
5466 }
5467 else {
5468 assert(iter2 == &oldimage[width*height*
5470 }
5471 assert( iter == &((GLubyte *)userdata)[rowsize*height +
5472 psm->pack_skip_rows * rowsize +
5473 psm->pack_skip_pixels * group_size] );
5474
5475 } /* else */
5476} /* empty_image() */
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLuint start
Definition: gl.h:1545
GLenum GLenum GLuint components
Definition: glext.h:9620
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static void shove565rev(const GLfloat[], int, void *)
Definition: mipmap.c:5616
static void shove8888(const GLfloat[], int, void *)
Definition: mipmap.c:5845
static GLboolean isTypePackedPixel(GLenum)
Definition: mipmap.c:3339
static void shove1010102(const GLfloat[], int, void *)
Definition: mipmap.c:5941
static void shove565(const GLfloat[], int, void *)
Definition: mipmap.c:5575
static void shove1555rev(const GLfloat[], int, void *)
Definition: mipmap.c:5797
static void shove2101010rev(const GLfloat[], int, void *)
Definition: mipmap.c:5991
static GLfloat bytes_per_element(GLenum type)
Definition: mipmap.c:4807
static void shove4444(const GLfloat[], int, void *)
Definition: mipmap.c:5659
static void shove8888rev(const GLfloat[], int, void *)
Definition: mipmap.c:5893
static void shove4444rev(const GLfloat[], int, void *)
Definition: mipmap.c:5702
static void shove233rev(const GLfloat[], int, void *)
Definition: mipmap.c:5534
static void shove332(const GLfloat[], int, void *)
Definition: mipmap.c:5498
static void shove5551(const GLfloat[], int, void *)
Definition: mipmap.c:5749
#define for
Definition: utility.h:88
static const DWORD padding[]
Definition: mciwnd.c:89
static float(__cdecl *square_half_float)(float x
int k
Definition: mpi.c:3369
GLint pack_alignment
Definition: mipmap.c:52
GLint pack_skip_pixels
Definition: mipmap.c:55
GLint pack_skip_rows
Definition: mipmap.c:54
GLint pack_lsb_first
Definition: mipmap.c:56
GLint pack_row_length
Definition: mipmap.c:53
GLint pack_swap_bytes
Definition: mipmap.c:57
unsigned short us[2]
Definition: mipmap.c:42
short s[2]
Definition: mipmap.c:45
int i
Definition: mipmap.c:46
unsigned char ub[4]
Definition: mipmap.c:41
float f
Definition: mipmap.c:47
unsigned int ui
Definition: mipmap.c:43

Referenced by gluScaleImage().

◆ emptyImage3D()

static void emptyImage3D ( const PixelStorageModes psm,
GLint  width,
GLint  height,
GLint  depth,
GLenum  format,
GLenum  type,
GLboolean  indexFormat,
const GLushort oldImage,
void userImage 
)
static

Definition at line 7050 of file mipmap.c.

7054{
7055 int myswapBytes;
7056 int components;
7057 int groupsPerLine;
7058 int elementSize;
7059 int groupSize;
7060 int rowSize;
7061 int padding;
7062 GLubyte *start, *rowStart, *iter;
7063 int elementsPerLine;
7064 const GLushort *iter2;
7065 int ii, jj, dd, k;
7066 int rowsPerImage;
7067 int imageSize;
7068
7069 myswapBytes= psm->pack_swap_bytes;
7071 if (psm->pack_row_length > 0) {
7072 groupsPerLine = psm->pack_row_length;
7073 }
7074 else {
7075 groupsPerLine = width;
7076 }
7077
7078 elementSize= bytes_per_element(type);
7079 groupSize= elementSize * components;
7080 if (elementSize == 1) myswapBytes= 0;
7081
7082 /* 3dstuff begin */
7083 if (psm->pack_image_height > 0) {
7084 rowsPerImage= psm->pack_image_height;
7085 }
7086 else {
7087 rowsPerImage= height;
7088 }
7089
7090 /* 3dstuff end */
7091
7092 rowSize = groupsPerLine * groupSize;
7093 padding = rowSize % psm->pack_alignment;
7094 if (padding) {
7095 rowSize+= psm->pack_alignment - padding;
7096 }
7097
7098 imageSize= rowsPerImage * rowSize; /* 3dstuff */
7099
7100 start = (GLubyte *)userImage + psm->pack_skip_rows * rowSize +
7101 psm->pack_skip_pixels * groupSize +
7102 /*3dstuff*/
7104 elementsPerLine= width * components;
7105
7106 iter2 = oldImage;
7107 for (dd= 0; dd < depth; dd++) {
7108 rowStart= start;
7109
7110 for (ii= 0; ii< height; ii++) {
7111 iter = rowStart;
7112
7113 for (jj = 0; jj < elementsPerLine; jj++) {
7114 Type_Widget widget;
7115 float shoveComponents[4];
7116
7117 switch(type){
7118 case GL_UNSIGNED_BYTE:
7119 if (indexFormat) {
7120 *iter = *iter2++;
7121 } else {
7122 *iter = *iter2++ >> 8;
7123 }
7124 break;
7125 case GL_BYTE:
7126 if (indexFormat) {
7127 *((GLbyte *) iter) = *iter2++;
7128 } else {
7129 *((GLbyte *) iter) = *iter2++ >> 9;
7130 }
7131 break;
7133 for (k = 0; k < 3; k++) {
7134 shoveComponents[k]= *iter2++ / 65535.0;
7135 }
7136 shove332(shoveComponents,0,(void *)iter);
7137 break;
7139 for (k = 0; k < 3; k++) {
7140 shoveComponents[k]= *iter2++ / 65535.0;
7141 }
7142 shove233rev(shoveComponents,0,(void *)iter);
7143 break;
7145 for (k = 0; k < 3; k++) {
7146 shoveComponents[k]= *iter2++ / 65535.0;
7147 }
7148 shove565(shoveComponents,0,(void *)&widget.us[0]);
7149 if (myswapBytes) {
7150 iter[0] = widget.ub[1];
7151 iter[1] = widget.ub[0];
7152 }
7153 else {
7154 *(GLushort *)iter = widget.us[0];
7155 }
7156 break;
7158 for (k = 0; k < 3; k++) {
7159 shoveComponents[k]= *iter2++ / 65535.0;
7160 }
7161 shove565rev(shoveComponents,0,(void *)&widget.us[0]);
7162 if (myswapBytes) {
7163 iter[0] = widget.ub[1];
7164 iter[1] = widget.ub[0];
7165 }
7166 else {
7167 *(GLushort *)iter = widget.us[0];
7168 }
7169 break;
7171 for (k = 0; k < 4; k++) {
7172 shoveComponents[k]= *iter2++ / 65535.0;
7173 }
7174 shove4444(shoveComponents,0,(void *)&widget.us[0]);
7175 if (myswapBytes) {
7176 iter[0] = widget.ub[1];
7177 iter[1] = widget.ub[0];
7178 } else {
7179 *(GLushort *)iter = widget.us[0];
7180 }
7181 break;
7183 for (k = 0; k < 4; k++) {
7184 shoveComponents[k]= *iter2++ / 65535.0;
7185 }
7186 shove4444rev(shoveComponents,0,(void *)&widget.us[0]);
7187 if (myswapBytes) {
7188 iter[0] = widget.ub[1];
7189 iter[1] = widget.ub[0];
7190 } else {
7191 *(GLushort *)iter = widget.us[0];
7192 }
7193 break;
7195 for (k = 0; k < 4; k++) {
7196 shoveComponents[k]= *iter2++ / 65535.0;
7197 }
7198 shove5551(shoveComponents,0,(void *)&widget.us[0]);
7199 if (myswapBytes) {
7200 iter[0] = widget.ub[1];
7201 iter[1] = widget.ub[0];
7202 } else {
7203 *(GLushort *)iter = widget.us[0];
7204 }
7205 break;
7207 for (k = 0; k < 4; k++) {
7208 shoveComponents[k]= *iter2++ / 65535.0;
7209 }
7210 shove1555rev(shoveComponents,0,(void *)&widget.us[0]);
7211 if (myswapBytes) {
7212 iter[0] = widget.ub[1];
7213 iter[1] = widget.ub[0];
7214 } else {
7215 *(GLushort *)iter = widget.us[0];
7216 }
7217 break;
7218 case GL_UNSIGNED_SHORT:
7219 case GL_SHORT:
7220 if (type == GL_SHORT) {
7221 if (indexFormat) {
7222 widget.s[0] = *iter2++;
7223 } else {
7224 widget.s[0] = *iter2++ >> 1;
7225 }
7226 } else {
7227 widget.us[0] = *iter2++;
7228 }
7229 if (myswapBytes) {
7230 iter[0] = widget.ub[1];
7231 iter[1] = widget.ub[0];
7232 } else {
7233 iter[0] = widget.ub[0];
7234 iter[1] = widget.ub[1];
7235 }
7236 break;
7238 for (k = 0; k < 4; k++) {
7239 shoveComponents[k]= *iter2++ / 65535.0;
7240 }
7241 shove8888(shoveComponents,0,(void *)&widget.ui);
7242 if (myswapBytes) {
7243 iter[3] = widget.ub[0];
7244 iter[2] = widget.ub[1];
7245 iter[1] = widget.ub[2];
7246 iter[0] = widget.ub[3];
7247 } else {
7248 *(GLuint *)iter= widget.ui;
7249 }
7250 break;
7252 for (k = 0; k < 4; k++) {
7253 shoveComponents[k]= *iter2++ / 65535.0;
7254 }
7255 shove8888rev(shoveComponents,0,(void *)&widget.ui);
7256 if (myswapBytes) {
7257 iter[3] = widget.ub[0];
7258 iter[2] = widget.ub[1];
7259 iter[1] = widget.ub[2];
7260 iter[0] = widget.ub[3];
7261 } else {
7262 *(GLuint *)iter= widget.ui;
7263 }
7264 break;
7266 for (k = 0; k < 4; k++) {
7267 shoveComponents[k]= *iter2++ / 65535.0;
7268 }
7269 shove1010102(shoveComponents,0,(void *)&widget.ui);
7270 if (myswapBytes) {
7271 iter[3] = widget.ub[0];
7272 iter[2] = widget.ub[1];
7273 iter[1] = widget.ub[2];
7274 iter[0] = widget.ub[3];
7275 } else {
7276 *(GLuint *)iter= widget.ui;
7277 }
7278 break;
7280 for (k = 0; k < 4; k++) {
7281 shoveComponents[k]= *iter2++ / 65535.0;
7282 }
7283 shove2101010rev(shoveComponents,0,(void *)&widget.ui);
7284 if (myswapBytes) {
7285 iter[3] = widget.ub[0];
7286 iter[2] = widget.ub[1];
7287 iter[1] = widget.ub[2];
7288 iter[0] = widget.ub[3];
7289 } else {
7290 *(GLuint *)iter= widget.ui;
7291 }
7292 break;
7293 case GL_INT:
7294 case GL_UNSIGNED_INT:
7295 case GL_FLOAT:
7296 if (type == GL_FLOAT) {
7297 if (indexFormat) {
7298 widget.f = *iter2++;
7299 } else {
7300 widget.f = *iter2++ / (float) 65535.0;
7301 }
7302 } else if (type == GL_UNSIGNED_INT) {
7303 if (indexFormat) {
7304 widget.ui = *iter2++;
7305 } else {
7306 widget.ui = (unsigned int) *iter2++ * 65537;
7307 }
7308 } else {
7309 if (indexFormat) {
7310 widget.i = *iter2++;
7311 } else {
7312 widget.i = ((unsigned int) *iter2++ * 65537)/2;
7313 }
7314 }
7315 if (myswapBytes) {
7316 iter[3] = widget.ub[0];
7317 iter[2] = widget.ub[1];
7318 iter[1] = widget.ub[2];
7319 iter[0] = widget.ub[3];
7320 } else {
7321 iter[0] = widget.ub[0];
7322 iter[1] = widget.ub[1];
7323 iter[2] = widget.ub[2];
7324 iter[3] = widget.ub[3];
7325 }
7326 break;
7327 default:
7328 assert(0);
7329 }
7330
7331 iter+= elementSize;
7332 } /* for jj */
7333
7334 rowStart+= rowSize;
7335 } /* for ii */
7336
7337 start+= imageSize;
7338 } /* for dd */
7339
7340 /* iterators should be one byte past end */
7341 if (!isTypePackedPixel(type)) {
7342 assert(iter2 == &oldImage[width*height*depth*components]);
7343 }
7344 else {
7345 assert(iter2 == &oldImage[width*height*depth*
7347 }
7348 assert( iter == &((GLubyte *)userImage)[rowSize*height*depth +
7349 psm->unpack_skip_rows * rowSize +
7350 psm->unpack_skip_pixels * groupSize +
7351 /*3dstuff*/
7352 psm->unpack_skip_images * imageSize] );
7353} /* emptyImage3D() */
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei imageSize
Definition: gl.h:1950
GLint pack_skip_images
Definition: mipmap.c:58
GLint unpack_skip_images
Definition: mipmap.c:67
GLint pack_image_height
Definition: mipmap.c:59

Referenced by gluScaleImage3D().

◆ extract1010102()

static void extract1010102 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5917 of file mipmap.c.

5919{
5920 GLuint uint;
5921
5922 if (isSwap) {
5923 uint= __GLU_SWAP_4_BYTES(packedPixel);
5924 }
5925 else {
5926 uint= *(const GLuint *)packedPixel;
5927 }
5928
5929 /* 11111111,11000000,00000000,00000000 == 0xffc00000 */
5930 /* 00000000,00111111,11110000,00000000 == 0x003ff000 */
5931 /* 00000000,00000000,00001111,11111100 == 0x00000ffc */
5932 /* 00000000,00000000,00000000,00000011 == 0x00000003 */
5933
5934 /* 1023 = 2^10-1 */
5935 extractComponents[0]= (float)((uint & 0xffc00000) >> 22) / 1023.0;
5936 extractComponents[1]= (float)((uint & 0x003ff000) >> 12) / 1023.0;
5937 extractComponents[2]= (float)((uint & 0x00000ffc) >> 2) / 1023.0;
5938 extractComponents[3]= (float)((uint & 0x00000003) ) / 3.0;
5939} /* extract1010102() */
UINT32 uint
Definition: types.h:83
#define __GLU_SWAP_4_BYTES(s)
Definition: mipmap.c:334

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract1555rev()

static void extract1555rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5773 of file mipmap.c.

5775{
5777
5778 if (isSwap) {
5779 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5780 }
5781 else {
5782 ushort= *(const GLushort *)packedPixel;
5783 }
5784
5785 /* 00000000,00011111 == 0x001F */
5786 /* 00000011,11100000 == 0x03E0 */
5787 /* 01111100,00000000 == 0x7C00 */
5788 /* 10000000,00000000 == 0x8000 */
5789
5790 /* 31 = 2^5-1 */
5791 extractComponents[0]= (float)((ushort & 0x001F) ) / 31.0;
5792 extractComponents[1]= (float)((ushort & 0x03E0) >> 5) / 31.0;
5793 extractComponents[2]= (float)((ushort & 0x7C00) >> 10) / 31.0;
5794 extractComponents[3]= (float)((ushort & 0x8000) >> 15);
5795} /* extract1555rev() */
unsigned short ushort
Definition: linux.h:273
#define __GLU_SWAP_2_BYTES(s)
Definition: mipmap.c:331

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract2101010rev()

static void extract2101010rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5965 of file mipmap.c.

5968{
5969 GLuint uint;
5970
5971 if (isSwap) {
5972 uint= __GLU_SWAP_4_BYTES(packedPixel);
5973 }
5974 else {
5975 uint= *(const GLuint *)packedPixel;
5976 }
5977
5978 /* 00000000,00000000,00000011,11111111 == 0x000003FF */
5979 /* 00000000,00001111,11111100,00000000 == 0x000FFC00 */
5980 /* 00111111,11110000,00000000,00000000 == 0x3FF00000 */
5981 /* 11000000,00000000,00000000,00000000 == 0xC0000000 */
5982
5983 /* 1023 = 2^10-1 */
5984 extractComponents[0]= (float)((uint & 0x000003FF) ) / 1023.0;
5985 extractComponents[1]= (float)((uint & 0x000FFC00) >> 10) / 1023.0;
5986 extractComponents[2]= (float)((uint & 0x3FF00000) >> 20) / 1023.0;
5987 extractComponents[3]= (float)((uint & 0xC0000000) >> 30) / 3.0;
5988 /* 3 = 2^2-1 */
5989} /* extract2101010rev() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract233rev()

static void extract233rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5518 of file mipmap.c.

5520{
5521 GLubyte ubyte= *(const GLubyte *)packedPixel;
5522
5523 isSwap= isSwap; /* turn off warnings */
5524
5525 /* 0000,0111 == 0x07 */
5526 /* 0011,1000 == 0x38 */
5527 /* 1100,0000 == 0xC0 */
5528
5529 extractComponents[0]= (float)((ubyte & 0x07) ) / 7.0;
5530 extractComponents[1]= (float)((ubyte & 0x38) >> 3) / 7.0;
5531 extractComponents[2]= (float)((ubyte & 0xC0) >> 6) / 3.0;
5532} /* extract233rev() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract332()

static void extract332 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5482 of file mipmap.c.

5484{
5485 GLubyte ubyte= *(const GLubyte *)packedPixel;
5486
5487 isSwap= isSwap; /* turn off warnings */
5488
5489 /* 11100000 == 0xe0 */
5490 /* 00011100 == 0x1c */
5491 /* 00000011 == 0x03 */
5492
5493 extractComponents[0]= (float)((ubyte & 0xe0) >> 5) / 7.0;
5494 extractComponents[1]= (float)((ubyte & 0x1c) >> 2) / 7.0; /* 7 = 2^3-1 */
5495 extractComponents[2]= (float)((ubyte & 0x03) ) / 3.0; /* 3 = 2^2-1 */
5496} /* extract332() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract4444()

static void extract4444 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5636 of file mipmap.c.

5638{
5640
5641 if (isSwap) {
5642 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5643 }
5644 else {
5645 ushort= *(const GLushort *)packedPixel;
5646 }
5647
5648 /* 11110000,00000000 == 0xf000 */
5649 /* 00001111,00000000 == 0x0f00 */
5650 /* 00000000,11110000 == 0x00f0 */
5651 /* 00000000,00001111 == 0x000f */
5652
5653 extractComponents[0]= (float)((ushort & 0xf000) >> 12) / 15.0;/* 15=2^4-1 */
5654 extractComponents[1]= (float)((ushort & 0x0f00) >> 8) / 15.0;
5655 extractComponents[2]= (float)((ushort & 0x00f0) >> 4) / 15.0;
5656 extractComponents[3]= (float)((ushort & 0x000f) ) / 15.0;
5657} /* extract4444() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract4444rev()

static void extract4444rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5678 of file mipmap.c.

5680{
5682
5683 if (isSwap) {
5684 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5685 }
5686 else {
5687 ushort= *(const GLushort *)packedPixel;
5688 }
5689
5690 /* 00000000,00001111 == 0x000f */
5691 /* 00000000,11110000 == 0x00f0 */
5692 /* 00001111,00000000 == 0x0f00 */
5693 /* 11110000,00000000 == 0xf000 */
5694
5695 /* 15 = 2^4-1 */
5696 extractComponents[0]= (float)((ushort & 0x000F) ) / 15.0;
5697 extractComponents[1]= (float)((ushort & 0x00F0) >> 4) / 15.0;
5698 extractComponents[2]= (float)((ushort & 0x0F00) >> 8) / 15.0;
5699 extractComponents[3]= (float)((ushort & 0xF000) >> 12) / 15.0;
5700} /* extract4444rev() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract5551()

static void extract5551 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5726 of file mipmap.c.

5728{
5730
5731 if (isSwap) {
5732 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5733 }
5734 else {
5735 ushort= *(const GLushort *)packedPixel;
5736 }
5737
5738 /* 11111000,00000000 == 0xf800 */
5739 /* 00000111,11000000 == 0x07c0 */
5740 /* 00000000,00111110 == 0x003e */
5741 /* 00000000,00000001 == 0x0001 */
5742
5743 extractComponents[0]=(float)((ushort & 0xf800) >> 11) / 31.0;/* 31 = 2^5-1*/
5744 extractComponents[1]=(float)((ushort & 0x07c0) >> 6) / 31.0;
5745 extractComponents[2]=(float)((ushort & 0x003e) >> 1) / 31.0;
5746 extractComponents[3]=(float)((ushort & 0x0001) );
5747} /* extract5551() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract565()

static void extract565 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5554 of file mipmap.c.

5556{
5558
5559 if (isSwap) {
5560 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5561 }
5562 else {
5563 ushort= *(const GLushort *)packedPixel;
5564 }
5565
5566 /* 11111000,00000000 == 0xf800 */
5567 /* 00000111,11100000 == 0x07e0 */
5568 /* 00000000,00011111 == 0x001f */
5569
5570 extractComponents[0]=(float)((ushort & 0xf800) >> 11) / 31.0;/* 31 = 2^5-1*/
5571 extractComponents[1]=(float)((ushort & 0x07e0) >> 5) / 63.0;/* 63 = 2^6-1*/
5572 extractComponents[2]=(float)((ushort & 0x001f) ) / 31.0;
5573} /* extract565() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract565rev()

static void extract565rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5595 of file mipmap.c.

5597{
5599
5600 if (isSwap) {
5601 ushort= __GLU_SWAP_2_BYTES(packedPixel);
5602 }
5603 else {
5604 ushort= *(const GLushort *)packedPixel;
5605 }
5606
5607 /* 00000000,00011111 == 0x001f */
5608 /* 00000111,11100000 == 0x07e0 */
5609 /* 11111000,00000000 == 0xf800 */
5610
5611 extractComponents[0]= (float)((ushort & 0x001F) ) / 31.0;
5612 extractComponents[1]= (float)((ushort & 0x07E0) >> 5) / 63.0;
5613 extractComponents[2]= (float)((ushort & 0xF800) >> 11) / 31.0;
5614} /* extract565rev() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract8888()

static void extract8888 ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5821 of file mipmap.c.

5823{
5824 GLuint uint;
5825
5826 if (isSwap) {
5827 uint= __GLU_SWAP_4_BYTES(packedPixel);
5828 }
5829 else {
5830 uint= *(const GLuint *)packedPixel;
5831 }
5832
5833 /* 11111111,00000000,00000000,00000000 == 0xff000000 */
5834 /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
5835 /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
5836 /* 00000000,00000000,00000000,11111111 == 0x000000ff */
5837
5838 /* 255 = 2^8-1 */
5839 extractComponents[0]= (float)((uint & 0xff000000) >> 24) / 255.0;
5840 extractComponents[1]= (float)((uint & 0x00ff0000) >> 16) / 255.0;
5841 extractComponents[2]= (float)((uint & 0x0000ff00) >> 8) / 255.0;
5842 extractComponents[3]= (float)((uint & 0x000000ff) ) / 255.0;
5843} /* extract8888() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extract8888rev()

static void extract8888rev ( int  isSwap,
const void packedPixel,
GLfloat  extractComponents[] 
)
static

Definition at line 5869 of file mipmap.c.

5871{
5872 GLuint uint;
5873
5874 if (isSwap) {
5875 uint= __GLU_SWAP_4_BYTES(packedPixel);
5876 }
5877 else {
5878 uint= *(const GLuint *)packedPixel;
5879 }
5880
5881 /* 00000000,00000000,00000000,11111111 == 0x000000ff */
5882 /* 00000000,00000000,11111111,00000000 == 0x0000ff00 */
5883 /* 00000000,11111111,00000000,00000000 == 0x00ff0000 */
5884 /* 11111111,00000000,00000000,00000000 == 0xff000000 */
5885
5886 /* 255 = 2^8-1 */
5887 extractComponents[0]= (float)((uint & 0x000000FF) ) / 255.0;
5888 extractComponents[1]= (float)((uint & 0x0000FF00) >> 8) / 255.0;
5889 extractComponents[2]= (float)((uint & 0x00FF0000) >> 16) / 255.0;
5890 extractComponents[3]= (float)((uint & 0xFF000000) >> 24) / 255.0;
5891} /* extract8888rev() */

Referenced by fill_image(), fillImage3D(), gluBuild2DMipmapLevelsCore(), and gluBuild3DMipmapLevelsCore().

◆ extractFloat()

static GLdouble extractFloat ( int  isSwap,
const void item 
)
static

Definition at line 8641 of file mipmap.c.

8642{
8643 GLfloat ffloat;
8644
8645 if (isSwap) {
8646 ffloat= __GLU_SWAP_4_BYTES(item);
8647 }
8648 else {
8649 ffloat= *(const GLfloat *)item;
8650 }
8651
8652 assert(ffloat <= 1.0);
8653
8654 return (GLdouble)ffloat;
8655} /* extractFloat() */
double GLdouble
Definition: gl.h:163
static ATOM item
Definition: dde.c:856

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractSbyte()

static GLdouble extractSbyte ( int  isSwap,
const void sbyte 
)
static

Definition at line 8535 of file mipmap.c.

8536{
8537 isSwap= isSwap; /* turn off warnings */
8538
8539 assert(*((const GLbyte *)sbyte) <= 127);
8540
8541 return (GLdouble)(*((const GLbyte *)sbyte));
8542} /* extractSbyte() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractSint()

static GLdouble extractSint ( int  isSwap,
const void sitem 
)
static

Definition at line 8618 of file mipmap.c.

8619{
8620 GLint sint;
8621
8622 if (isSwap) {
8623 sint= __GLU_SWAP_4_BYTES(sitem);
8624 }
8625 else {
8626 sint= *(const GLint *)sitem;
8627 }
8628
8629 assert(sint <= 0x7fffffff);
8630
8631 return (GLdouble)sint;
8632} /* extractSint() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractSshort()

static GLdouble extractSshort ( int  isSwap,
const void sitem 
)
static

Definition at line 8572 of file mipmap.c.

8573{
8574 GLshort sshort;
8575
8576 if (isSwap) {
8577 sshort= __GLU_SWAP_2_BYTES(sitem);
8578 }
8579 else {
8580 sshort= *(const GLshort *)sitem;
8581 }
8582
8583 assert(sshort <= 32767);
8584
8585 return (GLdouble)sshort;
8586} /* extractSshort() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractUbyte()

static GLdouble extractUbyte ( int  isSwap,
const void ubyte 
)
static

Definition at line 8519 of file mipmap.c.

8520{
8521 isSwap= isSwap; /* turn off warnings */
8522
8523 assert(*((const GLubyte *)ubyte) <= 255);
8524
8525 return (GLdouble)(*((const GLubyte *)ubyte));
8526} /* extractUbyte() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractUint()

static GLdouble extractUint ( int  isSwap,
const void uitem 
)
static

Definition at line 8595 of file mipmap.c.

8596{
8597 GLuint uint;
8598
8599 if (isSwap) {
8600 uint= __GLU_SWAP_4_BYTES(uitem);
8601 }
8602 else {
8603 uint= *(const GLuint *)uitem;
8604 }
8605
8606 assert(uint <= 0xffffffff);
8607
8608 return (GLdouble)uint;
8609} /* extractUint() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ extractUshort()

static GLdouble extractUshort ( int  isSwap,
const void uitem 
)
static

Definition at line 8549 of file mipmap.c.

8550{
8552
8553 if (isSwap) {
8554 ushort= __GLU_SWAP_2_BYTES(uitem);
8555 }
8556 else {
8557 ushort= *(const GLushort *)uitem;
8558 }
8559
8560 assert(ushort <= 65535);
8561
8562 return (GLdouble)ushort;
8563} /* extractUshort() */

Referenced by gluBuild3DMipmapLevelsCore().

◆ fill_image()

static void fill_image ( const PixelStorageModes psm,
GLint  width,
GLint  height,
GLenum  format,
GLenum  type,
GLboolean  index_format,
const void userdata,
GLushort newimage 
)
static

Definition at line 4878 of file mipmap.c.

4882{
4884 GLint element_size;
4885 GLint rowsize;
4886 GLint padding;
4887 GLint groups_per_line;
4888 GLint group_size;
4889 GLint elements_per_line;
4890 const GLubyte *start;
4891 const GLubyte *iter;
4892 GLushort *iter2;
4893 GLint i, j, k;
4894 GLint myswap_bytes;
4895
4896 myswap_bytes = psm->unpack_swap_bytes;
4898 if (psm->unpack_row_length > 0) {
4899 groups_per_line = psm->unpack_row_length;
4900 } else {
4901 groups_per_line = width;
4902 }
4903
4904 /* All formats except GL_BITMAP fall out trivially */
4905 if (type == GL_BITMAP) {
4906 GLint bit_offset;
4907 GLint current_bit;
4908
4909 rowsize = (groups_per_line * components + 7) / 8;
4910 padding = (rowsize % psm->unpack_alignment);
4911 if (padding) {
4912 rowsize += psm->unpack_alignment - padding;
4913 }
4914 start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize +
4915 (psm->unpack_skip_pixels * components / 8);
4916 elements_per_line = width * components;
4917 iter2 = newimage;
4918 for (i = 0; i < height; i++) {
4919 iter = start;
4920 bit_offset = (psm->unpack_skip_pixels * components) % 8;
4921 for (j = 0; j < elements_per_line; j++) {
4922 /* Retrieve bit */
4923 if (psm->unpack_lsb_first) {
4924 current_bit = iter[0] & (1 << bit_offset);
4925 } else {
4926 current_bit = iter[0] & (1 << (7 - bit_offset));
4927 }
4928 if (current_bit) {
4929 if (index_format) {
4930 *iter2 = 1;
4931 } else {
4932 *iter2 = 65535;
4933 }
4934 } else {
4935 *iter2 = 0;
4936 }
4937 bit_offset++;
4938 if (bit_offset == 8) {
4939 bit_offset = 0;
4940 iter++;
4941 }
4942 iter2++;
4943 }
4944 start += rowsize;
4945 }
4946 } else {
4947 element_size = bytes_per_element(type);
4948 group_size = element_size * components;
4949 if (element_size == 1) myswap_bytes = 0;
4950
4951 rowsize = groups_per_line * group_size;
4952 padding = (rowsize % psm->unpack_alignment);
4953 if (padding) {
4954 rowsize += psm->unpack_alignment - padding;
4955 }
4956 start = (const GLubyte *) userdata + psm->unpack_skip_rows * rowsize +
4957 psm->unpack_skip_pixels * group_size;
4958 elements_per_line = width * components;
4959
4960 iter2 = newimage;
4961 for (i = 0; i < height; i++) {
4962 iter = start;
4963 for (j = 0; j < elements_per_line; j++) {
4964 Type_Widget widget;
4965 float extractComponents[4];
4966
4967 switch(type) {
4969 extract332(0,iter,extractComponents);
4970 for (k = 0; k < 3; k++) {
4971 *iter2++ = (GLushort)(extractComponents[k]*65535);
4972 }
4973 break;
4975 extract233rev(0,iter,extractComponents);
4976 for (k = 0; k < 3; k++) {
4977 *iter2++ = (GLushort)(extractComponents[k]*65535);
4978 }
4979 break;
4980 case GL_UNSIGNED_BYTE:
4981 if (index_format) {
4982 *iter2++ = *iter;
4983 } else {
4984 *iter2++ = (*iter) * 257;
4985 }
4986 break;
4987 case GL_BYTE:
4988 if (index_format) {
4989 *iter2++ = *((const GLbyte *) iter);
4990 } else {
4991 /* rough approx */
4992 *iter2++ = (*((const GLbyte *) iter)) * 516;
4993 }
4994 break;
4996 extract565(myswap_bytes,iter,extractComponents);
4997 for (k = 0; k < 3; k++) {
4998 *iter2++ = (GLushort)(extractComponents[k]*65535);
4999 }
5000 break;
5002 extract565rev(myswap_bytes,iter,extractComponents);
5003 for (k = 0; k < 3; k++) {
5004 *iter2++ = (GLushort)(extractComponents[k]*65535);
5005 }
5006 break;
5008 extract4444(myswap_bytes,iter,extractComponents);
5009 for (k = 0; k < 4; k++) {
5010 *iter2++ = (GLushort)(extractComponents[k]*65535);
5011 }
5012 break;
5014 extract4444rev(myswap_bytes,iter,extractComponents);
5015 for (k = 0; k < 4; k++) {
5016 *iter2++ = (GLushort)(extractComponents[k]*65535);
5017 }
5018 break;
5020 extract5551(myswap_bytes,iter,extractComponents);
5021 for (k = 0; k < 4; k++) {
5022 *iter2++ = (GLushort)(extractComponents[k]*65535);
5023 }
5024 break;
5026 extract1555rev(myswap_bytes,iter,extractComponents);
5027 for (k = 0; k < 4; k++) {
5028 *iter2++ = (GLushort)(extractComponents[k]*65535);
5029 }
5030 break;
5031 case GL_UNSIGNED_SHORT:
5032 case GL_SHORT:
5033 if (myswap_bytes) {
5034 widget.ub[0] = iter[1];
5035 widget.ub[1] = iter[0];
5036 } else {
5037 widget.ub[0] = iter[0];
5038 widget.ub[1] = iter[1];
5039 }
5040 if (type == GL_SHORT) {
5041 if (index_format) {
5042 *iter2++ = widget.s[0];
5043 } else {
5044 /* rough approx */
5045 *iter2++ = widget.s[0]*2;
5046 }
5047 } else {
5048 *iter2++ = widget.us[0];
5049 }
5050 break;
5052 extract8888(myswap_bytes,iter,extractComponents);
5053 for (k = 0; k < 4; k++) {
5054 *iter2++ = (GLushort)(extractComponents[k]*65535);
5055 }
5056 break;
5058 extract8888rev(myswap_bytes,iter,extractComponents);
5059 for (k = 0; k < 4; k++) {
5060 *iter2++ = (GLushort)(extractComponents[k]*65535);
5061 }
5062 break;
5064 extract1010102(myswap_bytes,iter,extractComponents);
5065 for (k = 0; k < 4; k++) {
5066 *iter2++ = (GLushort)(extractComponents[k]*65535);
5067 }
5068 break;
5070 extract2101010rev(myswap_bytes,iter,extractComponents);
5071 for (k = 0; k < 4; k++) {
5072 *iter2++ = (GLushort)(extractComponents[k]*65535);
5073 }
5074 break;
5075 case GL_INT:
5076 case GL_UNSIGNED_INT:
5077 case GL_FLOAT:
5078 if (myswap_bytes) {
5079 widget.ub[0] = iter[3];
5080 widget.ub[1] = iter[2];
5081 widget.ub[2] = iter[1];
5082 widget.ub[3] = iter[0];
5083 } else {
5084 widget.ub[0] = iter[0];
5085 widget.ub[1] = iter[1];
5086 widget.ub[2] = iter[2];
5087 widget.ub[3] = iter[3];
5088 }
5089 if (type == GL_FLOAT) {
5090 if (index_format) {
5091 *iter2++ = widget.f;
5092 } else {
5093 *iter2++ = 65535 * widget.f;
5094 }
5095 } else if (type == GL_UNSIGNED_INT) {
5096 if (index_format) {
5097 *iter2++ = widget.ui;
5098 } else {
5099 *iter2++ = widget.ui >> 16;
5100 }
5101 } else {
5102 if (index_format) {
5103 *iter2++ = widget.i;
5104 } else {
5105 *iter2++ = widget.i >> 15;
5106 }
5107 }
5108 break;
5109 }
5110 iter += element_size;
5111 } /* for j */
5112 start += rowsize;
5113#if 1
5114 /* want 'iter' pointing at start, not within, row for assertion
5115 * purposes
5116 */
5117 iter= start;
5118#endif
5119 } /* for i */
5120
5121 /* iterators should be one byte past end */
5122 if (!isTypePackedPixel(type)) {
5123 assert(iter2 == &newimage[width*height*components]);
5124 }
5125 else {
5126 assert(iter2 == &newimage[width*height*
5128 }
5129 assert( iter == &((const GLubyte *)userdata)[rowsize*height +
5130 psm->unpack_skip_rows * rowsize +
5131 psm->unpack_skip_pixels * group_size] );
5132
5133 } /* else */
5134} /* fill_image() */
static void extract1010102(int, const void *, GLfloat[])
Definition: mipmap.c:5917
static void extract332(int, const void *, GLfloat[])
Definition: mipmap.c:5482
static void extract233rev(int, const void *, GLfloat[])
Definition: mipmap.c:5518
static void extract1555rev(int, const void *, GLfloat[])
Definition: mipmap.c:5773
static void extract4444(int, const void *, GLfloat[])
Definition: mipmap.c:5636
static void extract8888(int, const void *, GLfloat[])
Definition: mipmap.c:5821
static void extract5551(int, const void *, GLfloat[])
Definition: mipmap.c:5726
static void extract8888rev(int, const void *, GLfloat[])
Definition: mipmap.c:5869
static void extract565rev(int, const void *, GLfloat[])
Definition: mipmap.c:5595
static void extract2101010rev(int, const void *, GLfloat[])
Definition: mipmap.c:5965
static void extract565(int, const void *, GLfloat[])
Definition: mipmap.c:5554
static void extract4444rev(int, const void *, GLfloat[])
Definition: mipmap.c:5678
GLint unpack_lsb_first
Definition: mipmap.c:65

Referenced by bitmapBuild2DMipmaps(), gluBuild1DMipmapLevelsCore(), and gluScaleImage().

◆ fillImage3D()

static void fillImage3D ( const PixelStorageModes psm,
GLint  width,
GLint  height,
GLint  depth,
GLenum  format,
GLenum  type,
GLboolean  indexFormat,
const void userImage,
GLushort newImage 
)
static

Definition at line 6685 of file mipmap.c.

6689{
6690 int myswapBytes;
6691 int components;
6692 int groupsPerLine;
6693 int elementSize;
6694 int groupSize;
6695 int rowSize;
6696 int padding;
6697 int elementsPerLine;
6698 int rowsPerImage;
6699 int imageSize;
6700 const GLubyte *start, *rowStart, *iter;
6701 GLushort *iter2;
6702 int ww, hh, dd, k;
6703
6704 myswapBytes= psm->unpack_swap_bytes;
6706 if (psm->unpack_row_length > 0) {
6707 groupsPerLine= psm->unpack_row_length;
6708 }
6709 else {
6710 groupsPerLine= width;
6711 }
6712 elementSize= bytes_per_element(type);
6713 groupSize= elementSize * components;
6714 if (elementSize == 1) myswapBytes= 0;
6715
6716 /* 3dstuff begin */
6717 if (psm->unpack_image_height > 0) {
6718 rowsPerImage= psm->unpack_image_height;
6719 }
6720 else {
6721 rowsPerImage= height;
6722 }
6723 /* 3dstuff end */
6724
6725 rowSize= groupsPerLine * groupSize;
6726 padding= rowSize % psm->unpack_alignment;
6727 if (padding) {
6728 rowSize+= psm->unpack_alignment - padding;
6729 }
6730
6731 imageSize= rowsPerImage * rowSize; /* 3dstuff */
6732
6733 start= (const GLubyte *)userImage + psm->unpack_skip_rows * rowSize +
6734 psm->unpack_skip_pixels * groupSize +
6735 /*3dstuff*/
6737 elementsPerLine = width * components;
6738
6739 iter2= newImage;
6740 for (dd= 0; dd < depth; dd++) {
6741 rowStart= start;
6742
6743 for (hh= 0; hh < height; hh++) {
6744 iter= rowStart;
6745
6746 for (ww= 0; ww < elementsPerLine; ww++) {
6747 Type_Widget widget;
6748 float extractComponents[4];
6749
6750 switch(type) {
6751 case GL_UNSIGNED_BYTE:
6752 if (indexFormat) {
6753 *iter2++ = *iter;
6754 } else {
6755 *iter2++ = (*iter) * 257;
6756 }
6757 break;
6758 case GL_BYTE:
6759 if (indexFormat) {
6760 *iter2++ = *((const GLbyte *) iter);
6761 } else {
6762 /* rough approx */
6763 *iter2++ = (*((const GLbyte *) iter)) * 516;
6764 }
6765 break;
6767 extract332(0,iter,extractComponents);
6768 for (k = 0; k < 3; k++) {
6769 *iter2++ = (GLushort)(extractComponents[k]*65535);
6770 }
6771 break;
6773 extract233rev(0,iter,extractComponents);
6774 for (k = 0; k < 3; k++) {
6775 *iter2++ = (GLushort)(extractComponents[k]*65535);
6776 }
6777 break;
6779 extract565(myswapBytes,iter,extractComponents);
6780 for (k = 0; k < 3; k++) {
6781 *iter2++ = (GLushort)(extractComponents[k]*65535);
6782 }
6783 break;
6785 extract565rev(myswapBytes,iter,extractComponents);
6786 for (k = 0; k < 3; k++) {
6787 *iter2++ = (GLushort)(extractComponents[k]*65535);
6788 }
6789 break;
6791 extract4444(myswapBytes,iter,extractComponents);
6792 for (k = 0; k < 4; k++) {
6793 *iter2++ = (GLushort)(extractComponents[k]*65535);
6794 }
6795 break;
6797 extract4444rev(myswapBytes,iter,extractComponents);
6798 for (k = 0; k < 4; k++) {
6799 *iter2++ = (GLushort)(extractComponents[k]*65535);
6800 }
6801 break;
6803 extract5551(myswapBytes,iter,extractComponents);
6804 for (k = 0; k < 4; k++) {
6805 *iter2++ = (GLushort)(extractComponents[k]*65535);
6806 }
6807 break;
6809 extract1555rev(myswapBytes,iter,extractComponents);
6810 for (k = 0; k < 4; k++) {
6811 *iter2++ = (GLushort)(extractComponents[k]*65535);
6812 }
6813 break;
6814 case GL_UNSIGNED_SHORT:
6815 case GL_SHORT:
6816 if (myswapBytes) {
6817 widget.ub[0] = iter[1];
6818 widget.ub[1] = iter[0];
6819 } else {
6820 widget.ub[0] = iter[0];
6821 widget.ub[1] = iter[1];
6822 }
6823 if (type == GL_SHORT) {
6824 if (indexFormat) {
6825 *iter2++ = widget.s[0];
6826 } else {
6827 /* rough approx */
6828 *iter2++ = widget.s[0]*2;
6829 }
6830 } else {
6831 *iter2++ = widget.us[0];
6832 }
6833 break;
6835 extract8888(myswapBytes,iter,extractComponents);
6836 for (k = 0; k < 4; k++) {
6837 *iter2++ = (GLushort)(extractComponents[k]*65535);
6838 }
6839 break;
6841 extract8888rev(myswapBytes,iter,extractComponents);
6842 for (k = 0; k < 4; k++) {
6843 *iter2++ = (GLushort)(extractComponents[k]*65535);
6844 }
6845 break;
6847 extract1010102(myswapBytes,iter,extractComponents);
6848 for (k = 0; k < 4; k++) {
6849 *iter2++ = (GLushort)(extractComponents[k]*65535);
6850 }
6851 break;
6853 extract2101010rev(myswapBytes,iter,extractComponents);
6854 for (k = 0; k < 4; k++) {
6855 *iter2++ = (GLushort)(extractComponents[k]*65535);
6856 }
6857 break;
6858 case GL_INT:
6859 case GL_UNSIGNED_INT:
6860 case GL_FLOAT:
6861 if (myswapBytes) {
6862 widget.ub[0] = iter[3];
6863 widget.ub[1] = iter[2];
6864 widget.ub[2] = iter[1];
6865 widget.ub[3] = iter[0];
6866 } else {
6867 widget.ub[0] = iter[0];
6868 widget.ub[1] = iter[1];
6869 widget.ub[2] = iter[2];
6870 widget.ub[3] = iter[3];
6871 }
6872 if (type == GL_FLOAT) {
6873 if (indexFormat) {
6874 *iter2++ = widget.f;
6875 } else {
6876 *iter2++ = 65535 * widget.f;
6877 }
6878 } else if (type == GL_UNSIGNED_INT) {
6879 if (indexFormat) {
6880 *iter2++ = widget.ui;
6881 } else {
6882 *iter2++ = widget.ui >> 16;
6883 }
6884 } else {
6885 if (indexFormat) {
6886 *iter2++ = widget.i;
6887 } else {
6888 *iter2++ = widget.i >> 15;
6889 }
6890 }
6891 break;
6892 default:
6893 assert(0);
6894 }
6895
6896 iter+= elementSize;
6897 } /* for ww */
6898 rowStart+= rowSize;
6899
6900 iter= rowStart; /* for assertion purposes */
6901 } /* for hh */
6902
6903 start+= imageSize;
6904 } /* for dd */
6905
6906 /* iterators should be one byte past end */
6907 if (!isTypePackedPixel(type)) {
6908 assert(iter2 == &newImage[width*height*depth*components]);
6909 }
6910 else {
6911 assert(iter2 == &newImage[width*height*depth*
6913 }
6914 assert( iter == &((const GLubyte *)userImage)[rowSize*height*depth +
6915 psm->unpack_skip_rows * rowSize +
6916 psm->unpack_skip_pixels * groupSize +
6917 /*3dstuff*/
6918 psm->unpack_skip_images * imageSize] );
6919} /* fillImage3D () */
GLint unpack_image_height
Definition: mipmap.c:68

Referenced by gluScaleImage3D().

◆ gluBuild1DMipmapLevels()

GLint GLAPIENTRY gluBuild1DMipmapLevels ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)

Definition at line 3643 of file mipmap.c.

3648{
3649 int levels;
3650
3652 if (rc != 0) return rc;
3653
3654 if (width < 1) {
3655 return GLU_INVALID_VALUE;
3656 }
3657
3659
3660 levels+= userLevel;
3661 if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
3662 return GLU_INVALID_VALUE;
3663
3665 width,
3666 width,format, type,
3667 userLevel, baseLevel, maxLevel,
3668 data);
3669} /* gluBuild1DMipmapLevels() */
#define GLU_INVALID_VALUE
Definition: glu.h:89
static int checkMipmapArgs(GLenum, GLenum, GLenum)
Definition: mipmap.c:3270
static int gluBuild1DMipmapLevelsCore(GLenum, GLint, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
Definition: mipmap.c:3547
static GLboolean isLegalLevels(GLint, GLint, GLint, GLint)
Definition: mipmap.c:3393

◆ gluBuild1DMipmapLevelsCore()

int gluBuild1DMipmapLevelsCore ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  widthPowerOf2,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)
static

Definition at line 3547 of file mipmap.c.

3553{
3554 GLint newwidth;
3556 GLushort *newImage;
3557 GLint newImage_width;
3558 GLushort *otherImage;
3559 GLushort *imageTemp;
3560 GLint memreq;
3561 GLint cmpts;
3563
3565 assert(width >= 1);
3566
3567 otherImage = NULL;
3568
3569 newwidth= widthPowerOf2;
3570 levels = computeLog(newwidth);
3571
3572 levels+= userLevel;
3573
3574 retrieveStoreModes(&psm);
3575 newImage = (GLushort *)
3577 newImage_width = width;
3578 if (newImage == NULL) {
3579 return GLU_OUT_OF_MEMORY;
3580 }
3582 data, newImage);
3588 /*
3589 ** If swap_bytes was set, swapping occurred in fill_image.
3590 */
3592
3593 for (level = userLevel; level <= levels; level++) {
3594 if (newImage_width == newwidth) {
3595 /* Use newImage for this level */
3596 if (baseLevel <= level && level <= maxLevel) {
3597 glTexImage1D(target, level, internalFormat, newImage_width,
3598 0, format, GL_UNSIGNED_SHORT, (void *) newImage);
3599 }
3600 } else {
3601 if (otherImage == NULL) {
3602 memreq = image_size(newwidth, 1, format, GL_UNSIGNED_SHORT);
3603 otherImage = (GLushort *) malloc(memreq);
3604 if (otherImage == NULL) {
3610 free(newImage);
3611 return GLU_OUT_OF_MEMORY;
3612 }
3613 }
3614 scale_internal(cmpts, newImage_width, 1, newImage,
3615 newwidth, 1, otherImage);
3616 /* Swap newImage and otherImage */
3617 imageTemp = otherImage;
3618 otherImage = newImage;
3619 newImage = imageTemp;
3620
3621 newImage_width = newwidth;
3622 if (baseLevel <= level && level <= maxLevel) {
3623 glTexImage1D(target, level, internalFormat, newImage_width,
3624 0, format, GL_UNSIGNED_SHORT, (void *) newImage);
3625 }
3626 }
3627 if (newwidth > 1) newwidth /= 2;
3628 }
3634
3635 free((GLbyte *) newImage);
3636 if (otherImage) {
3637 free((GLbyte *) otherImage);
3638 }
3639 return 0;
3640}

Referenced by gluBuild1DMipmapLevels(), and gluBuild1DMipmaps().

◆ gluBuild1DMipmaps()

GLint GLAPIENTRY gluBuild1DMipmaps ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLenum  format,
GLenum  type,
const void data 
)

Definition at line 3672 of file mipmap.c.

3675{
3676 GLint widthPowerOf2;
3677 int levels;
3678 GLint dummy;
3679
3681 if (rc != 0) return rc;
3682
3683 if (width < 1) {
3684 return GLU_INVALID_VALUE;
3685 }
3686
3688 levels = computeLog(widthPowerOf2);
3689
3691 width,
3692 widthPowerOf2,
3693 format,type,0,0,levels,data);
3694}

◆ gluBuild2DMipmapLevels()

GLint GLAPIENTRY gluBuild2DMipmapLevels ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)

Definition at line 4554 of file mipmap.c.

4559{
4560 int level, levels;
4561
4563 if (rc != 0) return rc;
4564
4565 if (width < 1 || height < 1) {
4566 return GLU_INVALID_VALUE;
4567 }
4568
4571 if (level > levels) levels=level;
4572
4573 levels+= userLevel;
4574 if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
4575 return GLU_INVALID_VALUE;
4576
4578 width, height,
4579 width, height,
4580 format, type,
4581 userLevel, baseLevel, maxLevel,
4582 data);
4583} /* gluBuild2DMipmapLevels() */
static int gluBuild2DMipmapLevelsCore(GLenum, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
Definition: mipmap.c:3802

◆ gluBuild2DMipmapLevelsCore()

static int gluBuild2DMipmapLevelsCore ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLsizei  widthPowerOf2,
GLsizei  heightPowerOf2,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)
static

Definition at line 3802 of file mipmap.c.

3810{
3811 GLint newwidth, newheight;
3813 const void *usersImage; /* passed from user. Don't touch! */
3814 void *srcImage, *dstImage; /* scratch area to build mipmapped images */
3816 GLint memreq;
3817 GLint cmpts;
3818
3819 GLint myswap_bytes, groups_per_line, element_size, group_size;
3820 GLint rowsize, padding;
3822
3824 assert(width >= 1 && height >= 1);
3825
3826 if(type == GL_BITMAP) {
3828 format, type, data);
3829 }
3830
3831 srcImage = dstImage = NULL;
3832
3833 newwidth= widthPowerOf2;
3834 newheight= heightPowerOf2;
3835 levels = computeLog(newwidth);
3836 level = computeLog(newheight);
3837 if (level > levels) levels=level;
3838
3839 levels+= userLevel;
3840
3841 retrieveStoreModes(&psm);
3842 myswap_bytes = psm.unpack_swap_bytes;
3844 if (psm.unpack_row_length > 0) {
3845 groups_per_line = psm.unpack_row_length;
3846 } else {
3847 groups_per_line = width;
3848 }
3849
3850 element_size = bytes_per_element(type);
3851 group_size = element_size * cmpts;
3852 if (element_size == 1) myswap_bytes = 0;
3853
3854 rowsize = groups_per_line * group_size;
3855 padding = (rowsize % psm.unpack_alignment);
3856 if (padding) {
3857 rowsize += psm.unpack_alignment - padding;
3858 }
3859 usersImage = (const GLubyte *) data + psm.unpack_skip_rows * rowsize +
3860 psm.unpack_skip_pixels * group_size;
3861
3865
3866 level = userLevel;
3867
3868 /* already power-of-two square */
3869 if (width == newwidth && height == newheight) {
3870 /* Use usersImage for level userLevel */
3871 if (baseLevel <= level && level <= maxLevel) {
3874 height, 0, format, type,
3875 usersImage);
3876 }
3878 if(levels == 0) { /* we're done. clean up and return */
3884 return 0;
3885 }
3886 {
3887 int nextWidth= newwidth/2;
3888 int nextHeight= newheight/2;
3889
3890 /* clamp to 1 */
3891 if (nextWidth < 1) nextWidth= 1;
3892 if (nextHeight < 1) nextHeight= 1;
3893 memreq = image_size(nextWidth, nextHeight, format, type);
3894 }
3895
3896 switch(type) {
3897 case GL_UNSIGNED_BYTE:
3898 dstImage = (GLubyte *)malloc(memreq);
3899 break;
3900 case GL_BYTE:
3901 dstImage = (GLbyte *)malloc(memreq);
3902 break;
3903 case GL_UNSIGNED_SHORT:
3904 dstImage = (GLushort *)malloc(memreq);
3905 break;
3906 case GL_SHORT:
3907 dstImage = (GLshort *)malloc(memreq);
3908 break;
3909 case GL_UNSIGNED_INT:
3910 dstImage = (GLuint *)malloc(memreq);
3911 break;
3912 case GL_INT:
3913 dstImage = (GLint *)malloc(memreq);
3914 break;
3915 case GL_FLOAT:
3916 dstImage = (GLfloat *)malloc(memreq);
3917 break;
3920 dstImage = (GLubyte *)malloc(memreq);
3921 break;
3928 dstImage = (GLushort *)malloc(memreq);
3929 break;
3934 dstImage = (GLuint *)malloc(memreq);
3935 break;
3936 default:
3937 return GLU_INVALID_ENUM;
3938 }
3939 if (dstImage == NULL) {
3945 return GLU_OUT_OF_MEMORY;
3946 }
3947 else
3948 switch(type) {
3949 case GL_UNSIGNED_BYTE:
3951 (const GLubyte *)usersImage, (GLubyte *)dstImage,
3952 element_size, rowsize, group_size);
3953 break;
3954 case GL_BYTE:
3956 (const GLbyte *)usersImage, (GLbyte *)dstImage,
3957 element_size, rowsize, group_size);
3958 break;
3959 case GL_UNSIGNED_SHORT:
3961 (const GLushort *)usersImage, (GLushort *)dstImage,
3962 element_size, rowsize, group_size, myswap_bytes);
3963 break;
3964 case GL_SHORT:
3966 (const GLshort *)usersImage, (GLshort *)dstImage,
3967 element_size, rowsize, group_size, myswap_bytes);
3968 break;
3969 case GL_UNSIGNED_INT:
3971 (const GLuint *)usersImage, (GLuint *)dstImage,
3972 element_size, rowsize, group_size, myswap_bytes);
3973 break;
3974 case GL_INT:
3975 halveImage_int(cmpts, width, height,
3976 (const GLint *)usersImage, (GLint *)dstImage,
3977 element_size, rowsize, group_size, myswap_bytes);
3978 break;
3979 case GL_FLOAT:
3981 (const GLfloat *)usersImage, (GLfloat *)dstImage,
3982 element_size, rowsize, group_size, myswap_bytes);
3983 break;
3985 assert(format == GL_RGB);
3987 width,height,usersImage,dstImage,
3988 element_size,rowsize,myswap_bytes);
3989 break;
3991 assert(format == GL_RGB);
3993 width,height,usersImage,dstImage,
3994 element_size,rowsize,myswap_bytes);
3995 break;
3998 width,height,usersImage,dstImage,
3999 element_size,rowsize,myswap_bytes);
4000 break;
4003 width,height,usersImage,dstImage,
4004 element_size,rowsize,myswap_bytes);
4005 break;
4008 width,height,usersImage,dstImage,
4009 element_size,rowsize,myswap_bytes);
4010 break;
4013 width,height,usersImage,dstImage,
4014 element_size,rowsize,myswap_bytes);
4015 break;
4018 width,height,usersImage,dstImage,
4019 element_size,rowsize,myswap_bytes);
4020 break;
4023 width,height,usersImage,dstImage,
4024 element_size,rowsize,myswap_bytes);
4025 break;
4028 width,height,usersImage,dstImage,
4029 element_size,rowsize,myswap_bytes);
4030 break;
4033 width,height,usersImage,dstImage,
4034 element_size,rowsize,myswap_bytes);
4035 break;
4038 width,height,usersImage,dstImage,
4039 element_size,rowsize,myswap_bytes);
4040 break;
4043 width,height,usersImage,dstImage,
4044 element_size,rowsize,myswap_bytes);
4045 break;
4046 default:
4047 assert(0);
4048 break;
4049 }
4050 newwidth = width/2;
4051 newheight = height/2;
4052 /* clamp to 1 */
4053 if (newwidth < 1) newwidth= 1;
4054 if (newheight < 1) newheight= 1;
4055
4056 myswap_bytes = 0;
4057 rowsize = newwidth * group_size;
4058 memreq = image_size(newwidth, newheight, format, type);
4059 /* Swap srcImage and dstImage */
4060 __GLU_SWAP_IMAGE(srcImage,dstImage);
4061 switch(type) {
4062 case GL_UNSIGNED_BYTE:
4063 dstImage = (GLubyte *)malloc(memreq);
4064 break;
4065 case GL_BYTE:
4066 dstImage = (GLbyte *)malloc(memreq);
4067 break;
4068 case GL_UNSIGNED_SHORT:
4069 dstImage = (GLushort *)malloc(memreq);
4070 break;
4071 case GL_SHORT:
4072 dstImage = (GLshort *)malloc(memreq);
4073 break;
4074 case GL_UNSIGNED_INT:
4075 dstImage = (GLuint *)malloc(memreq);
4076 break;
4077 case GL_INT:
4078 dstImage = (GLint *)malloc(memreq);
4079 break;
4080 case GL_FLOAT:
4081 dstImage = (GLfloat *)malloc(memreq);
4082 break;
4085 dstImage = (GLubyte *)malloc(memreq);
4086 break;
4093 dstImage = (GLushort *)malloc(memreq);
4094 break;
4099 dstImage = (GLuint *)malloc(memreq);
4100 break;
4101 default:
4102 return GLU_INVALID_ENUM;
4103 }
4104 if (dstImage == NULL) {
4110 free(srcImage);
4111 return GLU_OUT_OF_MEMORY;
4112 }
4113 /* level userLevel+1 is in srcImage; level userLevel already saved */
4114 level = userLevel+1;
4115 } else { /* user's image is *not* nice power-of-2 sized square */
4116 memreq = image_size(newwidth, newheight, format, type);
4117 switch(type) {
4118 case GL_UNSIGNED_BYTE:
4119 dstImage = (GLubyte *)malloc(memreq);
4120 break;
4121 case GL_BYTE:
4122 dstImage = (GLbyte *)malloc(memreq);
4123 break;
4124 case GL_UNSIGNED_SHORT:
4125 dstImage = (GLushort *)malloc(memreq);
4126 break;
4127 case GL_SHORT:
4128 dstImage = (GLshort *)malloc(memreq);
4129 break;
4130 case GL_UNSIGNED_INT:
4131 dstImage = (GLuint *)malloc(memreq);
4132 break;
4133 case GL_INT:
4134 dstImage = (GLint *)malloc(memreq);
4135 break;
4136 case GL_FLOAT:
4137 dstImage = (GLfloat *)malloc(memreq);
4138 break;
4141 dstImage = (GLubyte *)malloc(memreq);
4142 break;
4149 dstImage = (GLushort *)malloc(memreq);
4150 break;
4155 dstImage = (GLuint *)malloc(memreq);
4156 break;
4157 default:
4158 return GLU_INVALID_ENUM;
4159 }
4160
4161 if (dstImage == NULL) {
4167 return GLU_OUT_OF_MEMORY;
4168 }
4169
4170 switch(type) {
4171 case GL_UNSIGNED_BYTE:
4173 (const GLubyte *)usersImage, newwidth, newheight,
4174 (GLubyte *)dstImage, element_size,
4175 rowsize, group_size);
4176 break;
4177 case GL_BYTE:
4179 (const GLbyte *)usersImage, newwidth, newheight,
4180 (GLbyte *)dstImage, element_size,
4181 rowsize, group_size);
4182 break;
4183 case GL_UNSIGNED_SHORT:
4185 (const GLushort *)usersImage, newwidth, newheight,
4186 (GLushort *)dstImage, element_size,
4187 rowsize, group_size, myswap_bytes);
4188 break;
4189 case GL_SHORT:
4191 (const GLshort *)usersImage, newwidth, newheight,
4192 (GLshort *)dstImage, element_size,
4193 rowsize, group_size, myswap_bytes);
4194 break;
4195 case GL_UNSIGNED_INT:
4197 (const GLuint *)usersImage, newwidth, newheight,
4198 (GLuint *)dstImage, element_size,
4199 rowsize, group_size, myswap_bytes);
4200 break;
4201 case GL_INT:
4203 (const GLint *)usersImage, newwidth, newheight,
4204 (GLint *)dstImage, element_size,
4205 rowsize, group_size, myswap_bytes);
4206 break;
4207 case GL_FLOAT:
4209 (const GLfloat *)usersImage, newwidth, newheight,
4210 (GLfloat *)dstImage, element_size,
4211 rowsize, group_size, myswap_bytes);
4212 break;
4215 width, height,usersImage,
4216 newwidth,newheight,(void *)dstImage,
4217 element_size,rowsize,myswap_bytes);
4218 break;
4221 width, height,usersImage,
4222 newwidth,newheight,(void *)dstImage,
4223 element_size,rowsize,myswap_bytes);
4224 break;
4227 width, height,usersImage,
4228 newwidth,newheight,(void *)dstImage,
4229 element_size,rowsize,myswap_bytes);
4230 break;
4233 width, height,usersImage,
4234 newwidth,newheight,(void *)dstImage,
4235 element_size,rowsize,myswap_bytes);
4236 break;
4239 width, height,usersImage,
4240 newwidth,newheight,(void *)dstImage,
4241 element_size,rowsize,myswap_bytes);
4242 break;
4245 width, height,usersImage,
4246 newwidth,newheight,(void *)dstImage,
4247 element_size,rowsize,myswap_bytes);
4248 break;
4251 width, height,usersImage,
4252 newwidth,newheight,(void *)dstImage,
4253 element_size,rowsize,myswap_bytes);
4254 break;
4257 width, height,usersImage,
4258 newwidth,newheight,(void *)dstImage,
4259 element_size,rowsize,myswap_bytes);
4260 break;
4263 width, height,usersImage,
4264 newwidth,newheight,(void *)dstImage,
4265 element_size,rowsize,myswap_bytes);
4266 break;
4269 width, height,usersImage,
4270 newwidth,newheight,(void *)dstImage,
4271 element_size,rowsize,myswap_bytes);
4272 break;
4275 width, height,usersImage,
4276 newwidth,newheight,(void *)dstImage,
4277 element_size,rowsize,myswap_bytes);
4278 break;
4281 width, height,usersImage,
4282 newwidth,newheight,(void *)dstImage,
4283 element_size,rowsize,myswap_bytes);
4284 break;
4285 default:
4286 assert(0);
4287 break;
4288 }
4289 myswap_bytes = 0;
4290 rowsize = newwidth * group_size;
4291 /* Swap dstImage and srcImage */
4292 __GLU_SWAP_IMAGE(srcImage,dstImage);
4293
4294 if(levels != 0) { /* use as little memory as possible */
4295 {
4296 int nextWidth= newwidth/2;
4297 int nextHeight= newheight/2;
4298 if (nextWidth < 1) nextWidth= 1;
4299 if (nextHeight < 1) nextHeight= 1;
4300
4301 memreq = image_size(nextWidth, nextHeight, format, type);
4302 }
4303
4304 switch(type) {
4305 case GL_UNSIGNED_BYTE:
4306 dstImage = (GLubyte *)malloc(memreq);
4307 break;
4308 case GL_BYTE:
4309 dstImage = (GLbyte *)malloc(memreq);
4310 break;
4311 case GL_UNSIGNED_SHORT:
4312 dstImage = (GLushort *)malloc(memreq);
4313 break;
4314 case GL_SHORT:
4315 dstImage = (GLshort *)malloc(memreq);
4316 break;
4317 case GL_UNSIGNED_INT:
4318 dstImage = (GLuint *)malloc(memreq);
4319 break;
4320 case GL_INT:
4321 dstImage = (GLint *)malloc(memreq);
4322 break;
4323 case GL_FLOAT:
4324 dstImage = (GLfloat *)malloc(memreq);
4325 break;
4328 dstImage = (GLubyte *)malloc(memreq);
4329 break;
4336 dstImage = (GLushort *)malloc(memreq);
4337 break;
4342 dstImage = (GLuint *)malloc(memreq);
4343 break;
4344 default:
4345 return GLU_INVALID_ENUM;
4346 }
4347 if (dstImage == NULL) {
4353 free(srcImage);
4354 return GLU_OUT_OF_MEMORY;
4355 }
4356 }
4357 /* level userLevel is in srcImage; nothing saved yet */
4358 level = userLevel;
4359 }
4360
4362 if (baseLevel <= level && level <= maxLevel) {
4363 glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
4364 format, type, (void *)srcImage);
4365 }
4366
4367 level++; /* update current level for the loop */
4368 for (; level <= levels; level++) {
4369 switch(type) {
4370 case GL_UNSIGNED_BYTE:
4371 halveImage_ubyte(cmpts, newwidth, newheight,
4372 (GLubyte *)srcImage, (GLubyte *)dstImage, element_size,
4373 rowsize, group_size);
4374 break;
4375 case GL_BYTE:
4376 halveImage_byte(cmpts, newwidth, newheight,
4377 (GLbyte *)srcImage, (GLbyte *)dstImage, element_size,
4378 rowsize, group_size);
4379 break;
4380 case GL_UNSIGNED_SHORT:
4381 halveImage_ushort(cmpts, newwidth, newheight,
4382 (GLushort *)srcImage, (GLushort *)dstImage, element_size,
4383 rowsize, group_size, myswap_bytes);
4384 break;
4385 case GL_SHORT:
4386 halveImage_short(cmpts, newwidth, newheight,
4387 (GLshort *)srcImage, (GLshort *)dstImage, element_size,
4388 rowsize, group_size, myswap_bytes);
4389 break;
4390 case GL_UNSIGNED_INT:
4391 halveImage_uint(cmpts, newwidth, newheight,
4392 (GLuint *)srcImage, (GLuint *)dstImage, element_size,
4393 rowsize, group_size, myswap_bytes);
4394 break;
4395 case GL_INT:
4396 halveImage_int(cmpts, newwidth, newheight,
4397 (GLint *)srcImage, (GLint *)dstImage, element_size,
4398 rowsize, group_size, myswap_bytes);
4399 break;
4400 case GL_FLOAT:
4401 halveImage_float(cmpts, newwidth, newheight,
4402 (GLfloat *)srcImage, (GLfloat *)dstImage, element_size,
4403 rowsize, group_size, myswap_bytes);
4404 break;
4407 newwidth,newheight,
4408 srcImage,dstImage,element_size,rowsize,
4409 myswap_bytes);
4410 break;
4413 newwidth,newheight,
4414 srcImage,dstImage,element_size,rowsize,
4415 myswap_bytes);
4416 break;
4419 newwidth,newheight,
4420 srcImage,dstImage,element_size,rowsize,
4421 myswap_bytes);
4422 break;
4425 newwidth,newheight,
4426 srcImage,dstImage,element_size,rowsize,
4427 myswap_bytes);
4428 break;
4431 newwidth,newheight,
4432 srcImage,dstImage,element_size,rowsize,
4433 myswap_bytes);
4434 break;
4437 newwidth,newheight,
4438 srcImage,dstImage,element_size,rowsize,
4439 myswap_bytes);
4440 break;
4443 newwidth,newheight,
4444 srcImage,dstImage,element_size,rowsize,
4445 myswap_bytes);
4446 break;
4449 newwidth,newheight,
4450 srcImage,dstImage,element_size,rowsize,
4451 myswap_bytes);
4452 break;
4455 newwidth,newheight,
4456 srcImage,dstImage,element_size,rowsize,
4457 myswap_bytes);
4458 break;
4461 newwidth,newheight,
4462 srcImage,dstImage,element_size,rowsize,
4463 myswap_bytes);
4464 break;
4467 newwidth,newheight,
4468 srcImage,dstImage,element_size,rowsize,
4469 myswap_bytes);
4470 break;
4473 newwidth,newheight,
4474 srcImage,dstImage,element_size,rowsize,
4475 myswap_bytes);
4476 break;
4477 default:
4478 assert(0);
4479 break;
4480 }
4481
4482 __GLU_SWAP_IMAGE(srcImage,dstImage);
4483
4484 if (newwidth > 1) { newwidth /= 2; rowsize /= 2;}
4485 if (newheight > 1) newheight /= 2;
4486 {
4487 /* compute amount to pad per row, if any */
4488 int rowPad= rowsize % psm.unpack_alignment;
4489
4490 /* should row be padded? */
4491 if (rowPad == 0) { /* nope, row should not be padded */
4492 /* call tex image with srcImage untouched since it's not padded */
4493 if (baseLevel <= level && level <= maxLevel) {
4494 glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
4495 format, type, (void *) srcImage);
4496 }
4497 }
4498 else { /* yes, row should be padded */
4499 /* compute length of new row in bytes, including padding */
4500 int newRowLength= rowsize + psm.unpack_alignment - rowPad;
4501 int ii; unsigned char *dstTrav, *srcTrav; /* indices for copying */
4502
4503 /* allocate new image for mipmap of size newRowLength x newheight */
4504 void *newMipmapImage= malloc((size_t) (newRowLength*newheight));
4505 if (newMipmapImage == NULL) {
4506 /* out of memory so return */
4512 free(srcImage);
4513 free(dstImage);
4514 return GLU_OUT_OF_MEMORY;
4515 }
4516
4517 /* copy image from srcImage into newMipmapImage by rows */
4518 for (ii= 0,
4519 dstTrav= (unsigned char *) newMipmapImage,
4520 srcTrav= (unsigned char *) srcImage;
4521 ii< newheight;
4522 ii++,
4523 dstTrav+= newRowLength, /* make sure the correct distance... */
4524 srcTrav+= rowsize) { /* ...is skipped */
4525 memcpy(dstTrav,srcTrav,rowsize);
4526 /* note that the pad bytes are not visited and will contain
4527 * garbage, which is ok.
4528 */
4529 }
4530
4531 /* ...and use this new image for mipmapping instead */
4532 if (baseLevel <= level && level <= maxLevel) {
4533 glTexImage2D(target, level, internalFormat, newwidth, newheight, 0,
4534 format, type, newMipmapImage);
4535 }
4536 free(newMipmapImage); /* don't forget to free it! */
4537 } /* else */
4538 }
4539 } /* for level */
4545
4546 free(srcImage); /*if you get to here, a srcImage has always been malloc'ed*/
4547 if (dstImage) { /* if it's non-rectangular and only 1 level */
4548 free(dstImage);
4549 }
4550 return 0;
4551} /* gluBuild2DMipmapLevelsCore() */
static void scaleInternalPackedPixel(int, void(*)(int, const void *, GLfloat[]), void(*)(const GLfloat[], int, void *), GLint, GLint, const void *, GLint, GLint, void *, GLint, GLint, GLint)
Definition: mipmap.c:6015
static void halveImage_short(GLint components, GLuint width, GLuint height, const GLshort *datain, GLshort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:708
static int bitmapBuild2DMipmaps(GLenum target, GLint internalFormat, GLint width, GLint height, GLenum format, GLenum type, const void *data)
Definition: mipmap.c:3696
static void scale_internal_float(GLint components, GLint widthin, GLint heightin, const GLfloat *datain, GLint widthout, GLint heightout, GLfloat *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:2976
static void scale_internal_ushort(GLint components, GLint widthin, GLint heightin, const GLushort *datain, GLint widthout, GLint heightout, GLushort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:1819
#define __GLU_SWAP_IMAGE(a, b)
Definition: mipmap.c:3800
static void halveImage_byte(GLint components, GLuint width, GLuint height, const GLbyte *datain, GLbyte *dataout, GLint element_size, GLint ysize, GLint group_size)
Definition: mipmap.c:469
static void halveImagePackedPixel(int, void(*)(int, const void *, GLfloat[]), void(*)(const GLfloat[], int, void *), GLint, GLint, const void *, void *, GLint, GLint, GLint)
Definition: mipmap.c:6419
static void scale_internal_short(GLint components, GLint widthin, GLint heightin, const GLshort *datain, GLint widthout, GLint heightout, GLshort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:2099
static void scale_internal_byte(GLint components, GLint widthin, GLint heightin, const GLbyte *datain, GLint widthout, GLint heightout, GLbyte *dataout, GLint element_size, GLint ysize, GLint group_size)
Definition: mipmap.c:1602
static void scale_internal_ubyte(GLint components, GLint widthin, GLint heightin, const GLubyte *datain, GLint widthout, GLint heightout, GLubyte *dataout, GLint element_size, GLint ysize, GLint group_size)
Definition: mipmap.c:1385
static void halveImage_uint(GLint components, GLuint width, GLuint height, const GLuint *datain, GLuint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:854
static void scale_internal_uint(GLint components, GLint widthin, GLint heightin, const GLuint *datain, GLint widthout, GLint heightout, GLuint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:2393
static void halveImage_ubyte(GLint components, GLuint width, GLuint height, const GLubyte *datain, GLubyte *dataout, GLint element_size, GLint ysize, GLint group_size)
Definition: mipmap.c:368
static void halveImage_int(GLint components, GLuint width, GLuint height, const GLint *datain, GLint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:999
#define __GLU_INIT_SWAP_IMAGE
Definition: mipmap.c:3799
static void halveImage_ushort(GLint components, GLuint width, GLuint height, const GLushort *datain, GLushort *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:569
static void scale_internal_int(GLint components, GLint widthin, GLint heightin, const GLint *datain, GLint widthout, GLint heightout, GLint *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:2680
static void halveImage_float(GLint components, GLuint width, GLuint height, const GLfloat *datain, GLfloat *dataout, GLint element_size, GLint ysize, GLint group_size, GLint myswap_bytes)
Definition: mipmap.c:1146
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by gluBuild2DMipmapLevels(), and gluBuild2DMipmaps().

◆ gluBuild2DMipmaps()

GLint GLAPIENTRY gluBuild2DMipmaps ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLenum  format,
GLenum  type,
const void data 
)

Definition at line 4586 of file mipmap.c.

4590{
4591 GLint widthPowerOf2, heightPowerOf2;
4592 int level, levels;
4593
4595 if (rc != 0) return rc;
4596
4597 if (width < 1 || height < 1) {
4598 return GLU_INVALID_VALUE;
4599 }
4600
4602 &widthPowerOf2,&heightPowerOf2);
4603
4604 levels = computeLog(widthPowerOf2);
4605 level = computeLog(heightPowerOf2);
4606 if (level > levels) levels=level;
4607
4609 width, height,
4610 widthPowerOf2,heightPowerOf2,
4611 format,type,
4612 0,0,levels,data);
4613} /* gluBuild2DMipmaps() */

◆ gluBuild3DMipmapLevels()

GLint GLAPIENTRY gluBuild3DMipmapLevels ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLsizei  depth,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)

Definition at line 8446 of file mipmap.c.

8451{
8452 int level, levels;
8453
8455 if (rc != 0) return rc;
8456
8457 if (width < 1 || height < 1 || depth < 1) {
8458 return GLU_INVALID_VALUE;
8459 }
8460
8461 if(type == GL_BITMAP) {
8462 return GLU_INVALID_ENUM;
8463 }
8464
8467 if (level > levels) levels=level;
8469 if (level > levels) levels=level;
8470
8471 levels+= userLevel;
8472 if (!isLegalLevels(userLevel,baseLevel,maxLevel,levels))
8473 return GLU_INVALID_VALUE;
8474
8476 width, height, depth,
8477 width, height, depth,
8478 format, type,
8479 userLevel, baseLevel, maxLevel,
8480 data);
8481} /* gluBuild3DMipmapLevels() */
static int gluBuild3DMipmapLevelsCore(GLenum, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, GLint, GLint, GLint, const void *)
Definition: mipmap.c:7722

◆ gluBuild3DMipmapLevelsCore()

static int gluBuild3DMipmapLevelsCore ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLsizei  depth,
GLsizei  widthPowerOf2,
GLsizei  heightPowerOf2,
GLsizei  depthPowerOf2,
GLenum  format,
GLenum  type,
GLint  userLevel,
GLint  baseLevel,
GLint  maxLevel,
const void data 
)
static

Definition at line 7722 of file mipmap.c.

7733{
7734 GLint newWidth, newHeight, newDepth;
7736 const void *usersImage;
7737 void *srcImage, *dstImage;
7739 GLint memReq;
7740 GLint cmpts;
7741
7742 GLint myswapBytes, groupsPerLine, elementSize, groupSize;
7743 GLint rowsPerImage, imageSize;
7744 GLint rowSize, padding;
7746
7748 assert(width >= 1 && height >= 1 && depth >= 1);
7749 assert(type != GL_BITMAP);
7750
7751 srcImage = dstImage = NULL;
7752
7753 newWidth= widthPowerOf2;
7754 newHeight= heightPowerOf2;
7755 newDepth= depthPowerOf2;
7756 levels = computeLog(newWidth);
7757 level = computeLog(newHeight);
7758 if (level > levels) levels=level;
7759 level = computeLog(newDepth);
7760 if (level > levels) levels=level;
7761
7762 levels+= userLevel;
7763
7765 myswapBytes = psm.unpack_swap_bytes;
7767 if (psm.unpack_row_length > 0) {
7768 groupsPerLine = psm.unpack_row_length;
7769 } else {
7770 groupsPerLine = width;
7771 }
7772
7773 elementSize = bytes_per_element(type);
7774 groupSize = elementSize * cmpts;
7775 if (elementSize == 1) myswapBytes = 0;
7776
7777 /* 3dstuff begin */
7778 if (psm.unpack_image_height > 0) {
7779 rowsPerImage= psm.unpack_image_height;
7780 }
7781 else {
7782 rowsPerImage= height;
7783 }
7784
7785 /* 3dstuff end */
7786 rowSize = groupsPerLine * groupSize;
7787 padding = (rowSize % psm.unpack_alignment);
7788 if (padding) {
7789 rowSize += psm.unpack_alignment - padding;
7790 }
7791
7792 imageSize= rowsPerImage * rowSize; /* 3dstuff */
7793
7794 usersImage = (const GLubyte *)data + psm.unpack_skip_rows * rowSize +
7795 psm.unpack_skip_pixels * groupSize +
7796 /* 3dstuff */
7798
7804
7805 level = userLevel;
7806
7807 if (width == newWidth && height == newHeight && depth == newDepth) {
7808 /* Use usersImage for level userLevel */
7809 if (baseLevel <= level && level <= maxLevel) {
7811 height, depth, 0, format, type,
7812 usersImage);
7813 }
7814 if(levels == 0) { /* we're done. clean up and return */
7822 return 0;
7823 }
7824 {
7825 int nextWidth= newWidth/2;
7826 int nextHeight= newHeight/2;
7827 int nextDepth= newDepth/2;
7828
7829 /* clamp to 1 */
7830 if (nextWidth < 1) nextWidth= 1;
7831 if (nextHeight < 1) nextHeight= 1;
7832 if (nextDepth < 1) nextDepth= 1;
7833 memReq = imageSize3D(nextWidth, nextHeight, nextDepth, format, type);
7834 }
7835 switch(type) {
7836 case GL_UNSIGNED_BYTE:
7837 dstImage = (GLubyte *)malloc(memReq);
7838 break;
7839 case GL_BYTE:
7840 dstImage = (GLbyte *)malloc(memReq);
7841 break;
7842 case GL_UNSIGNED_SHORT:
7843 dstImage = (GLushort *)malloc(memReq);
7844 break;
7845 case GL_SHORT:
7846 dstImage = (GLshort *)malloc(memReq);
7847 break;
7848 case GL_UNSIGNED_INT:
7849 dstImage = (GLuint *)malloc(memReq);
7850 break;
7851 case GL_INT:
7852 dstImage = (GLint *)malloc(memReq);
7853 break;
7854 case GL_FLOAT:
7855 dstImage = (GLfloat *)malloc(memReq);
7856 break;
7859 dstImage = (GLubyte *)malloc(memReq);
7860 break;
7867 dstImage = (GLushort *)malloc(memReq);
7868 break;
7873 dstImage = (GLuint *)malloc(memReq);
7874 break;
7875 default:
7876 return GLU_INVALID_ENUM; /* assertion */
7877 }
7878 if (dstImage == NULL) {
7886 return GLU_OUT_OF_MEMORY;
7887 }
7888 else
7889 switch(type) {
7890 case GL_UNSIGNED_BYTE:
7891 if (depth > 1) {
7894 usersImage,dstImage,elementSize,groupSize,rowSize,
7895 imageSize,myswapBytes);
7896 }
7897 else {
7898 halveImage_ubyte(cmpts,width,height,usersImage,dstImage,
7899 elementSize,rowSize,groupSize);
7900 }
7901 break;
7902 case GL_BYTE:
7903 if (depth > 1) {
7906 usersImage,dstImage,elementSize,groupSize,rowSize,
7907 imageSize,myswapBytes);
7908 }
7909 else {
7910 halveImage_byte(cmpts,width,height,usersImage,dstImage,
7911 elementSize,rowSize,groupSize);
7912 }
7913 break;
7914 case GL_UNSIGNED_SHORT:
7915 if (depth > 1) {
7918 usersImage,dstImage,elementSize,groupSize,rowSize,
7919 imageSize,myswapBytes);
7920 }
7921 else {
7922 halveImage_ushort(cmpts,width,height,usersImage,dstImage,
7923 elementSize,rowSize,groupSize,myswapBytes);
7924 }
7925 break;
7926 case GL_SHORT:
7927 if (depth > 1) {
7930 usersImage,dstImage,elementSize,groupSize,rowSize,
7931 imageSize,myswapBytes);
7932 }
7933 else {
7934 halveImage_short(cmpts,width,height,usersImage,dstImage,
7935 elementSize,rowSize,groupSize,myswapBytes);
7936 }
7937 break;
7938 case GL_UNSIGNED_INT:
7939 if (depth > 1) {
7942 usersImage,dstImage,elementSize,groupSize,rowSize,
7943 imageSize,myswapBytes);
7944 }
7945 else {
7946 halveImage_uint(cmpts,width,height,usersImage,dstImage,
7947 elementSize,rowSize,groupSize,myswapBytes);
7948 }
7949 break;
7950 case GL_INT:
7951 if (depth > 1) {
7954 usersImage,dstImage,elementSize,groupSize,rowSize,
7955 imageSize,myswapBytes);
7956 }
7957 else {
7958 halveImage_int(cmpts,width,height,usersImage,dstImage,
7959 elementSize,rowSize,groupSize,myswapBytes);
7960 }
7961 break;
7962 case GL_FLOAT:
7963 if (depth > 1 ) {
7966 usersImage,dstImage,elementSize,groupSize,rowSize,
7967 imageSize,myswapBytes);
7968 }
7969 else {
7970 halveImage_float(cmpts,width,height,usersImage,dstImage,
7971 elementSize,rowSize,groupSize,myswapBytes);
7972 }
7973 break;
7975 assert(format == GL_RGB);
7977 width,height,depth,usersImage,dstImage,
7978 elementSize,rowSize,imageSize,myswapBytes);
7979 break;
7981 assert(format == GL_RGB);
7983 width,height,depth,usersImage,dstImage,
7984 elementSize,rowSize,imageSize,myswapBytes);
7985 break;
7988 width,height,depth,usersImage,dstImage,
7989 elementSize,rowSize,imageSize,myswapBytes);
7990 break;
7993 width,height,depth,usersImage,dstImage,
7994 elementSize,rowSize,imageSize,myswapBytes);
7995 break;
7998 width,height,depth,usersImage,dstImage,
7999 elementSize,rowSize,imageSize,myswapBytes);
8000 break;
8003 width,height,depth,usersImage,dstImage,
8004 elementSize,rowSize,imageSize,myswapBytes);
8005 break;
8008 width,height,depth,usersImage,dstImage,
8009 elementSize,rowSize,imageSize,myswapBytes);
8010 break;
8013 width,height,depth,usersImage,dstImage,
8014 elementSize,rowSize,imageSize,myswapBytes);
8015 break;
8018 width,height,depth,usersImage,dstImage,
8019 elementSize,rowSize,imageSize,myswapBytes);
8020 break;
8023 width,height,depth,usersImage,dstImage,
8024 elementSize,rowSize,imageSize,myswapBytes);
8025 break;
8028 width,height,depth,usersImage,dstImage,
8029 elementSize,rowSize,imageSize,myswapBytes);
8030 break;
8033 width,height,depth,usersImage,dstImage,
8034 elementSize,rowSize,imageSize,myswapBytes);
8035 break;
8036 default:
8037 assert(0);
8038 break;
8039 }
8040 newWidth = width/2;
8041 newHeight = height/2;
8042 newDepth = depth/2;
8043 /* clamp to 1 */
8044 if (newWidth < 1) newWidth= 1;
8045 if (newHeight < 1) newHeight= 1;
8046 if (newDepth < 1) newDepth= 1;
8047
8048 myswapBytes = 0;
8049 rowSize = newWidth * groupSize;
8050 imageSize= rowSize * newHeight; /* 3dstuff */
8051 memReq = imageSize3D(newWidth, newHeight, newDepth, format, type);
8052 /* Swap srcImage and dstImage */
8053 __GLU_SWAP_IMAGE(srcImage,dstImage);
8054 switch(type) {
8055 case GL_UNSIGNED_BYTE:
8056 dstImage = (GLubyte *)malloc(memReq);
8057 break;
8058 case GL_BYTE:
8059 dstImage = (GLbyte *)malloc(memReq);
8060 break;
8061 case GL_UNSIGNED_SHORT:
8062 dstImage = (GLushort *)malloc(memReq);
8063 break;
8064 case GL_SHORT:
8065 dstImage = (GLshort *)malloc(memReq);
8066 break;
8067 case GL_UNSIGNED_INT:
8068 dstImage = (GLuint *)malloc(memReq);
8069 break;
8070 case GL_INT:
8071 dstImage = (GLint *)malloc(memReq);
8072 break;
8073 case GL_FLOAT:
8074 dstImage = (GLfloat *)malloc(memReq);
8075 break;
8078 dstImage = (GLubyte *)malloc(memReq);
8079 break;
8086 dstImage = (GLushort *)malloc(memReq);
8087 break;
8092 dstImage = (GLuint *)malloc(memReq);
8093 break;
8094 default:
8095 return GLU_INVALID_ENUM; /* assertion */
8096 }
8097 if (dstImage == NULL) {
8105 free(srcImage);
8106 return GLU_OUT_OF_MEMORY;
8107 }
8108 /* level userLevel+1 is in srcImage; level userLevel already saved */
8109 level = userLevel+1;
8110 } else {/* user's image is *not* nice power-of-2 sized square */
8111 memReq = imageSize3D(newWidth, newHeight, newDepth, format, type);
8112 switch(type) {
8113 case GL_UNSIGNED_BYTE:
8114 dstImage = (GLubyte *)malloc(memReq);
8115 break;
8116 case GL_BYTE:
8117 dstImage = (GLbyte *)malloc(memReq);
8118 break;
8119 case GL_UNSIGNED_SHORT:
8120 dstImage = (GLushort *)malloc(memReq);
8121 break;
8122 case GL_SHORT:
8123 dstImage = (GLshort *)malloc(memReq);
8124 break;
8125 case GL_UNSIGNED_INT:
8126 dstImage = (GLuint *)malloc(memReq);
8127 break;
8128 case GL_INT:
8129 dstImage = (GLint *)malloc(memReq);
8130 break;
8131 case GL_FLOAT:
8132 dstImage = (GLfloat *)malloc(memReq);
8133 break;
8136 dstImage = (GLubyte *)malloc(memReq);
8137 break;
8144 dstImage = (GLushort *)malloc(memReq);
8145 break;
8150 dstImage = (GLuint *)malloc(memReq);
8151 break;
8152 default:
8153 return GLU_INVALID_ENUM; /* assertion */
8154 }
8155
8156 if (dstImage == NULL) {
8164 return GLU_OUT_OF_MEMORY;
8165 }
8166 /*printf("Build3DMipmaps(): ScaleImage3D %d %d %d->%d %d %d\n",
8167 width,height,depth,newWidth,newHeight,newDepth);*/
8168
8169 gluScaleImage3D(format, width, height, depth, type, usersImage,
8170 newWidth, newHeight, newDepth, type, dstImage);
8171
8172 myswapBytes = 0;
8173 rowSize = newWidth * groupSize;
8174 imageSize = rowSize * newHeight; /* 3dstuff */
8175 /* Swap dstImage and srcImage */
8176 __GLU_SWAP_IMAGE(srcImage,dstImage);
8177
8178 if(levels != 0) { /* use as little memory as possible */
8179 {
8180 int nextWidth= newWidth/2;
8181 int nextHeight= newHeight/2;
8182 int nextDepth= newDepth/2;
8183 if (nextWidth < 1) nextWidth= 1;
8184 if (nextHeight < 1) nextHeight= 1;
8185 if (nextDepth < 1) nextDepth= 1;
8186
8187 memReq = imageSize3D(nextWidth, nextHeight, nextDepth, format, type);
8188 }
8189 switch(type) {
8190 case GL_UNSIGNED_BYTE:
8191 dstImage = (GLubyte *)malloc(memReq);
8192 break;
8193 case GL_BYTE:
8194 dstImage = (GLbyte *)malloc(memReq);
8195 break;
8196 case GL_UNSIGNED_SHORT:
8197 dstImage = (GLushort *)malloc(memReq);
8198 break;
8199 case GL_SHORT:
8200 dstImage = (GLshort *)malloc(memReq);
8201 break;
8202 case GL_UNSIGNED_INT:
8203 dstImage = (GLuint *)malloc(memReq);
8204 break;
8205 case GL_INT:
8206 dstImage = (GLint *)malloc(memReq);
8207 break;
8208 case GL_FLOAT:
8209 dstImage = (GLfloat *)malloc(memReq);
8210 break;
8213 dstImage = (GLubyte *)malloc(memReq);
8214 break;
8221 dstImage = (GLushort *)malloc(memReq);
8222 break;
8227 dstImage = (GLuint *)malloc(memReq);
8228 break;
8229 default:
8230 return GLU_INVALID_ENUM; /* assertion */
8231 }
8232 if (dstImage == NULL) {
8240 free(srcImage);
8241 return GLU_OUT_OF_MEMORY;
8242 }
8243 }
8244 /* level userLevel is in srcImage; nothing saved yet */
8245 level = userLevel;
8246 }
8247
8249 if (baseLevel <= level && level <= maxLevel) {
8250 gluTexImage3D(target, level, internalFormat, newWidth, newHeight, newDepth,
8251 0,format, type, (void *)srcImage);
8252 }
8253 level++; /* update current level for the loop */
8254 for (; level <= levels; level++) {
8255 switch(type) {
8256 case GL_UNSIGNED_BYTE:
8257 if (newDepth > 1) {
8259 newWidth,newHeight,newDepth,
8260 srcImage,dstImage,elementSize,groupSize,rowSize,
8261 imageSize,myswapBytes);
8262 }
8263 else {
8264 halveImage_ubyte(cmpts,newWidth,newHeight,srcImage,dstImage,
8265 elementSize,rowSize,groupSize);
8266 }
8267 break;
8268 case GL_BYTE:
8269 if (newDepth > 1) {
8271 newWidth,newHeight,newDepth,
8272 srcImage,dstImage,elementSize,groupSize,rowSize,
8273 imageSize,myswapBytes);
8274 }
8275 else {
8276 halveImage_byte(cmpts,newWidth,newHeight,srcImage,dstImage,
8277 elementSize,rowSize,groupSize);
8278 }
8279 break;
8280 case GL_UNSIGNED_SHORT:
8281 if (newDepth > 1) {
8283 newWidth,newHeight,newDepth,
8284 srcImage,dstImage,elementSize,groupSize,rowSize,
8285 imageSize,myswapBytes);
8286 }
8287 else {
8288 halveImage_ushort(cmpts,newWidth,newHeight,srcImage,dstImage,
8289 elementSize,rowSize,groupSize,myswapBytes);
8290 }
8291 break;
8292 case GL_SHORT:
8293 if (newDepth > 1) {
8295 newWidth,newHeight,newDepth,
8296 srcImage,dstImage,elementSize,groupSize,rowSize,
8297 imageSize,myswapBytes);
8298 }
8299 else {
8300 halveImage_short(cmpts,newWidth,newHeight,srcImage,dstImage,
8301 elementSize,rowSize,groupSize,myswapBytes);
8302 }
8303 break;
8304 case GL_UNSIGNED_INT:
8305 if (newDepth > 1) {
8307 newWidth,newHeight,newDepth,
8308 srcImage,dstImage,elementSize,groupSize,rowSize,
8309 imageSize,myswapBytes);
8310 }
8311 else {
8312 halveImage_uint(cmpts,newWidth,newHeight,srcImage,dstImage,
8313 elementSize,rowSize,groupSize,myswapBytes);
8314 }
8315 break;
8316 case GL_INT:
8317 if (newDepth > 1) {
8319 newWidth,newHeight,newDepth,
8320 srcImage,dstImage,elementSize,groupSize,rowSize,
8321 imageSize,myswapBytes);
8322 }
8323 else {
8324 halveImage_int(cmpts,newWidth,newHeight,srcImage,dstImage,
8325 elementSize,rowSize,groupSize,myswapBytes);
8326 }
8327 break;
8328 case GL_FLOAT:
8329 if (newDepth > 1) {
8331 newWidth,newHeight,newDepth,
8332 srcImage,dstImage,elementSize,groupSize,rowSize,
8333 imageSize,myswapBytes);
8334 }
8335 else {
8336 halveImage_float(cmpts,newWidth,newHeight,srcImage,dstImage,
8337 elementSize,rowSize,groupSize,myswapBytes);
8338 }
8339 break;
8342 newWidth,newHeight,newDepth,
8343 srcImage,dstImage,elementSize,rowSize,
8344 imageSize,myswapBytes);
8345 break;
8348 newWidth,newHeight,newDepth,
8349 srcImage,dstImage,elementSize,rowSize,
8350 imageSize,myswapBytes);
8351 break;
8354 newWidth,newHeight,newDepth,
8355 srcImage,dstImage,elementSize,rowSize,
8356 imageSize,myswapBytes);
8357 break;
8360 newWidth,newHeight,newDepth,
8361 srcImage,dstImage,elementSize,rowSize,
8362 imageSize,myswapBytes);
8363 break;
8366 newWidth,newHeight,newDepth,
8367 srcImage,dstImage,elementSize,rowSize,
8368 imageSize,myswapBytes);
8369 break;
8372 newWidth,newHeight,newDepth,
8373 srcImage,dstImage,elementSize,rowSize,
8374 imageSize,myswapBytes);
8375 break;
8378 newWidth,newHeight,newDepth,
8379 srcImage,dstImage,elementSize,rowSize,
8380 imageSize,myswapBytes);
8381 break;
8384 newWidth,newHeight,newDepth,
8385 srcImage,dstImage,elementSize,rowSize,
8386 imageSize,myswapBytes);
8387 break;
8390 newWidth,newHeight,newDepth,
8391 srcImage,dstImage,elementSize,rowSize,
8392 imageSize,myswapBytes);
8393 break;
8396 newWidth,newHeight,newDepth,
8397 srcImage,dstImage,elementSize,rowSize,
8398 imageSize,myswapBytes);
8399 break;
8402 newWidth,newHeight,newDepth,
8403 srcImage,dstImage,elementSize,rowSize,
8404 imageSize,myswapBytes);
8405 break;
8408 newWidth,newHeight,newDepth,
8409 srcImage,dstImage,elementSize,rowSize,
8410 imageSize,myswapBytes);
8411 break;
8412 default:
8413 assert(0);
8414 break;
8415 }
8416
8417 __GLU_SWAP_IMAGE(srcImage,dstImage);
8418
8419 if (newWidth > 1) { newWidth /= 2; rowSize /= 2;}
8420 if (newHeight > 1) { newHeight /= 2; imageSize = rowSize * newHeight; }
8421 if (newDepth > 1) newDepth /= 2;
8422 {
8423 /* call tex image with srcImage untouched since it's not padded */
8424 if (baseLevel <= level && level <= maxLevel) {
8425 gluTexImage3D(target, level, internalFormat, newWidth, newHeight,
8426 newDepth,0, format, type, (void *) srcImage);
8427 }
8428 }
8429 } /* for level */
8437
8438 free(srcImage); /*if you get to here, a srcImage has always been malloc'ed*/
8439 if (dstImage) { /* if it's non-rectangular and only 1 level */
8440 free(dstImage);
8441 }
8442 return 0;
8443} /* gluBuild3DMipmapLevelsCore() */
#define GL_UNPACK_SKIP_IMAGES
Definition: gl.h:1513
#define GL_UNPACK_IMAGE_HEIGHT
Definition: gl.h:1514
static void shoveSbyte(GLdouble, int, void *)
Definition: mipmap.c:8544
static GLdouble extractFloat(int, const void *)
Definition: mipmap.c:8641
static void shoveFloat(GLdouble, int, void *)
Definition: mipmap.c:8657
static void shoveUshort(GLdouble, int, void *)
Definition: mipmap.c:8565
static void shoveSint(GLdouble, int, void *)
Definition: mipmap.c:8634
static GLint imageSize3D(GLint, GLint, GLint, GLenum, GLenum)
Definition: mipmap.c:6673
static GLdouble extractUint(int, const void *)
Definition: mipmap.c:8595
static void shoveUint(GLdouble, int, void *)
Definition: mipmap.c:8611
static GLdouble extractSbyte(int, const void *)
Definition: mipmap.c:8535
static GLdouble extractSint(int, const void *)
Definition: mipmap.c:8618
static void shoveSshort(GLdouble, int, void *)
Definition: mipmap.c:8588
static GLdouble extractUshort(int, const void *)
Definition: mipmap.c:8549
static GLdouble extractUbyte(int, const void *)
Definition: mipmap.c:8519
static int gluScaleImage3D(GLenum format, GLint widthIn, GLint heightIn, GLint depthIn, GLenum typeIn, const void *dataIn, GLint widthOut, GLint heightOut, GLint depthOut, GLenum typeOut, void *dataOut)
Definition: mipmap.c:7356
static void retrieveStoreModes3D(PixelStorageModes *psm)
Definition: mipmap.c:266
static void halveImagePackedPixel3D(int components, void(*extractPackedPixel)(int, const void *, GLfloat[]), void(*shovePackedPixel)(const GLfloat[], int, void *), GLint width, GLint height, GLint depth, const void *dataIn, void *dataOut, GLint pixelSizeInBytes, GLint rowSizeInBytes, GLint imageSizeInBytes, GLint isSwap)
Definition: mipmap.c:7606
static GLdouble extractSshort(int, const void *)
Definition: mipmap.c:8572
static void halveImage3D(int, GLdouble(*)(int, const void *), void(*)(GLdouble, int, void *), GLint, GLint, GLint, const void *, void *, GLint, GLint, GLint, GLint, GLint)
Definition: mipmap.c:8826
static void shoveUbyte(GLdouble, int, void *)
Definition: mipmap.c:8528

Referenced by gluBuild3DMipmapLevels(), and gluBuild3DMipmaps().

◆ gluBuild3DMipmaps()

GLint GLAPIENTRY gluBuild3DMipmaps ( GLenum  target,
GLint  internalFormat,
GLsizei  width,
GLsizei  height,
GLsizei  depth,
GLenum  format,
GLenum  type,
const void data 
)

Definition at line 8484 of file mipmap.c.

8487{
8488 GLint widthPowerOf2, heightPowerOf2, depthPowerOf2;
8489 int level, levels;
8490
8492 if (rc != 0) return rc;
8493
8494 if (width < 1 || height < 1 || depth < 1) {
8495 return GLU_INVALID_VALUE;
8496 }
8497
8498 if(type == GL_BITMAP) {
8499 return GLU_INVALID_ENUM;
8500 }
8501
8503 &widthPowerOf2,&heightPowerOf2,&depthPowerOf2);
8504
8505 levels = computeLog(widthPowerOf2);
8506 level = computeLog(heightPowerOf2);
8507 if (level > levels) levels=level;
8508 level = computeLog(depthPowerOf2);
8509 if (level > levels) levels=level;
8510
8512 width, height, depth,
8513 widthPowerOf2, heightPowerOf2,
8514 depthPowerOf2,
8515 format, type, 0, 0, levels,
8516 data);
8517} /* gluBuild3DMipmaps() */
static void closestFit3D(GLenum target, GLint width, GLint height, GLint depth, GLint internalFormat, GLenum format, GLenum type, GLint *newWidth, GLint *newHeight, GLint *newDepth)
Definition: mipmap.c:7412

◆ gluScaleImage()

GLAPI GLint GLAPIENTRY gluScaleImage ( GLenum  format,
GLsizei  widthin,
GLsizei  heightin,
GLenum  typein,
const void datain,
GLsizei  widthout,
GLsizei  heightout,
GLenum  typeout,
void dataout 
)

Definition at line 3498 of file mipmap.c.

3502{
3503 int components;
3504 GLushort *beforeImage;
3505 GLushort *afterImage;
3507
3508 if (widthin == 0 || heightin == 0 || widthout == 0 || heightout == 0) {
3509 return 0;
3510 }
3511 if (widthin < 0 || heightin < 0 || widthout < 0 || heightout < 0) {
3512 return GLU_INVALID_VALUE;