mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 14:43:34 +00:00
fixing color bug
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 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);
|
||||
|
||||
void* newTexture(int w, int h);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace mlx::core
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 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 texturePut(std::shared_ptr<Texture> texture, int x, int y);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace mlx
|
||||
_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);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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();
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
if(!_buffer.isMapped())
|
||||
_buffer.mapMem(&_map);
|
||||
unsigned char* mem = static_cast<unsigned char*>(_map) + (y * _width * sizeof(uint32_t)) + (x * sizeof(uint32_t));
|
||||
uint32_t new_color = color & 0xFFFFFF00;
|
||||
new_color >>= 8;
|
||||
new_color |= (color << 24) & 0xFF000000;
|
||||
*reinterpret_cast<uint32_t*>(mem) = new_color;
|
||||
*reinterpret_cast<uint32_t*>(mem) = color;
|
||||
_has_been_modified = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 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 render(class Renderer& renderer) noexcept;
|
||||
VkDescriptorSet getDescriptorSet() noexcept;
|
||||
|
||||
Reference in New Issue
Block a user