comparison src/video/x11/SDL_x11render.c @ 2868:3b595278f813

Fixed BadMatch error in X11 renderer
author Sam Lantinga <slouken@libsdl.org>
date Sat, 13 Dec 2008 13:10:53 +0000
parents 99210400e8b9
children b801df19835f
comparison
equal deleted inserted replaced
2867:eec7adc3d1c5 2868:3b595278f813
425 425
426 XGetWindowAttributes(renderdata->display, renderdata->window, 426 XGetWindowAttributes(renderdata->display, renderdata->window,
427 &attributes); 427 &attributes);
428 depth = X11_GetDepthFromPixelFormat(data->format); 428 depth = X11_GetDepthFromPixelFormat(data->format);
429 429
430 /* The image/pixmap depth must be the same as the window or you
431 get a BadMatch error when trying to putimage or copyarea.
432 */
433 if (depth != attributes.depth) {
434 X11_DestroyTexture(renderer, texture);
435 SDL_SetError("Texture format doesn't match window format");
436 return -1;
437 }
438
430 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { 439 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
431 #ifndef NO_SHARED_MEMORY 440 #ifndef NO_SHARED_MEMORY
432 XShmSegmentInfo *shminfo = &data->shminfo; 441 XShmSegmentInfo *shminfo = &data->shminfo;
433 442
434 shm_error = True; 443 shm_error = True;
473 if (!data->image) 482 if (!data->image)
474 #endif /* not NO_SHARED_MEMORY */ 483 #endif /* not NO_SHARED_MEMORY */
475 { 484 {
476 data->pixels = SDL_malloc(texture->h * data->pitch); 485 data->pixels = SDL_malloc(texture->h * data->pitch);
477 if (!data->pixels) { 486 if (!data->pixels) {
487 X11_DestroyTexture(renderer, texture);
478 SDL_OutOfMemory(); 488 SDL_OutOfMemory();
479 return -1; 489 return -1;
480 } 490 }
481 491
482 data->image = 492 data->image =
483 XCreateImage(renderdata->display, attributes.visual, depth, 493 XCreateImage(renderdata->display, attributes.visual, depth,
484 ZPixmap, 0, data->pixels, texture->w, texture->h, 494 ZPixmap, 0, data->pixels, texture->w, texture->h,
485 SDL_BYTESPERPIXEL(data->format) * 8, 495 SDL_BYTESPERPIXEL(data->format) * 8,
486 data->pitch); 496 data->pitch);
487 if (!data->image) { 497 if (!data->image) {
498 X11_DestroyTexture(renderer, texture);
488 SDL_SetError("XCreateImage() failed"); 499 SDL_SetError("XCreateImage() failed");
489 return -1; 500 return -1;
490 } 501 }
491 } 502 }
492 } else { 503 } else {
493 data->pixmap = 504 data->pixmap =
494 XCreatePixmap(renderdata->display, renderdata->window, texture->w, 505 XCreatePixmap(renderdata->display, renderdata->window, texture->w,
495 texture->h, depth); 506 texture->h, depth);
496 if (data->pixmap == None) { 507 if (data->pixmap == None) {
508 X11_DestroyTexture(renderer, texture);
497 SDL_SetError("XCteatePixmap() failed"); 509 SDL_SetError("XCteatePixmap() failed");
498 return -1; 510 return -1;
499 } 511 }
500 512
501 data->image = 513 data->image =
502 XCreateImage(renderdata->display, attributes.visual, depth, 514 XCreateImage(renderdata->display, attributes.visual, depth,
503 ZPixmap, 0, NULL, texture->w, texture->h, 515 ZPixmap, 0, NULL, texture->w, texture->h,
504 SDL_BYTESPERPIXEL(data->format) * 8, data->pitch); 516 SDL_BYTESPERPIXEL(data->format) * 8, data->pitch);
505 if (!data->image) { 517 if (!data->image) {
518 X11_DestroyTexture(renderer, texture);
506 SDL_SetError("XCreateImage() failed"); 519 SDL_SetError("XCreateImage() failed");
507 return -1; 520 return -1;
508 } 521 }
509 } 522 }
510 523