working textures

This commit is contained in:
kbz_8
2023-04-01 15:48:28 +02:00
parent e9c3fb8046
commit 3a93881392
17 changed files with 387 additions and 138 deletions

View File

@@ -6,11 +6,12 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 22:10:52 by maldavid #+# #+# */
/* Updated: 2022/12/19 00:40:17 by maldavid ### ########.fr */
/* Updated: 2023/04/01 15:34:00 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
#include "application.h"
#include <renderer/images/texture.h>
namespace mlx::core
{
@@ -29,4 +30,29 @@ namespace mlx::core
win->endFrame();
}
}
void* Application::new_stb_texture(char* file, int* w, int* h)
{
std::shared_ptr<Texture> texture = std::make_shared<Texture>(stb_texture_load(file, w, h));
TextureID id = _texture_lib.addTextureToLibrary(texture);
_texture_ids.push_back(id);
return &_texture_ids.back();
}
void Application::texture_put(void* win, void* img, int x, int y)
{
std::shared_ptr<Texture> texture = _texture_lib.getTexture(*static_cast<TextureID*>(img));
_wins[*static_cast<int*>(win)]->texture_put(texture, x, y);
}
void Application::destroy_texture(void* ptr)
{
TextureID id = *static_cast<TextureID*>(ptr);
_texture_lib.removeTextureFromLibrary(id);
}
Application::~Application()
{
_texture_lib.clearLibrary();
}
}