mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
working textures
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user