for (j = 0; j < numFaces; j++) {
struct gl_texture_image *texImg = texObj->Image[j][i];
if (texImg) {
- printf(" Face %u level %u: %d x %d x %d, format %s at %p\n",
+ printf(" Face %u level %u: %d x %d x %d, format %s\n",
j, i,
texImg->Width, texImg->Height, texImg->Depth,
- _mesa_get_format_name(texImg->TexFormat),
- texImg->Data);
+ _mesa_get_format_name(texImg->TexFormat));
if (writeImages == WRITE_ALL ||
(writeImages == WRITE_ONE && !written)) {
write_texture_image(texObj, j, i);
* Quick and dirty function to "print" a texture to stdout.
*/
void
-_mesa_print_texture(struct gl_context *ctx, const struct gl_texture_image *img)
+_mesa_print_texture(struct gl_context *ctx, struct gl_texture_image *img)
{
#if CHAN_TYPE != GL_UNSIGNED_BYTE
_mesa_problem(NULL, "PrintTexture not supported");
#else
+ const GLint slice = 0;
+ GLint srcRowStride;
GLuint i, j, c;
- const GLubyte *data = (const GLubyte *) img->Data;
+ GLubyte *data;
+
+ ctx->Driver.MapTextureImage(ctx, img, slice,
+ 0, 0, img->Width, img->Height, GL_MAP_READ_BIT,
+ &data, &srcRowStride);
if (!data) {
printf("No texture data\n");
- return;
}
+ else {
+ /* XXX add more formats or make into a new format utility function */
+ switch (img->TexFormat) {
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ c = 1;
+ break;
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_AL88_REV:
+ c = 2;
+ break;
+ case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR888:
+ c = 3;
+ break;
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ARGB8888:
+ c = 4;
+ break;
+ default:
+ _mesa_problem(NULL, "error in PrintTexture\n");
+ return;
+ }
- /* XXX add more formats or make into a new format utility function */
- switch (img->TexFormat) {
- case MESA_FORMAT_A8:
- case MESA_FORMAT_L8:
- case MESA_FORMAT_I8:
- case MESA_FORMAT_CI8:
- c = 1;
- break;
- case MESA_FORMAT_AL88:
- case MESA_FORMAT_AL88_REV:
- c = 2;
- break;
- case MESA_FORMAT_RGB888:
- case MESA_FORMAT_BGR888:
- c = 3;
- break;
- case MESA_FORMAT_RGBA8888:
- case MESA_FORMAT_ARGB8888:
- c = 4;
- break;
- default:
- _mesa_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 += (srcRowStride - img->Width) * c;
+ }
+ /* XXX use img->ImageStride here */
+ printf("\n");
- 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 += (img->RowStride - img->Width) * c;
}
- /* XXX use img->ImageStride here */
- printf("\n");
}
+
+ ctx->Driver.UnmapTextureImage(ctx, img, slice);
#endif
}