fixing compatibility, workign on renderer

This commit is contained in:
2022-12-18 04:04:10 +01:00
parent b275918de6
commit c907c52968
48 changed files with 6535 additions and 75 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2022/10/05 19:23:15 by maldavid ### ########.fr */
/* Updated: 2022/12/18 03:45:13 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -16,6 +16,7 @@
#include <vector>
#include <memory>
#include <utility>
#include <functional>
#include "errors.h"
@@ -31,26 +32,32 @@ namespace mlx::core
inline void* new_window(std::size_t w, std::size_t h, std::string title)
{
_wins.emplace_back(std::make_shared<Window>(w, h, std::move(title), _wins.size()));
return reinterpret_cast<void*>(&_wins.back()->get_id());
_wins.emplace_back(std::make_shared<MLX_Window>(w, h, std::move(title), _wins.size()));
return static_cast<void*>(&_wins.back()->get_id());
}
inline int get_mouse_pos(void* win_ptr, int* x, int* y) noexcept
{
if(*reinterpret_cast<int*>(win_ptr) > _wins.size())
{
error::report(e_kind::error, "Invalid window pointer");
if(*static_cast<int*>(win_ptr) > _wins.size())
return -1;
}
}
inline void loop_hook(int (*f)(void*), void* param) { _loop_hook = f; _param = param; }
inline void loop_end() noexcept { _in.finish(); }
inline void pixel_put(void* win_ptr, int x, int y, int color) const noexcept { _wins[*static_cast<int*>(win_ptr)]->pixel_put(x, y, color); }
inline void destroy_window(void* win_ptr) { _wins[*static_cast<int*>(win_ptr)].reset(); }
void run() noexcept;
~Application() = default;
private:
Input _in;
std::vector<std::shared_ptr<Window>> _wins;
std::vector<std::shared_ptr<MLX_Window>> _wins;
std::function<int(void*)> _loop_hook;
void* _param = nullptr;
bool _is_loop_running = false;
};
}