mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
fixing performance issue in text pipeline, working on event system
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/06 15:35:31 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/12 11:03:57 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,9 +20,9 @@ namespace mlx::core
|
||||
{
|
||||
void Application::run() noexcept
|
||||
{
|
||||
while(_in.is_running())
|
||||
while(_in->is_running())
|
||||
{
|
||||
_in.update();
|
||||
_in->update();
|
||||
for(auto& gs : _graphics)
|
||||
gs->beginRender();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/11 21:43:13 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/12 11:14:24 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -32,14 +32,12 @@ namespace mlx::core
|
||||
class Application
|
||||
{
|
||||
public:
|
||||
Application() : _in() {}
|
||||
Application() : _in(std::make_unique<Input>()) {}
|
||||
|
||||
inline void getMousePos(int* x, int* y) noexcept;
|
||||
inline void mouseMove(void* win, int x, int y) noexcept;
|
||||
|
||||
inline void mouseHook(int (*funct_ptr)(const char*, void*), void* param) noexcept;
|
||||
inline void keyHook(int (*funct_ptr)(const char*, void*), void* param) noexcept;
|
||||
inline void exposeHook(int (*funct_ptr)(const char*, void*), void* param) noexcept;
|
||||
inline void onEvent(int event, int (*funct_ptr)(int, void*), void* param) noexcept;
|
||||
|
||||
inline constexpr void enableAutoRepeat() noexcept;
|
||||
inline constexpr void disableAutoRepeat() noexcept;
|
||||
@@ -67,11 +65,11 @@ namespace mlx::core
|
||||
~Application() = default;
|
||||
|
||||
private:
|
||||
Input _in;
|
||||
TextureLibrary _texture_lib;
|
||||
std::list<TextureID> _texture_ids;
|
||||
std::vector<std::unique_ptr<GraphicsSupport>> _graphics;
|
||||
std::function<int(void*)> _loop_hook;
|
||||
std::unique_ptr<Input> _in;
|
||||
void* _param = nullptr;
|
||||
bool _is_loop_running = false;
|
||||
};
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace mlx::core
|
||||
{
|
||||
void Application::getMousePos(int* x, int* y) noexcept
|
||||
{
|
||||
*x = _in.getX();
|
||||
*y = _in.getY();
|
||||
*x = _in->getX();
|
||||
*y = _in->getY();
|
||||
}
|
||||
|
||||
void Application::mouseMove(void* win, int x, int y) noexcept
|
||||
@@ -27,29 +27,19 @@ namespace mlx::core
|
||||
SDL_FlushEvent(SDL_MOUSEMOTION);
|
||||
}
|
||||
|
||||
void Application::mouseHook(int (*funct_ptr)(const char*, void*), void* param) noexcept
|
||||
void Application::onEvent(int event, int (*funct_ptr)(int, void*), void* param) noexcept
|
||||
{
|
||||
_in.mouseHook(funct_ptr, param);
|
||||
}
|
||||
|
||||
void Application::keyHook(int (*funct_ptr)(const char*, void*), void* param) noexcept
|
||||
{
|
||||
_in.keyHook(funct_ptr, param);
|
||||
}
|
||||
|
||||
void Application::exposeHook(int (*funct_ptr)(const char*, void*), void* param) noexcept
|
||||
{
|
||||
_in.exposeHook(funct_ptr, param);
|
||||
_in->onEvent(event, funct_ptr, param);
|
||||
}
|
||||
|
||||
constexpr void Application::enableAutoRepeat() noexcept
|
||||
{
|
||||
_in.enableAutoRepeat();
|
||||
_in->enableAutoRepeat();
|
||||
}
|
||||
|
||||
constexpr void Application::disableAutoRepeat() noexcept
|
||||
{
|
||||
_in.disableAutoRepeat();
|
||||
_in->disableAutoRepeat();
|
||||
}
|
||||
|
||||
void Application::getScreenSize(int* w, int* h) noexcept
|
||||
@@ -101,6 +91,6 @@ namespace mlx::core
|
||||
|
||||
void Application::loopEnd() noexcept
|
||||
{
|
||||
_in.finish();
|
||||
_in->finish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
|
||||
/* Updated: 2023/04/11 21:42:56 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/04/12 11:16:52 by maldavid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -69,21 +69,9 @@ extern "C"
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx_mouse_hook(void* mlx, int (*funct_ptr)(const char*, void*), void* param)
|
||||
int mlx_on_event(void* mlx, int event, int (*funct_ptr)(int, void*), void* param)
|
||||
{
|
||||
static_cast<mlx::core::Application*>(mlx)->mouseHook(funct_ptr, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx_key_hook(void* mlx, int (*funct_ptr)(const char*, void*), void* param)
|
||||
{
|
||||
static_cast<mlx::core::Application*>(mlx)->keyHook(funct_ptr, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mlx_expose_hook(void* mlx, int (*funct_ptr)(const char*, void*), void* param)
|
||||
{
|
||||
static_cast<mlx::core::Application*>(mlx)->exposeHook(funct_ptr, param);
|
||||
static_cast<mlx::core::Application*>(mlx)->onEvent(event, funct_ptr, param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user