Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
PixelUpload.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
18#pragma once
19
20#include "../../core/Types.hpp"
21
22#include <cstring>
23
24namespace esengine {
25
29inline void stageTextureRows(u8* dst, const u8* src, u32 width, u32 height,
30 u32 srcBpp, u32 dstBpp, bool reverseRows) {
31 const usize srcRow = static_cast<usize>(width) * srcBpp;
32 const usize dstRow = static_cast<usize>(width) * dstBpp;
33 for (u32 row = 0; row < height; ++row) {
34 const u8* from = src + srcRow * (reverseRows ? (height - 1 - row) : row);
35 u8* to = dst + dstRow * row;
36 if (srcBpp == dstBpp) {
37 std::memcpy(to, from, srcRow);
38 continue;
39 }
40 for (u32 px = 0; px < width; ++px) {
41 std::memcpy(to + px * dstBpp, from + px * srcBpp, srcBpp);
42 to[px * dstBpp + 3] = 0xFF;
43 }
44 }
45}
46
47} // namespace esengine
Core type definitions and utilities for ESEngine.
std::size_t usize
Size type for indexing and sizes.
Definition Types.hpp:64
void stageTextureRows(u8 *dst, const u8 *src, u32 width, u32 height, u32 srcBpp, u32 dstBpp, bool reverseRows)
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41