format into texImage->TexFormat, the rest is handled by core Mesa.
-/* $Id: mtypes.h,v 1.33 2001/03/27 19:18:02 gareth Exp $ */
+/* $Id: mtypes.h,v 1.34 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
/* Texture format record */
struct gl_texture_format {
- GLint IntFormat; /* One of the MESA_FORMAT_* values */
+ GLint MesaFormat; /* One of the MESA_FORMAT_* values */
- GLenum BaseFormat;
- GLenum BaseType;
+ GLenum IntFormat; /* Internal format as GL enum value */
+ GLenum Type; /* Internal type as GL enum value */
GLubyte RedBits; /* Bits per texel component */
GLubyte GreenBits;
* GL_INTENSITY, GL_RGB, GL_RGBA,
* GL_COLOR_INDEX or GL_DEPTH_COMPONENT only.
*/
- GLenum Type; /* Texel type: GL_UNSIGNED_BYTE, etc. */
- GLenum IntFormat; /* Internal format as given by the user */
GLuint Border; /* 0 or 1 */
GLuint Width; /* = 2^WidthLog2 + 2*Border */
GLuint Height; /* = 2^HeightLog2 + 2*Border */
-/* $Id: texformat.c,v 1.5 2001/03/27 20:26:37 brianp Exp $ */
+/* $Id: texformat.c,v 1.6 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
*/
const struct gl_texture_format _mesa_texformat_rgba = {
- MESA_FORMAT_RGBA, /* IntFormat */
- GL_RGBA, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_RGBA, /* MesaFormat */
+ GL_RGBA, /* IntFormat */
+ CHAN_TYPE, /* Type */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_rgb = {
- MESA_FORMAT_RGB, /* IntFormat */
- GL_RGB, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_RGB, /* MesaFormat */
+ GL_RGB, /* IntFormat */
+ CHAN_TYPE, /* Type */
CHAN_BITS, /* RedBits */
CHAN_BITS, /* GreenBits */
CHAN_BITS, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_alpha = {
- MESA_FORMAT_ALPHA, /* IntFormat */
- GL_ALPHA, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_ALPHA, /* MesaFormat */
+ GL_ALPHA, /* IntFormat */
+ CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_luminance = {
- MESA_FORMAT_LUMINANCE, /* IntFormat */
- GL_LUMINANCE, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_LUMINANCE, /* MesaFormat */
+ GL_LUMINANCE, /* IntFormat */
+ CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_luminance_alpha = {
- MESA_FORMAT_LUMINANCE_ALPHA, /* IntFormat */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* IntFormat */
+ CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_intensity = {
- MESA_FORMAT_INTENSITY, /* IntFormat */
- GL_INTENSITY, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_INTENSITY, /* MesaFormat */
+ GL_INTENSITY, /* IntFormat */
+ CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_color_index = {
- MESA_FORMAT_COLOR_INDEX, /* IntFormat */
- GL_COLOR_INDEX, /* BaseFormat */
- CHAN_TYPE, /* BaseType */
+ MESA_FORMAT_COLOR_INDEX, /* MesaFormat */
+ GL_COLOR_INDEX, /* IntFormat */
+ CHAN_TYPE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_depth_component = {
- MESA_FORMAT_DEPTH_COMPONENT, /* IntFormat */
- GL_DEPTH_COMPONENT, /* BaseFormat */
- GL_FLOAT, /* BaseType */
+ MESA_FORMAT_DEPTH_COMPONENT, /* MesaFormat */
+ GL_DEPTH_COMPONENT, /* IntFormat */
+ GL_FLOAT, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
*/
const struct gl_texture_format _mesa_texformat_rgba8888 = {
- MESA_FORMAT_RGBA8888, /* IntFormat */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_RGBA8888, /* MesaFormat */
+ GL_RGBA, /* IntFormat */
+ GL_UNSIGNED_INT_8_8_8_8, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_argb8888 = {
- MESA_FORMAT_ARGB8888, /* IntFormat */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* FIXME: ??? */ /* BaseType */
+ MESA_FORMAT_ARGB8888, /* MesaFormat */
+ GL_BGRA, /* IntFormat */
+ GL_UNSIGNED_INT_8_8_8_8_REV, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_rgb888 = {
- MESA_FORMAT_RGB888, /* IntFormat */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_RGB888, /* MesaFormat */
+ GL_BGR, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
8, /* RedBits */
8, /* GreenBits */
8, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_rgb565 = {
- MESA_FORMAT_RGB565, /* IntFormat */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_SHORT_5_6_5, /* BaseType */
+ MESA_FORMAT_RGB565, /* MesaFormat */
+ GL_RGB, /* IntFormat */
+ GL_UNSIGNED_SHORT_5_6_5, /* Type */
5, /* RedBits */
6, /* GreenBits */
5, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_argb4444 = {
- MESA_FORMAT_ARGB4444, /* IntFormat */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_SHORT_4_4_4_4_REV, /* BaseType */
+ MESA_FORMAT_ARGB4444, /* MesaFormat */
+ GL_BGRA, /* IntFormat */
+ GL_UNSIGNED_SHORT_4_4_4_4_REV, /* Type */
4, /* RedBits */
4, /* GreenBits */
4, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_argb1555 = {
- MESA_FORMAT_ARGB1555, /* IntFormat */
- GL_RGBA, /* BaseFormat */
- GL_UNSIGNED_SHORT_1_5_5_5_REV, /* BaseType */
+ MESA_FORMAT_ARGB1555, /* MesaFormat */
+ GL_BGRA, /* IntFormat */
+ GL_UNSIGNED_SHORT_1_5_5_5_REV, /* Type */
5, /* RedBits */
5, /* GreenBits */
5, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_al88 = {
- MESA_FORMAT_AL88, /* IntFormat */
- GL_LUMINANCE_ALPHA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_AL88, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_rgb332 = {
- MESA_FORMAT_RGB332, /* IntFormat */
- GL_RGB, /* BaseFormat */
- GL_UNSIGNED_BYTE_3_3_2, /* BaseType */
+ MESA_FORMAT_RGB332, /* MesaFormat */
+ GL_RGB, /* IntFormat */
+ GL_UNSIGNED_BYTE_3_3_2, /* Type */
3, /* RedBits */
3, /* GreenBits */
2, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_a8 = {
- MESA_FORMAT_A8, /* IntFormat */
- GL_ALPHA, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_A8, /* MesaFormat */
+ GL_ALPHA, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_l8 = {
- MESA_FORMAT_L8, /* IntFormat */
- GL_LUMINANCE, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_L8, /* MesaFormat */
+ GL_LUMINANCE, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_i8 = {
- MESA_FORMAT_I8, /* IntFormat */
- GL_INTENSITY, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_I8, /* MesaFormat */
+ GL_INTENSITY, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
};
const struct gl_texture_format _mesa_texformat_ci8 = {
- MESA_FORMAT_CI8, /* IntFormat */
- GL_COLOR_INDEX, /* BaseFormat */
- GL_UNSIGNED_BYTE, /* BaseType */
+ MESA_FORMAT_CI8, /* MesaFormat */
+ GL_COLOR_INDEX, /* IntFormat */
+ GL_UNSIGNED_BYTE, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
*/
const struct gl_texture_format _mesa_null_texformat = {
- -1, /* IntFormat */
- 0, /* BaseFormat */
- 0, /* BaseType */
+ -1, /* MesaFormat */
+ 0, /* IntFormat */
+ 0, /* Type */
0, /* RedBits */
0, /* GreenBits */
0, /* BlueBits */
{
const struct gl_texture_format *texFormat;
- texImage->IntFormat = internalFormat;
-
/* Ask the driver for the base format, if it doesn't know, it will
* return -1;
*/
return;
}
- /* Initialize the base format and type.
- */
- texImage->Format = texFormat->BaseFormat;
- texImage->Type = texFormat->BaseType;
-
texImage->TexFormat = texFormat;
}
-/* $Id: teximage.c,v 1.87 2001/03/26 20:02:38 brianp Exp $ */
+/* $Id: teximage.c,v 1.88 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
/*
* Compute log base 2 of n.
* If n isn't an exact power of two return -1.
- * If n<0 return -1.
+ * If n < 0 return -1.
*/
static int
logbase2( int n )
GLint i = 1;
GLint log2 = 0;
- if (n<0) {
+ if (n < 0) {
return -1;
}
GLint
_mesa_base_tex_format( GLcontext *ctx, GLint format )
{
- /*
- * Ask the driver for the base format, if it doesn't
- * know, it will return -1;
- */
+ /*
+ * Ask the driver for the base format, if it doesn't
+ * know, it will return -1;
+ */
if (ctx->Driver.BaseCompressedTexFormat) {
GLint ifmt = (*ctx->Driver.BaseCompressedTexFormat)(ctx, format);
if (ifmt >= 0) {
{
ASSERT(img);
img->Format = 0;
- img->Type = 0;
- img->IntFormat = 0;
img->Border = 0;
img->Width = 0;
img->Height = 0;
GLint border, GLenum internalFormat)
{
ASSERT(img);
-
- img->IntFormat = internalFormat;
+ img->Format = _mesa_base_tex_format( ctx, internalFormat );
img->Border = border;
img->Width = width;
img->Height = height;
return GL_TRUE;
}
- if (!is_compressed_format(ctx, internalFormat)) {
- if (!_mesa_is_legal_format_and_type( format, type )) {
- /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
- * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
- */
- if (!isProxy) {
- char message[100];
- sprintf(message, "glTexImage%dD(format or type)", dimensions);
- _mesa_error(ctx, GL_INVALID_OPERATION, message);
- }
- return GL_TRUE;
+ if (!is_compressed_format( ctx, internalFormat ) &&
+ !_mesa_is_legal_format_and_type( format, type )) {
+ /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
+ * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
+ */
+ if (!isProxy) {
+ char message[100];
+ sprintf(message, "glTexImage%dD(format or type)", dimensions);
+ _mesa_error(ctx, GL_INVALID_OPERATION, message);
}
+ return GL_TRUE;
}
/* if we get here, the parameters are OK */
_mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)");
return GL_TRUE;
}
- if (zoffset + depth > (GLint) (destTex->Depth+destTex->Border)) {
+ if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) {
_mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)");
return GL_TRUE;
}
}
- if (!is_compressed_format(ctx, destTex->IntFormat)) {
- if (!_mesa_is_legal_format_and_type(format, type)) {
- char message[100];
- sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
- _mesa_error(ctx, GL_INVALID_ENUM, message);
- return GL_TRUE;
- }
+ if (!is_compressed_format(ctx, destTex->TexFormat->IntFormat) &&
+ !_mesa_is_legal_format_and_type(format, type)) {
+ char message[100];
+ sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
+ _mesa_error(ctx, GL_INVALID_ENUM, message);
+ return GL_TRUE;
}
return GL_FALSE;
}
/* Border */
- if (border!=0 && border!=1) {
+ if (border != 0 && border != 1) {
char message[100];
sprintf(message, "glCopyTexImage%dD(border)", dimensions);
_mesa_error(ctx, GL_INVALID_VALUE, message);
}
/* Level */
- if (level<0 || level>=ctx->Const.MaxTextureLevels) {
+ if (level < 0 || level>=ctx->Const.MaxTextureLevels) {
char message[100];
sprintf(message, "glCopyTexImage%dD(level=%d)", dimensions, level);
_mesa_error(ctx, GL_INVALID_VALUE, message);
_mesa_error(ctx, GL_INVALID_VALUE, message);
return GL_TRUE;
}
- if (xoffset+width > (GLint) (teximage->Width+teximage->Border)) {
+ if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) {
char message[100];
sprintf(message, "glCopyTexSubImage%dD(xoffset+width)", dimensions);
_mesa_error(ctx, GL_INVALID_VALUE, message);
return GL_TRUE;
}
/* NOTE: we're adding the border here, not subtracting! */
- if (yoffset+height > (GLint) (teximage->Height+teximage->Border)) {
+ if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) {
char message[100];
sprintf(message, "glCopyTexSubImage%dD(yoffset+height)", dimensions);
_mesa_error(ctx, GL_INVALID_VALUE, message);
_mesa_error(ctx, GL_INVALID_VALUE, message);
return GL_TRUE;
}
- if (zoffset > (GLint) (teximage->Depth+teximage->Border)) {
+ if (zoffset > (GLint) (teximage->Depth + teximage->Border)) {
char message[100];
sprintf(message, "glCopyTexSubImage%dD(zoffset+depth)", dimensions);
_mesa_error(ctx, GL_INVALID_VALUE, message);
}
}
-#if 0
- /* one of these has to be non-zero! */
- ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits ||
- texImage->LuminanceBits || texImage->IntensityBits ||
- texImage->DepthBits);
- ASSERT(texImage->FetchTexel);
-#endif
+ ASSERT(texImage->TexFormat);
+ texImage->FetchTexel = texImage->TexFormat->FetchTexel1D;
/* state update */
texObj->Complete = GL_FALSE;
if (is_color_format(internalFormat)) {
_mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
- &postConvHeight);
+ &postConvHeight);
}
if (target == GL_TEXTURE_2D ||
}
}
-#if 0
- /* one of these has to be non-zero! */
- ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits ||
- texImage->LuminanceBits || texImage->IntensityBits ||
- texImage->DepthBits);
- ASSERT(texImage->FetchTexel);
-#endif
+ ASSERT(texImage->TexFormat);
+ texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
/* state update */
texObj->Complete = GL_FALSE;
else if (target == GL_PROXY_TEXTURE_2D) {
/* Proxy texture: check for errors and update proxy state */
GLenum error = texture_error_check(ctx, target, level, internalFormat,
- format, type, 2,
- postConvWidth, postConvHeight, 1, border);
+ format, type, 2,
+ postConvWidth, postConvHeight, 1, border);
if (!error) {
struct gl_texture_unit *texUnit;
struct gl_texture_image *texImage;
}
}
-#if 0
- /* one of these has to be non-zero! */
- ASSERT(texImage->RedBits || texImage->IndexBits || texImage->AlphaBits ||
- texImage->LuminanceBits || texImage->IntensityBits ||
- texImage->DepthBits);
- ASSERT(texImage->FetchTexel);
-#endif
+ ASSERT(texImage->TexFormat);
+ texImage->FetchTexel = texImage->TexFormat->FetchTexel3D;
/* state update */
texObj->Complete = GL_FALSE;
-/* $Id: texstate.c,v 1.39 2001/03/26 19:42:40 brianp Exp $ */
+/* $Id: texstate.c,v 1.40 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
case GL_TEXTURE_DEPTH:
*params = img->Depth;
return;
- case GL_TEXTURE_COMPONENTS:
- *params = img->IntFormat;
+ case GL_TEXTURE_INTERNAL_FORMAT:
+ *params = img->TexFormat->IntFormat;
return;
case GL_TEXTURE_BORDER:
*params = img->Border;
-/* $Id: texstore.c,v 1.20 2001/03/27 20:26:10 brianp Exp $ */
+/* $Id: texstore.c,v 1.21 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
/* setup the teximage struct's fields */
_mesa_init_tex_format( ctx, internalFormat, texImage );
- texImage->FetchTexel = texImage->TexFormat->FetchTexel1D;
texelBytes = texImage->TexFormat->TexelBytes;
/* setup the teximage struct's fields */
_mesa_init_tex_format( ctx, internalFormat, texImage );
- texImage->FetchTexel = texImage->TexFormat->FetchTexel2D;
texelBytes = texImage->TexFormat->TexelBytes;
/* setup the teximage struct's fields */
_mesa_init_tex_format( ctx, internalFormat, texImage );
- texImage->FetchTexel = texImage->TexFormat->FetchTexel3D;
texelBytes = texImage->TexFormat->TexelBytes;
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- const GLint components = components_in_intformat(texImage->IntFormat);
- const GLint compSize = _mesa_sizeof_type(texImage->Type);
_mesa_transfer_teximage(ctx, 2, texImage->Format, texImage->Data,
width, height, 1, /* src size */
xoffset, yoffset, 0, /* dest offsets */
- texImage->Width * components * compSize,
+ texImage->Width * texImage->TexFormat->TexelBytes,
0, /* dstImageStride */
format, type, pixels, packing);
}
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
{
- const GLint components = components_in_intformat(texImage->IntFormat);
- const GLint compSize = _mesa_sizeof_type(texImage->Type);
+ const GLint texelBytes = texImage->TexFormat->TexelBytes;
_mesa_transfer_teximage(ctx, 3, texImage->Format, texImage->Data,
width, height, depth, /* src size */
xoffset, yoffset, xoffset, /* dest offsets */
- texImage->Width * components * compSize,
- texImage->Width * texImage->Height * components
- * compSize,
+ texImage->Width * texelBytes,
+ texImage->Width * texImage->Height * texelBytes,
format, type, pixels, packing);
}
struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- const struct gl_texture_format *texFormat;
(void) format;
(void) type;
/* setup the teximage struct's fields */
_mesa_init_tex_format( ctx, internalFormat, texImage );
- texFormat = texImage->TexFormat;
- texImage->Format = texFormat->BaseFormat;
- texImage->Type = texFormat->BaseType;
-
return GL_TRUE;
}
-/* $Id: texutil.c,v 1.20 2001/03/27 20:32:24 brianp Exp $ */
+/* $Id: texutil.c,v 1.21 2001/03/28 20:40:51 gareth Exp $ */
/*
* Mesa 3-D graphics library
#define DST_TEXELS_PER_DWORD 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+ dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[0], src[1], src[2], src[3] )
+ dst = PACK_COLOR_8888( src[0], src[1], src[2], src[3] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[0], src[1], src[2], 0xff )
+ dst = PACK_COLOR_8888( src[0], src[1], src[2], 0xff )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
#define DST_TEXELS_PER_DWORD 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
+ dst = PACK_COLOR_8888( src[3], src[2], src[1], src[0] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_8888( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_8888( 0xff, src[0], src[1], src[2] )
+ dst = PACK_COLOR_8888( 0xff, src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) CONVERT_TEXEL( dst, src )
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565( src[0], src[1], src[2] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565( src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
- (PACK_COLOR_565( src[3], src[4], src[5] ) << 16))
+ dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
+ (PACK_COLOR_565( src[3], src[4], src[5] ) << 16))
#define SRC_TEXEL_BYTES 3
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_565( src[0], src[1], src[2] )
+ dst = PACK_COLOR_565( src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
- (PACK_COLOR_565( src[4], src[5], src[6] ) << 16))
+ dst = ((PACK_COLOR_565( src[0], src[1], src[2] )) | \
+ (PACK_COLOR_565( src[4], src[5], src[6] ) << 16))
#define SRC_TEXEL_BYTES 4
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_4444( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_4444( src[3], src[0], src[1], src[2] )) |\
- (PACK_COLOR_4444( src[7], src[4], src[5], src[6] ) << 16))
+ dst = ((PACK_COLOR_4444( src[3], src[0], src[1], src[2] )) | \
+ (PACK_COLOR_4444( src[7], src[4], src[5], src[6] ) << 16))
#define SRC_TEXEL_BYTES 4
-#define TAG(x) x##_rgba8888_to_argb4444
+#define TAG(x) x##_abgr8888_to_argb4444
#include "texutil_tmp.h"
else if ( convert->format == GL_RGBA && \
convert->type == GL_UNSIGNED_BYTE ) \
{ \
- tab = name##_tab_rgba8888_to_argb4444; \
+ tab = name##_tab_abgr8888_to_argb4444; \
} \
else \
{ \
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- { const GLushort s = *(GLushort *)src; \
- dst = (s >> 1) | ((s & 1) << 15); }
+ { const GLushort s = *(GLushort *)src; \
+ dst = (s >> 1) | ((s & 1) << 15); }
#define CONVERT_TEXEL_DWORD( dst, src ) \
- { const GLuint s = *(GLuint *)src; \
- dst = (((s & 0xfffefffe) >> 1) | \
- ((s & 0x00010001) << 15)); }
+ { const GLuint s = *(GLuint *)src; \
+ dst = (((s & 0xfffefffe) >> 1) | \
+ ((s & 0x00010001) << 15)); }
#define SRC_TEXEL_BYTES 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
+ dst = PACK_COLOR_1555( src[3], src[0], src[1], src[2] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_1555( src[3], src[0], src[1], src[2] )) |\
- (PACK_COLOR_1555( src[7], src[4], src[5], src[6] ) << 16))
+ dst = ((PACK_COLOR_1555( src[3], src[0], src[1], src[2] )) | \
+ (PACK_COLOR_1555( src[7], src[4], src[5], src[6] ) << 16))
#define SRC_TEXEL_BYTES 4
-#define TAG(x) x##_rgba8888_to_argb1555
+#define TAG(x) x##_abgr8888_to_argb1555
#include "texutil_tmp.h"
else if ( convert->format == GL_RGBA && \
convert->type == GL_UNSIGNED_BYTE ) \
{ \
- tab = name##_tab_rgba8888_to_argb1555; \
+ tab = name##_tab_abgr8888_to_argb1555; \
} \
else \
{ \
#define DST_TEXELS_PER_DWORD 2
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[0], src[1] )
+ dst = PACK_COLOR_88( src[0], src[1] )
#define CONVERT_DIRECT
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[0], 0x00 )
+ dst = PACK_COLOR_88( src[0], 0x00 )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( src[0], 0x00 )) | \
- (PACK_COLOR_88( src[1], 0x00 ) << 16))
+ dst = ((PACK_COLOR_88( src[0], 0x00 )) | \
+ (PACK_COLOR_88( src[1], 0x00 ) << 16))
#define SRC_TEXEL_BYTES 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( 0xff, src[0] )
+ dst = PACK_COLOR_88( 0xff, src[0] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( 0xff, src[0] )) | \
- (PACK_COLOR_88( 0xff, src[1] ) << 16))
+ dst = ((PACK_COLOR_88( 0xff, src[0] )) | \
+ (PACK_COLOR_88( 0xff, src[1] ) << 16))
#define SRC_TEXEL_BYTES 1
#define CONVERT_TEXEL( dst, src ) \
- dst = PACK_COLOR_88( src[3], src[0] )
+ dst = PACK_COLOR_88( src[3], src[0] )
#define CONVERT_TEXEL_DWORD( dst, src ) \
- dst = ((PACK_COLOR_88( src[3], src[0] )) | \
- (PACK_COLOR_88( src[7], src[1] ) << 16))
+ dst = ((PACK_COLOR_88( src[3], src[0] )) | \
+ (PACK_COLOR_88( src[7], src[1] ) << 16))
#define SRC_TEXEL_BYTES 4
}
-/*
- * Convert a user's 2D image into a texture image. This basically repacks
- * pixel data into the special texture formats used by core Mesa and the DRI
- * drivers. This function can do full images or subimages.
+/* Convert a user's 2D image into a texture image. This basically
+ * repacks pixel data into the special texture formats used by core Mesa
+ * and the DRI drivers. This function can do full images or subimages.
*
- * We return a boolean because this function may not accept some kinds of
- * source image formats and/or types. For example, if the incoming
+ * We return a boolean because this function may not accept some kinds
+ * of source image formats and/or types. For example, if the incoming
* format/type = GL_BGR, GL_UNSIGNED_INT this function probably won't
* be able to do the conversion.
*
-/* $Id: s_texstore.c,v 1.1 2001/03/19 02:28:59 keithw Exp $ */
+/* $Id: s_texstore.c,v 1.2 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
ASSERT(ctx->Driver.TexImage1D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, 1);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage1D to do the real work */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- GLchan *image = read_color_image(ctx, x, y, width, 1);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, 1);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
return;
}
- /* now call glTexSubImage1D to do the real work */
+ /* call glTexSubImage1D to redefine the texture */
(*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
ASSERT(ctx->Driver.TexImage2D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage2D to do the real work */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
return;
}
- /* now call glTexSubImage2D to do the real work */
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage2D)(ctx, target, level,
xoffset, yoffset, width, height,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
ASSERT(ctx->Driver.TexImage3D);
- if (is_depth_format(texImage->IntFormat)) {
- /* read depth image from framebuffer */
- GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
return;
}
- /* call glTexImage1D to redefine the texture */
+ /* now call glTexSubImage3D to do the real work */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ GL_RGBA, CHAN_TYPE, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
else {
- /* read RGBA image from framebuffer */
- GLchan *image = read_color_image(ctx, x, y, width, height);
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
if (!image) {
- _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
return;
}
- /* now call glTexSubImage3D to do the real work */
+ /* call glTexImage1D to redefine the texture */
(*ctx->Driver.TexSubImage3D)(ctx, target, level,
xoffset, yoffset, zoffset, width, height, 1,
- GL_RGBA, CHAN_TYPE, image,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
&_mesa_native_packing, texObj, texImage);
FREE(image);
}
}
-
-/* $Id: s_texture.c,v 1.20 2001/03/26 19:42:40 brianp Exp $ */
+/* $Id: s_texture.c,v 1.21 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
#include "macros.h"
#include "mmath.h"
#include "mem.h"
+#include "texformat.h"
#include "teximage.h"
#include "s_context.h"
if (t->WrapS == GL_REPEAT &&
t->WrapT == GL_REPEAT &&
t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->Format == GL_RGB &&
- t->Image[baseLevel]->Type == CHAN_TYPE) {
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
swrast->TextureSample[texUnit] = opt_sample_rgb_2d;
}
else if (t->WrapS == GL_REPEAT &&
t->WrapT == GL_REPEAT &&
t->Image[baseLevel]->Border == 0 &&
- t->Image[baseLevel]->Format==GL_RGBA &&
- t->Image[baseLevel]->Type == CHAN_TYPE) {
+ t->Image[baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
swrast->TextureSample[texUnit] = opt_sample_rgba_2d;
}
else
-/* $Id: s_triangle.c,v 1.21 2001/03/22 04:54:08 brianp Exp $ */
+/* $Id: s_triangle.c,v 1.22 2001/03/28 20:40:52 gareth Exp $ */
/*
* Mesa 3-D graphics library
/*
* When the device driver doesn't implement triangle rasterization it
* can hook in _swrast_Triangle, which eventually calls one of these
- * functions to draw triangles.
+ * functions to draw triangles.
*/
#include "glheader.h"
SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLboolean rgbmode = ctx->Visual.rgbMode;
- if (ctx->Polygon.CullFlag &&
+ if (ctx->Polygon.CullFlag &&
ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
USE(nodraw_triangle);
return;
&& texObj2D->WrapT==GL_REPEAT
&& texImg->Border==0
&& (format == GL_RGB || format == GL_RGBA)
- && texImg->Type == CHAN_TYPE
+ && texImg->TexFormat->Type == CHAN_TYPE
&& minFilter == magFilter
&& ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
&& ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) {