Fixes
This commit is contained in:
parent
dddf968810
commit
29c84ae222
1 changed files with 12 additions and 4 deletions
|
@ -54,12 +54,22 @@ Backend_Surface* Backend_Init(SDL_Window *window)
|
||||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||||
|
|
||||||
if (renderer == NULL)
|
if (renderer == NULL)
|
||||||
return FALSE;
|
return NULL;
|
||||||
|
|
||||||
int width, height;
|
int width, height;
|
||||||
SDL_GetRendererOutputSize(renderer, &width, &height);
|
SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||||
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
|
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
|
||||||
|
|
||||||
|
if (framebuffer.texture == NULL)
|
||||||
|
{
|
||||||
|
SDL_DestroyRenderer(renderer);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
framebuffer.alpha = TRUE;
|
||||||
|
framebuffer.width = width;
|
||||||
|
framebuffer.height = height;
|
||||||
|
|
||||||
return &framebuffer;
|
return &framebuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +129,7 @@ unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch
|
||||||
|
|
||||||
*pitch = surface->width * (surface->alpha ? 4 : 3);
|
*pitch = surface->width * (surface->alpha ? 4 : 3);
|
||||||
|
|
||||||
surface->pixels = (unsigned char*)malloc(surface->width * surface->height * (surface->alpha ? 4 : 3));
|
surface->pixels = (unsigned char*)malloc(surface->height * *pitch);
|
||||||
|
|
||||||
return surface->pixels;
|
return surface->pixels;
|
||||||
}
|
}
|
||||||
|
@ -129,8 +139,6 @@ void Backend_UnlockSurface(Backend_Surface *surface)
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SDL_UnlockTexture(surface->texture);
|
|
||||||
|
|
||||||
if (surface->alpha)
|
if (surface->alpha)
|
||||||
{
|
{
|
||||||
SDL_UpdateTexture(surface->texture, NULL, surface->pixels, surface->width * 4);
|
SDL_UpdateTexture(surface->texture, NULL, surface->pixels, surface->width * 4);
|
||||||
|
|
Loading…
Add table
Reference in a new issue