Fixes and tweaks
This commit is contained in:
parent
a679373c14
commit
81eb438482
4 changed files with 19 additions and 6 deletions
|
@ -86,6 +86,7 @@ BOOL Backend_Init(SDL_Window *window)
|
|||
|
||||
void Backend_Deinit(void)
|
||||
{
|
||||
SDL_DestroyTexture(screen_texture);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
}
|
||||
|
||||
|
@ -126,9 +127,10 @@ Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
|||
surface->needs_syncing = FALSE;
|
||||
|
||||
surface->next = surface_list_head;
|
||||
surface->prev = NULL;
|
||||
surface_list_head = surface;
|
||||
if (surface->next)
|
||||
surface->next->prev = surface;
|
||||
surface_list_head = surface;
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,12 @@ void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Sur
|
|||
rect_clamped.bottom -= overflow;
|
||||
}
|
||||
|
||||
if (rect_clamped.bottom - rect_clamped.top <= 0)
|
||||
return;
|
||||
|
||||
if (rect_clamped.right - rect_clamped.left <= 0)
|
||||
return;
|
||||
|
||||
// Do the actual blitting
|
||||
if (colour_key)
|
||||
{
|
||||
|
@ -205,6 +211,12 @@ void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned cha
|
|||
rect_clamped.bottom -= overflow;
|
||||
}
|
||||
|
||||
if (rect_clamped.bottom - rect_clamped.top <= 0)
|
||||
return;
|
||||
|
||||
if (rect_clamped.right - rect_clamped.left <= 0)
|
||||
return;
|
||||
|
||||
for (long j = 0; j < rect_clamped.bottom - rect_clamped.top; ++j)
|
||||
{
|
||||
unsigned char *source_pointer = &surface->pixels[((rect_clamped.top + j) * surface->pitch) + (rect_clamped.left * 3)];
|
||||
|
|
|
@ -92,24 +92,24 @@ BOOL StartDirectDraw(int lMagnification, int lColourDepth)
|
|||
break;
|
||||
}
|
||||
|
||||
rgb24_pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB24);
|
||||
|
||||
// Create renderer
|
||||
if (!Backend_Init(gWindow))
|
||||
return FALSE;
|
||||
|
||||
rgb24_pixel_format = SDL_AllocFormat(SDL_PIXELFORMAT_RGB24);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void EndDirectDraw()
|
||||
{
|
||||
SDL_FreeFormat(rgb24_pixel_format);
|
||||
|
||||
// Release all surfaces
|
||||
for (int i = 0; i < SURFACE_ID_MAX; i++)
|
||||
ReleaseSurface(i);
|
||||
|
||||
Backend_Deinit();
|
||||
|
||||
SDL_FreeFormat(rgb24_pixel_format);
|
||||
}
|
||||
|
||||
static BOOL IsEnableBitmap(SDL_RWops *fp)
|
||||
|
|
|
@ -298,7 +298,6 @@ int main(int argc, char *argv[])
|
|||
|
||||
StartDirectDraw(2, colourDepth);
|
||||
|
||||
fullscreen = TRUE;
|
||||
SDL_ShowCursor(0);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue