transparency management added

This commit is contained in:
Kbz-8
2023-11-25 10:31:06 +01:00
parent 38768c85c9
commit 49c211cebc
7 changed files with 37 additions and 18 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
/* Updated: 2023/11/23 14:32:41 by maldavid ### ########.fr */
/* Updated: 2023/11/25 10:12:36 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -100,8 +100,8 @@ extern "C"
unsigned char color_bits[4];
color_bits[0] = (color & 0x00FF0000) >> 16;
color_bits[1] = (color & 0x0000FF00) >> 8;
color_bits[2] = color & 0x000000FF;
color_bits[3] = 0xFF;
color_bits[2] = (color & 0x000000FF);
color_bits[3] = (color & 0xFF000000) >> 24;
mlx->setTexturePixel(img, x, y, *reinterpret_cast<unsigned int*>(color_bits));
}

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
/* Updated: 2023/11/24 19:19:25 by maldavid ### ########.fr */
/* Updated: 2023/11/24 20:42:15 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
/* Updated: 2023/11/23 14:26:06 by maldavid ### ########.fr */
/* Updated: 2023/11/25 09:59:39 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -49,7 +49,7 @@ namespace mlx
~GraphicsSupport();
private:
std::unordered_set<TextureRenderData> _textures_to_render;
std::vector<TextureRenderData> _textures_to_render;
PixelPutPipeline _pixel_put_pipeline;
glm::mat4 _proj = glm::mat4(1.0);
std::shared_ptr<MLX_Window> _window;

View File

@@ -10,7 +10,9 @@
/* */
/* ************************************************************************** */
#include "renderer/images/texture.h"
#include <core/graphics.h>
#include <type_traits>
namespace mlx
{
@@ -44,7 +46,17 @@ namespace mlx
void GraphicsSupport::texturePut(Texture* texture, int x, int y)
{
_textures_to_render.emplace(texture, x, y);
_textures_to_render.emplace_back(texture, x, y);
std::size_t hash = std::hash<TextureRenderData>{}(_textures_to_render.back());
_textures_to_render.back().hash = hash;
auto it = std::find_if(_textures_to_render.begin(), _textures_to_render.end() - 1, [=](const TextureRenderData& rhs)
{
return rhs.hash == hash;
});
if(it != _textures_to_render.end() - 1)
_textures_to_render.erase(it);
}
void GraphicsSupport::loadFont(const std::filesystem::path& filepath, float scale)