-/* $Id: teximage.c,v 1.25 2000/03/23 16:23:14 brianp Exp $ */
/*
* Mesa 3-D graphics library
*/
+#ifdef DEBUG
+static void PrintTexture(const struct gl_texture_image *img)
+{
+ int i, j, c;
+ GLubyte *data = img->Data;
+
+ if (!data) {
+ printf("No texture data\n");
+ return;
+ }
+
+ switch (img->Format) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ case GL_COLOR_INDEX:
+ c = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ c = 2;
+ break;
+ case GL_RGB:
+ c = 3;
+ break;
+ case GL_RGBA:
+ c = 4;
+ break;
+ default:
+ gl_problem(NULL, "error in PrintTexture\n");
+ return;
+ }
+
+
+ for (i = 0; i < img->Height; i++) {
+ for (j = 0; j < img->Width; j++) {
+ if (c==1)
+ printf("%02x ", data[0]);
+ else if (c==2)
+ printf("%02x%02x ", data[0], data[1]);
+ else if (c==3)
+ printf("%02x%02x%02x ", data[0], data[1], data[2]);
+ else if (c==4)
+ printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
+ data += c;
+ }
+ printf("\n");
+ }
+}
+#endif
+
+
+
/*
* Compute log base 2 of n.
* If n isn't an exact power of two return -1.
* Return new gl_texture_image struct with all fields initialized to zero.
*/
struct gl_texture_image *
-gl_alloc_texture_image( void )
+_mesa_alloc_texture_image( void )
{
return CALLOC_STRUCT(gl_texture_image);
}
void
-gl_free_texture_image( struct gl_texture_image *teximage )
+_mesa_free_texture_image( struct gl_texture_image *teximage )
{
if (teximage->Data) {
FREE( teximage->Data );
}
/* Border */
- if (border!=0 && border!=1) {
+ if (border != 0 && border != 1) {
if (!isProxy) {
char message[100];
sprintf(message, "glTexImage%dD(border)", dimensions);
}
/* Level */
- if (level<0 || level>=ctx->Const.MaxTextureLevels) {
+ if (level < 0 || level >= ctx->Const.MaxTextureLevels) {
if (!isProxy) {
char message[100];
sprintf(message, "glTexImage%dD(level)", dimensions);
texImage = texObj->Image[level];
if (!texImage) {
- texImage = gl_alloc_texture_image();
+ texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
texImage = texObj->Image[level];
if (!texImage) {
- texImage = gl_alloc_texture_image();
+ texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
texImage = texObj->Image[level];
if (!texImage) {
- texImage = gl_alloc_texture_image();
+ texImage = _mesa_alloc_texture_image();
texObj->Image[level] = texImage;
if (!texImage) {
gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
* Fetch a texture image from the device driver.
* Store the results in the given texture object at the given mipmap level.
*/
-static void
-get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
- const struct gl_texture_object *texObj )
+void
+_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
+ const struct gl_texture_object *texObj )
{
GLvoid *image;
GLenum imgFormat, imgType;
if (!ctx->Driver.GetTexImage)
return;
- image = (*ctx->Driver.GetTexImage)( ctx, target, level,
+ image = (*ctx->Driver.GetTexImage)( ctx, target, level, texObj,
&imgFormat, &imgType, &freeImage);
if (!image)
return;
if (!texImage->Data) {
/* try to get the texture image from the device driver */
- get_teximage_from_driver(ctx, target, level, texObj);
+ _mesa_get_teximage_from_driver(ctx, target, level, texObj);
discardImage = GL_TRUE;
}
else {
const GLint xoffsetb = xoffset + texImage->Border;
GLboolean retain = GL_TRUE;
if (!texImage->Data) {
- get_teximage_from_driver( ctx, target, level, texObj );
+ _mesa_get_teximage_from_driver( ctx, target, level, texObj );
if (!texImage->Data) {
make_null_texture(texImage);
}
GLboolean retain = GL_TRUE;
if (!texImage->Data) {
- get_teximage_from_driver( ctx, target, level, texObj );
+ _mesa_get_teximage_from_driver( ctx, target, level, texObj );
if (!texImage->Data) {
make_null_texture(texImage);
}
texImage->IntFormat, texImage);
}
else if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_1D, texObj,
+ (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_2D, texObj,
level, texImage->IntFormat, texImage );
}
#endif
if (teximage->Data) {
copy_tex_sub_image(ctx, teximage, width, 1, x, y, xoffset, 0, 0);
/* tell driver about the change */
- /* XXX call Driver.TexSubImage instead? */
+ /* XXX this is obsolete */
if (ctx->Driver.TexImage) {
(*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
texUnit->CurrentD[1],
copy_tex_sub_image(ctx, teximage, width, height,
x, y, xoffset, yoffset, 0);
/* tell driver about the change */
- /* XXX call Driver.TexSubImage instead? */
+ /* XXX this is obsolete */
if (ctx->Driver.TexImage) {
(*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D,
texUnit->CurrentD[2],
copy_tex_sub_image(ctx, teximage, width, height,
x, y, xoffset, yoffset, zoffset);
/* tell driver about the change */
- /* XXX call Driver.TexSubImage instead? */
+ /* XXX this is obsolete */
if (ctx->Driver.TexImage) {
(*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D,
texUnit->CurrentD[3],