mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
fixing color bug
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/12 19:33:39 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:35:30 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/13 10:56:19 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:31:51 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace mlx::core
|
|||||||
inline void clearGraphicsSupport(void* win);
|
inline void clearGraphicsSupport(void* win);
|
||||||
inline void destroyGraphicsSupport(void* win);
|
inline void destroyGraphicsSupport(void* win);
|
||||||
|
|
||||||
inline void pixelPut(void* win, int x, int y, int color) const noexcept;
|
inline void pixelPut(void* win, int x, int y, uint32_t color) const noexcept;
|
||||||
inline void stringPut(void* win, int x, int y, int color, char* str);
|
inline void stringPut(void* win, int x, int y, int color, char* str);
|
||||||
|
|
||||||
void* newTexture(int w, int h);
|
void* newTexture(int w, int h);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace mlx::core
|
|||||||
_graphics[*static_cast<int*>(win)].reset();
|
_graphics[*static_cast<int*>(win)].reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::pixelPut(void* win, int x, int y, int color) const noexcept
|
void Application::pixelPut(void* win, int x, int y, uint32_t color) const noexcept
|
||||||
{
|
{
|
||||||
_graphics[*static_cast<int*>(win)]->pixelPut(x, y, color);
|
_graphics[*static_cast<int*>(win)]->pixelPut(x, y, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/12 19:34:22 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:49:40 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -144,13 +144,23 @@ extern "C"
|
|||||||
|
|
||||||
int mlx_pixel_put(void* mlx, void* win, int x, int y, int color)
|
int mlx_pixel_put(void* mlx, void* win, int x, int y, int color)
|
||||||
{
|
{
|
||||||
static_cast<mlx::core::Application*>(mlx)->pixelPut(win, x, y, color);
|
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;
|
||||||
|
static_cast<mlx::core::Application*>(mlx)->pixelPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str)
|
int mlx_string_put(void* mlx, void* win, int x, int y, int color, char* str)
|
||||||
{
|
{
|
||||||
static_cast<mlx::core::Application*>(mlx)->stringPut(win, x, y, color, str);
|
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;
|
||||||
|
static_cast<mlx::core::Application*>(mlx)->stringPut(win, x, y, *reinterpret_cast<unsigned int*>(color_bits), str);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/11 18:37:11 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:32:16 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace mlx
|
|||||||
inline void beginRender() noexcept;
|
inline void beginRender() noexcept;
|
||||||
|
|
||||||
inline void clearRenderData() noexcept;
|
inline void clearRenderData() noexcept;
|
||||||
inline void pixelPut(int x, int y, int color) noexcept;
|
inline void pixelPut(int x, int y, uint32_t color) noexcept;
|
||||||
inline void stringPut(int x, int y, int color, std::string str);
|
inline void stringPut(int x, int y, int color, std::string str);
|
||||||
inline void texturePut(std::shared_ptr<Texture> texture, int x, int y);
|
inline void texturePut(std::shared_ptr<Texture> texture, int x, int y);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace mlx
|
|||||||
_text_put_pipeline->clear();
|
_text_put_pipeline->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::pixelPut(int x, int y, int color) noexcept
|
void GraphicsSupport::pixelPut(int x, int y, uint32_t color) noexcept
|
||||||
{
|
{
|
||||||
_pixel_put_pipeline.setPixel(x, y, color);
|
_pixel_put_pipeline.setPixel(x, y, color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/31 15:14:50 by maldavid #+# #+# */
|
/* Created: 2023/03/31 15:14:50 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/13 14:51:37 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:32:54 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -30,17 +30,14 @@ namespace mlx
|
|||||||
return _texture.getSet();
|
return _texture.getSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelPutPipeline::setPixel(uint32_t x, uint32_t y, int color) noexcept
|
void PixelPutPipeline::setPixel(uint32_t x, uint32_t y, uint32_t color) noexcept
|
||||||
{
|
{
|
||||||
if(x < 0 || y < 0 || x > _width || y > _height)
|
if(x < 0 || y < 0 || x > _width || y > _height)
|
||||||
return;
|
return;
|
||||||
if(!_buffer.isMapped())
|
if(!_buffer.isMapped())
|
||||||
_buffer.mapMem(&_map);
|
_buffer.mapMem(&_map);
|
||||||
unsigned char* mem = static_cast<unsigned char*>(_map) + (y * _width * sizeof(uint32_t)) + (x * sizeof(uint32_t));
|
unsigned char* mem = static_cast<unsigned char*>(_map) + (y * _width * sizeof(uint32_t)) + (x * sizeof(uint32_t));
|
||||||
uint32_t new_color = color & 0xFFFFFF00;
|
*reinterpret_cast<uint32_t*>(mem) = color;
|
||||||
new_color >>= 8;
|
|
||||||
new_color |= (color << 24) & 0xFF000000;
|
|
||||||
*reinterpret_cast<uint32_t*>(mem) = new_color;
|
|
||||||
_has_been_modified = true;
|
_has_been_modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/31 13:18:50 by maldavid #+# #+# */
|
/* Created: 2023/03/31 13:18:50 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/03 14:22:35 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:32:34 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ namespace mlx
|
|||||||
|
|
||||||
void init(uint32_t width, uint32_t height, class Renderer& renderer) noexcept;
|
void init(uint32_t width, uint32_t height, class Renderer& renderer) noexcept;
|
||||||
|
|
||||||
void setPixel(uint32_t x, uint32_t y, int color) noexcept;
|
void setPixel(uint32_t x, uint32_t y, uint32_t color) noexcept;
|
||||||
void present() noexcept;
|
void present() noexcept;
|
||||||
void render(class Renderer& renderer) noexcept;
|
void render(class Renderer& renderer) noexcept;
|
||||||
VkDescriptorSet getDescriptorSet() noexcept;
|
VkDescriptorSet getDescriptorSet() noexcept;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
/* Created: 2022/10/04 17:55:21 by maldavid #+# #+# */
|
||||||
/* Updated: 2023/04/13 14:59:32 by maldavid ### ########.fr */
|
/* Updated: 2023/04/19 11:49:56 by maldavid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -24,14 +24,18 @@ int update(t_mlx *mlx)
|
|||||||
{
|
{
|
||||||
static int i = 0;
|
static int i = 0;
|
||||||
int j;
|
int j;
|
||||||
|
int k;
|
||||||
|
|
||||||
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100);
|
mlx_put_image_to_window(mlx->mlx, mlx->win, mlx->logo, 100, 100);
|
||||||
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
|
mlx_string_put(mlx->mlx, mlx->win, 20, 50, 0xFFFFFFFF, "that's a text");
|
||||||
j = 0;
|
j = 0;
|
||||||
|
k = 0;
|
||||||
while (j < 400)
|
while (j < 400)
|
||||||
{
|
{
|
||||||
mlx_pixel_put(mlx->mlx, mlx->win, j, j, 0xFF00FF01);
|
mlx_pixel_put(mlx->mlx, mlx->win, j, j, 0xFFFF0000 + k);
|
||||||
mlx_pixel_put(mlx->mlx, mlx->win, 399 - j, j, 0xFF0000FF);
|
mlx_pixel_put(mlx->mlx, mlx->win, 399 - j, j, 0xFF0000FF);
|
||||||
|
if (k < 255)
|
||||||
|
k++;
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user