diff --git a/example/main.c b/example/main.c index b5c94cf..acb2906 100644 --- a/example/main.c +++ b/example/main.c @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */ -/* Updated: 2024/01/26 11:59:34 by maldavid ### ########.fr */ +/* Updated: 2024/02/24 01:07:56 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/src/core/bridge.cpp b/src/core/bridge.cpp index 3580fcd..f980141 100644 --- a/src/core/bridge.cpp +++ b/src/core/bridge.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */ -/* Updated: 2024/01/19 05:35:38 by maldavid ### ########.fr */ +/* Updated: 2024/02/23 22:37:24 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -120,7 +120,13 @@ extern "C" int mlx_get_image_pixel(void* mlx, void* img, int x, int y) { MLX_CHECK_APPLICATION_POINTER(mlx); - return static_cast(mlx)->getTexturePixel(img, x, y); + int color = static_cast(mlx)->getTexturePixel(img, x, y); + unsigned char color_bits[4]; + color_bits[0] = (color & 0x000000FF); + color_bits[1] = (color & 0x0000FF00) >> 8; + color_bits[2] = (color & 0x00FF0000) >> 16; + color_bits[3] = (color & 0xFF000000) >> 24; + return *reinterpret_cast(color_bits); } void mlx_set_image_pixel(void* mlx, void* img, int x, int y, int color) diff --git a/src/platform/inputs.cpp b/src/platform/inputs.cpp index 738fa1b..cc826f9 100644 --- a/src/platform/inputs.cpp +++ b/src/platform/inputs.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/05 16:30:19 by maldavid #+# #+# */ -/* Updated: 2024/01/16 07:59:15 by maldavid ### ########.fr */ +/* Updated: 2024/02/23 22:27:30 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -123,19 +123,19 @@ namespace mlx case SDL_WINDOWEVENT_FOCUS_GAINED: { if(win_hook.hook) - win_hook.hook(4, win_hook.param); + win_hook.hook(5, win_hook.param); break; } case SDL_WINDOWEVENT_LEAVE: { if(win_hook.hook) - win_hook.hook(5, win_hook.param); + win_hook.hook(6, win_hook.param); break; } case SDL_WINDOWEVENT_FOCUS_LOST: { if(win_hook.hook) - win_hook.hook(4, win_hook.param); + win_hook.hook(7, win_hook.param); break; } diff --git a/src/renderer/images/texture.cpp b/src/renderer/images/texture.cpp index 16d693f..1fe116f 100644 --- a/src/renderer/images/texture.cpp +++ b/src/renderer/images/texture.cpp @@ -6,7 +6,7 @@ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/03/31 18:03:35 by maldavid #+# #+# */ -/* Updated: 2024/01/18 10:18:22 by maldavid ### ########.fr */ +/* Updated: 2024/02/24 03:51:59 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ @@ -98,7 +98,11 @@ namespace mlx if(_map == nullptr) openCPUmap(); uint32_t color = _cpu_map[(y * getWidth()) + x]; - return (color); + uint8_t* bytes = reinterpret_cast(&color); + uint8_t tmp = bytes[0]; + bytes[0] = bytes[2]; + bytes[2] = tmp; + return *reinterpret_cast(bytes); } void Texture::openCPUmap()