mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
removing xpm support bc frick xpm
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/05 13:42:39 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/06 15:27:21 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -63,27 +63,6 @@ namespace mlx::core
|
||||
return map;
|
||||
}
|
||||
|
||||
void* Application::newXpmTexture(char** data, int* w, int* h)
|
||||
{
|
||||
std::vector<uint8_t> pixels = parseXpmData(data, w, h);
|
||||
std::shared_ptr<Texture> texture = std::make_shared<Texture>();
|
||||
texture->create(pixels.data(), *w, *h, VK_FORMAT_R8G8B8A8_UNORM);
|
||||
TextureID id = _texture_lib.addTextureToLibrary(texture);
|
||||
_texture_ids.push_back(id);
|
||||
return &_texture_ids.back();
|
||||
}
|
||||
|
||||
void* Application::newXpmTexture(std::string filename, int* w, int* h)
|
||||
{
|
||||
/*
|
||||
std::shared_ptr<Texture> texture = std::make_shared<Texture>();
|
||||
texture->create(reinterpret_cast<uint8_t*>(xpm_image.data), *w, *h, VK_FORMAT_R8G8B8A8_UNORM);
|
||||
TextureID id = _texture_lib.addTextureToLibrary(texture);
|
||||
_texture_ids.push_back(id);
|
||||
return &_texture_ids.back();
|
||||
*/
|
||||
}
|
||||
|
||||
void Application::destroyTexture(void* ptr)
|
||||
{
|
||||
vkDeviceWaitIdle(Render_Core::get().getDevice().get());
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/04 20:53:21 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/06 15:27:32 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -49,10 +49,6 @@ namespace mlx::core
|
||||
inline void pixelPut(void* win_ptr, int x, int y, int color) const noexcept;
|
||||
|
||||
void* newTexture(int w, int h);
|
||||
#ifndef MLX_NO_XPM
|
||||
void* newXpmTexture(std::string filename, int* w, int* h);
|
||||
void* newXpmTexture(char** data, int* w, int* h);
|
||||
#endif
|
||||
void* newStbTexture(char* file, int* w, int* h); // stb textures are format managed by stb image (png, jpg, bpm, ...)
|
||||
char* mapTexture(void* img_ptr, int* bits_per_pixel, int* size_line, int* endian);
|
||||
inline void texturePut(void* win_ptr, void* img, int x, int y);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/04 21:02:29 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/06 15:27:54 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
#include <renderer/core/render_core.h>
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef MLX_NO_XPM
|
||||
#include <X11/xpm.h>
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
void* mlx_init()
|
||||
@@ -140,18 +136,6 @@ extern "C"
|
||||
return static_cast<mlx::core::Application*>(mlx)->newStbTexture(filename, width, height);
|
||||
}
|
||||
|
||||
#ifndef MLX_NO_XPM
|
||||
void* mlx_xpm_file_to_image(void* mlx, char* filename, int* width, int* height)
|
||||
{
|
||||
return static_cast<mlx::core::Application*>(mlx)->newXpmTexture(std::string(filename), width, height);
|
||||
}
|
||||
|
||||
void* mlx_xpm_to_image(void* mlx, char** xpm_data, int* width, int* height)
|
||||
{
|
||||
return static_cast<mlx::core::Application*>(mlx)->newXpmTexture(xpm_data, width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
||||
|
||||
@@ -6,13 +6,15 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/05 13:37:21 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/05 13:53:30 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/06 15:20:14 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <utils/xpm_reader.h>
|
||||
#include <core/errors.h>
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
@@ -29,12 +31,19 @@ namespace mlx
|
||||
return {};
|
||||
}
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t ncolors;
|
||||
uint32_t cpp; // chars per pixels
|
||||
int32_t width = -1;
|
||||
int32_t height = -1;
|
||||
int32_t ncolors = -1;
|
||||
int32_t cpp = -1; // chars per pixels
|
||||
//
|
||||
std::stringstream stream;
|
||||
|
||||
if(std::sscanf(data[0], "%d %d %d %d", &width, &height, &ncolors, &cpp) != 4)
|
||||
stream.str(data[0]);
|
||||
stream >> width;
|
||||
stream >> height;
|
||||
stream >> ncolors;
|
||||
stream >> cpp;
|
||||
if(width == -1 || height == -1 || ncolors == -1 || cpp == -1 || !stream.eof())
|
||||
{
|
||||
core::error::report(e_kind::error, "Xpm reader : invalid pixmap description");
|
||||
return {};
|
||||
@@ -42,5 +51,19 @@ namespace mlx
|
||||
|
||||
*w = width;
|
||||
*h = height;
|
||||
|
||||
stream.clear();
|
||||
std::vector<std::string> colors;
|
||||
colors.reserve(ncolors);
|
||||
std::cout << ncolors << std::endl;
|
||||
for(int32_t i = 1; i < ncolors; ++i)
|
||||
{
|
||||
std::cout << (bool)(i < ncolors) << std::endl;
|
||||
stream.str(data[i]);
|
||||
std::string c;
|
||||
stream >> c;
|
||||
|
||||
std::cout << ncolors << " " << i << " " << c << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user