mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Deduplicate BuildTextureRGBA functions
All of them contain the same loop.
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
#ifndef INCLUDED_TERRAINOVERLAY
|
||||
#define INCLUDED_TERRAINOVERLAY
|
||||
|
||||
#include "graphics/SColor.h"
|
||||
#include "graphics/ShaderTechniquePtr.h"
|
||||
#include "lib/code_annotation.h"
|
||||
#include "lib/posix/posix_types.h"
|
||||
@@ -212,6 +213,24 @@ public:
|
||||
*/
|
||||
static SColor4ub GetColor(std::size_t idx, std::uint8_t alpha);
|
||||
|
||||
static void OverwriteEachTile(std::uint8_t* data, const std::size_t w, const std::size_t h,
|
||||
const auto generate)
|
||||
{
|
||||
static_assert(std::is_invocable_r_v<SColor4ub, decltype(generate), int, int>);
|
||||
|
||||
for (int i{0}; i != static_cast<int>(h); ++i)
|
||||
{
|
||||
for (int j{0}; j != static_cast<int>(w); ++j)
|
||||
{
|
||||
SColor4ub color{generate(i, j)};
|
||||
*data++ = color.R;
|
||||
*data++ = color.G;
|
||||
*data++ = color.B;
|
||||
*data++ = color.A;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
void RenderAfterWater(
|
||||
Renderer::Backend::IDeviceCommandContext* deviceCommandContext, int cullGroup) final;
|
||||
|
||||
Reference in New Issue
Block a user