-/* $Id: teximage.c,v 1.72 2001/02/06 23:35:26 brianp Exp $ */
+/* $Id: teximage.c,v 1.73 2001/02/07 03:27:41 brianp Exp $ */
/*
* Mesa 3-D graphics library
}
+/*
+ * Initialize basic fields of the gl_texture_image struct.
+ */
+static void
+init_teximage_fields(GLcontext *ctx,
+ struct gl_texture_image *img,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum internalFormat)
+{
+ ASSERT(img);
+
+ img->IntFormat = internalFormat;
+ img->Border = border;
+ img->Width = width;
+ img->Height = height;
+ img->Depth = depth;
+ img->WidthLog2 = logbase2(width - 2 * border);
+ if (height == 1) /* 1-D texture */
+ img->HeightLog2 = 0;
+ else
+ img->HeightLog2 = logbase2(height - 2 * border);
+ if (depth == 1) /* 2-D texture */
+ img->DepthLog2 = 0;
+ else
+ img->DepthLog2 = logbase2(depth - 2 * border);
+ img->Width2 = 1 << img->WidthLog2;
+ img->Height2 = 1 << img->HeightLog2;
+ img->Depth2 = 1 << img->DepthLog2;
+ img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
+ img->IsCompressed = is_compressed_format(ctx, internalFormat);
+}
+
+
/*
* Test glTexImage[123]D() parameters for errors.
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
+ init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
+ border, internalFormat);
if (ctx->NewState & _NEW_PIXEL)
gl_update_state(ctx);
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
+ init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1,
+ border, internalFormat);
if (ctx->NewState & _NEW_PIXEL)
gl_update_state(ctx);
texImage->Data = NULL;
}
clear_teximage_fields(texImage); /* not really needed, but helpful */
+ init_teximage_fields(ctx, texImage, width, height, depth, border,
+ internalFormat);
if (ctx->NewState & _NEW_PIXEL)
gl_update_state(ctx);
texImage->Data = NULL;
}
+ init_teximage_fields(ctx, texImage, width, 1, 1, border, internalFormat);
+
if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage1D);
(*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
texImage->Data = NULL;
}
+ init_teximage_fields(ctx, texImage, width, height, 1, border,
+ internalFormat);
+
if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage2D);
(*ctx->Driver.CompressedTexImage2D)(ctx, target, level,
texImage->Data = NULL;
}
+ init_teximage_fields(ctx, texImage, width, height, depth, border,
+ internalFormat);
+
if (ctx->Extensions.ARB_texture_compression) {
ASSERT(ctx->Driver.CompressedTexImage3D);
(*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
-/* $Id: texstore.c,v 1.1 2001/02/06 21:42:48 brianp Exp $ */
+/* $Id: texstore.c,v 1.2 2001/02/07 03:27:41 brianp Exp $ */
/*
* Mesa 3-D graphics library
-/*
- * Initialize most fields of a gl_texture_image struct.
- */
-static void
-init_teximage_fields( GLcontext *ctx,
- struct gl_texture_image *img,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum internalFormat )
-{
- ASSERT(img);
- ASSERT(!img->Data);
- img->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
- img->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
- set_teximage_component_sizes( img );
- img->IntFormat = internalFormat;
- img->Border = border;
- img->Width = width;
- img->Height = height;
- img->Depth = depth;
- img->WidthLog2 = logbase2(width - 2 * border);
- if (height == 1) /* 1-D texture */
- img->HeightLog2 = 0;
- else
- img->HeightLog2 = logbase2(height - 2 * border);
- if (depth == 1) /* 2-D texture */
- img->DepthLog2 = 0;
- else
- img->DepthLog2 = logbase2(depth - 2 * border);
- img->Width2 = 1 << img->WidthLog2;
- img->Height2 = 1 << img->HeightLog2;
- img->Depth2 = 1 << img->DepthLog2;
- img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
- img->IsCompressed = is_compressed_format(ctx, internalFormat);
-
- if (height == 1 && depth == 1) {
- img->FetchTexel = fetch_1d_texel;
- }
- else if (depth == 1) {
- img->FetchTexel = fetch_2d_texel;
- }
- else {
- img->FetchTexel = fetch_3d_texel;
- }
-}
-
-
-
/*
* Given an internal texture format enum or 1, 2, 3, 4 return the
* corresponding _base_ internal format: GL_ALPHA, GL_LUMINANCE,
}
/* setup the teximage struct's fields */
- init_teximage_fields(ctx, texImage, postConvWidth, 1, 1,
- border, internalFormat);
+ texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
+ texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
+ texImage->FetchTexel = fetch_1d_texel;
+ set_teximage_component_sizes(texImage);
/* allocate memory */
texImage->Data = (GLchan *) MALLOC(postConvWidth
}
/* setup the teximage struct's fields */
- init_teximage_fields(ctx, texImage, postConvWidth, postConvHeight, 1,
- border, internalFormat);
+ texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
+ texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
+ texImage->FetchTexel = fetch_2d_texel;
+ set_teximage_component_sizes(texImage);
/* allocate memory */
texImage->Data = (GLchan *) MALLOC(postConvWidth * postConvHeight
const GLint components = components_in_intformat(internalFormat);
/* setup the teximage struct's fields */
- init_teximage_fields(ctx, texImage, width, height, depth,
- border, internalFormat);
+ texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
+ texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
+ texImage->FetchTexel = fetch_3d_texel;
+ set_teximage_component_sizes(texImage);
/* allocate memory */
texImage->Data = (GLchan *) MALLOC(width * height * depth
* Drivers may have more stringent texture limits to enforce and will
* have to override this function.
*/
- init_teximage_fields(ctx, texImage, width, height, depth, border,
- internalFormat);
+ /* setup the teximage struct's fields */
+ texImage->Format = (GLenum) _mesa_base_tex_format(ctx, internalFormat);
+ texImage->Type = CHAN_TYPE; /* usually GL_UNSIGNED_BYTE */
+ set_teximage_component_sizes(texImage);
return GL_TRUE;
}