mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 01:48:15 +03:00
Add more draw functions, make less code use rectangles
Some code still used rectangles to draw things like lines and pixels, so this commit adds more draw functions to support drawing lines and pixels without directly using the renderer. Aside from making generated minimaps draw points instead of 1x1 rectangles, this commit also batches the point drawing for an additional speed increase.
This commit is contained in:
committed by
Misa Elizabeth Kai
parent
dc9c51dbf3
commit
5089bc373e
@@ -1697,15 +1697,10 @@ void customlevelclass::generatecustomminimap(void)
|
||||
{
|
||||
for (int i2 = 0; i2 < mapwidth; i2++)
|
||||
{
|
||||
int tm;
|
||||
if (getroomprop(i2, j2)->tileset == 1)
|
||||
{
|
||||
tm = 96;
|
||||
}
|
||||
else
|
||||
{
|
||||
tm = 196;
|
||||
}
|
||||
std::vector<SDL_Point> dark_points;
|
||||
std::vector<SDL_Point> light_points;
|
||||
|
||||
bool dark = getroomprop(i2, j2)->tileset == 1;
|
||||
|
||||
// Ok, now scan over each square
|
||||
for (int j = 0; j < 9 * map.customzoom; j++)
|
||||
@@ -1737,16 +1732,28 @@ void customlevelclass::generatecustomminimap(void)
|
||||
|
||||
if (tile >= 1)
|
||||
{
|
||||
// Fill in this pixel
|
||||
graphics.fill_rect(
|
||||
(i2 * 12 * map.customzoom) + i,
|
||||
(j2 * 9 * map.customzoom) + j,
|
||||
1, 1,
|
||||
graphics.getRGB(tm, tm, tm)
|
||||
);
|
||||
// Add this pixel
|
||||
SDL_Point point = { (i2 * 12 * map.customzoom) + i, (j2 * 9 * map.customzoom) + j };
|
||||
if (dark)
|
||||
{
|
||||
dark_points.push_back(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
light_points.push_back(point);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Draw them all at once
|
||||
if (!dark_points.empty())
|
||||
{
|
||||
graphics.draw_points(dark_points.data(), dark_points.size(), 96, 96, 96);
|
||||
}
|
||||
if (!light_points.empty())
|
||||
{
|
||||
graphics.draw_points(light_points.data(), light_points.size(), 196, 196, 196);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user