Move from surfaces to the SDL render system

Ever since VVVVVV was initially ported to C++ in 2.0, it has used surfaces from SDL. The downside is, that's all software rendering. This commit moves most things off of surfaces, and all into GPU, by using textures and SDL_Renderer.

Pixel-perfect collision has been kept by keeping a copy of sprites as surfaces. There's plans for pixel-perfect collision to use masks instead of reading pixel data directly, but that's out of scope for this commit.

- `graphics.reloadresources()` is now called later in `main`, because textures cannot be created without a renderer.

- This commit also removes a bunch of surface functions which are no longer needed.

- This also recaches target textures in certain places for d3d9.

- graphics.images was converted to a fixed-size array.

- fillbox and fillboxabs use SDL_RenderDrawRect instead of drawing an outline using four filled rectangles

- Update my name in the credits
This commit is contained in:
AllyTally
2023-01-07 14:28:07 -04:00
committed by Misa Elizabeth Kai
parent 556e3a110a
commit 19b2a317f1
24 changed files with 1446 additions and 1387 deletions

View File

@@ -21,6 +21,7 @@
#include "Localization.h"
#include "LocalizationStorage.h"
#include "Map.h"
#include "Screen.h"
#include "Script.h"
#include "UtilityClass.h"
#include "Vlogging.h"
@@ -1539,7 +1540,11 @@ void customlevelclass::generatecustomminimap(void)
map.custommmxsize = 240 - (map.custommmxoff * 2);
map.custommmysize = 180 - (map.custommmyoff * 2);
FillRect(graphics.images[12], graphics.getRGB(0, 0, 0));
// Start drawing the minimap
SDL_Texture* target = SDL_GetRenderTarget(gameScreen.m_renderer);
graphics.set_render_target(graphics.images[IMAGE_CUSTOMMINIMAP]);
graphics.clear();
// Scan over the map size
for (int j2 = 0; j2 < mapheight; j2++)
@@ -1587,12 +1592,10 @@ void customlevelclass::generatecustomminimap(void)
if (tile >= 1)
{
// Fill in this pixel
FillRect(
graphics.images[12],
graphics.fill_rect(
(i2 * 12 * map.customzoom) + i,
(j2 * 9 * map.customzoom) + j,
1,
1,
1, 1,
graphics.getRGB(tm, tm, tm)
);
}
@@ -1600,6 +1603,8 @@ void customlevelclass::generatecustomminimap(void)
}
}
}
graphics.set_render_target(target);
}
// Return a graphics-ready color based off of the given tileset and tilecol