ref: 3b395c26396ddd225c465fc8cc9c590dc833fbb7
parent: e1cd4cf8d8be8381fdb2b6c930e4d25f3b8d0ddc
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Feb 14 01:47:15 EST 2019
Draw.cpp fix and optimisations For whatever reason, alpha blending is enabled by default on surfaces. Disabling it should result in faster blits, and also follow DirectDraw's behaviour more closely.
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -155,6 +155,7 @@
{
//Create surface
surf[surf_no].surface = SDL_CreateRGBSurfaceWithFormat(0, bxsize * magnification, bysize * magnification, 0, SDL_PIXELFORMAT_RGBA32);
+ SDL_SetSurfaceBlendMode(surf[surf_no].surface, SDL_BLENDMODE_NONE);
if (surf[surf_no].surface == NULL)
{
@@ -224,7 +225,7 @@
}
else
{
- SDL_Surface *surface = SDL_LoadBMP_RW(fp, 1);
+ SDL_Surface *surface = SDL_LoadBMP_RW(fp, 0);
if (surface == NULL)
{
@@ -238,7 +239,6 @@
{
SDL_Rect dst_rect = {0, 0, surface->w, surface->h};
SDL_BlitSurface(surface, NULL, surf[surf_no].surface, &dst_rect);
- SDL_FreeSurface(surface);
surf[surf_no].needs_updating = true;
printf(" ^ Successfully loaded\n");
success = true;
@@ -287,6 +287,8 @@
}
}
+ fp->close(fp);
+
return success;
}
@@ -379,6 +381,7 @@
//Get texture of what's currently rendered on screen
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, SDL_PIXELFORMAT_RGBA32);
+ SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_NONE);
SDL_RenderReadPixels(gRenderer, NULL, SDL_PIXELFORMAT_RGBA32, surface->pixels, surface->pitch);
//Get rects
--
⑨