Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed BadMatch error in X11 renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Dec 13, 2008
1 parent f6f95c2 commit f8eb663
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/video/x11/SDL_x11render.c
Expand Up @@ -427,6 +427,15 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
&attributes);
depth = X11_GetDepthFromPixelFormat(data->format);

/* The image/pixmap depth must be the same as the window or you
get a BadMatch error when trying to putimage or copyarea.
*/
if (depth != attributes.depth) {
X11_DestroyTexture(renderer, texture);
SDL_SetError("Texture format doesn't match window format");
return -1;
}

if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
#ifndef NO_SHARED_MEMORY
XShmSegmentInfo *shminfo = &data->shminfo;
Expand Down Expand Up @@ -475,6 +484,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
data->pixels = SDL_malloc(texture->h * data->pitch);
if (!data->pixels) {
X11_DestroyTexture(renderer, texture);
SDL_OutOfMemory();
return -1;
}
Expand All @@ -485,6 +495,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
SDL_BYTESPERPIXEL(data->format) * 8,
data->pitch);
if (!data->image) {
X11_DestroyTexture(renderer, texture);
SDL_SetError("XCreateImage() failed");
return -1;
}
Expand All @@ -494,6 +505,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
XCreatePixmap(renderdata->display, renderdata->window, texture->w,
texture->h, depth);
if (data->pixmap == None) {
X11_DestroyTexture(renderer, texture);
SDL_SetError("XCteatePixmap() failed");
return -1;
}
Expand All @@ -503,6 +515,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
ZPixmap, 0, NULL, texture->w, texture->h,
SDL_BYTESPERPIXEL(data->format) * 8, data->pitch);
if (!data->image) {
X11_DestroyTexture(renderer, texture);
SDL_SetError("XCreateImage() failed");
return -1;
}
Expand Down

0 comments on commit f8eb663

Please sign in to comment.