/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* application.h :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: maldavid +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */ /* Updated: 2023/04/25 15:23:31 by maldavid ### ########.fr */ /* */ /* ************************************************************************** */ #ifndef __MLX_APPLICATION__ #define __MLX_APPLICATION__ #include #include #include #include #include #include #include #include #include namespace mlx::core { class Application { public: Application() : _in(std::make_unique()) {} inline void getMousePos(int* x, int* y) noexcept; inline void mouseMove(void* win, int x, int y) noexcept; inline void onEvent(void* win, int event, int (*funct_ptr)(int, void*), void* param) noexcept; inline void getScreenSize(int* w, int* h) noexcept; inline void* newGraphicsSuport(std::size_t w, std::size_t h, std::string title); inline void clearGraphicsSupport(void* win); inline void destroyGraphicsSupport(void* win); inline void pixelPut(void* win, int x, int y, uint32_t color) const noexcept; inline void stringPut(void* win, int x, int y, int color, char* str); void* newTexture(int w, int h); void* newStbTexture(char* file, int* w, int* h); // stb textures are format managed by stb image (png, jpg, bpm, ...) inline void texturePut(void* win, void* img, int x, int y); inline int getTexturePixel(void* img, int x, int y); inline void setTexturePixel(void* img, int x, int y, uint32_t color); void destroyTexture(void* ptr); inline void loopHook(int (*f)(void*), void* param); inline void loopEnd() noexcept; void run() noexcept; ~Application() = default; private: std::list _textures; std::vector> _graphics; std::function _loop_hook; std::unique_ptr _in; void* _param = nullptr; bool _is_loop_running = false; }; } #include #endif // __MLX_APPLICATION__