mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 07:03:34 +00:00
adding possible new feature
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/11 19:46:49 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/22 21:04:48 by kbz_8 ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace mlx::core
|
||||
|
||||
inline void getScreenSize(int* w, int* h) noexcept;
|
||||
|
||||
inline void* newGraphicsSuport(std::size_t w, std::size_t h, std::string title);
|
||||
inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title);
|
||||
inline void clearGraphicsSupport(void* win);
|
||||
inline void destroyGraphicsSupport(void* win);
|
||||
|
||||
|
||||
@@ -54,10 +54,19 @@ namespace mlx::core
|
||||
*h = DM.h;
|
||||
}
|
||||
|
||||
void* Application::newGraphicsSuport(std::size_t w, std::size_t h, std::string title)
|
||||
void* Application::newGraphicsSuport(std::size_t w, std::size_t h, const char* title)
|
||||
{
|
||||
_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, _graphics.size()));
|
||||
_in->addWindow(_graphics.back()->getWindow());
|
||||
auto it = std::find_if(_textures.begin(), _textures.end(), [=](const Texture& texture)
|
||||
{
|
||||
return &texture == reinterpret_cast<Texture*>(const_cast<char*>(title));
|
||||
});
|
||||
if(it != _textures.end())
|
||||
_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, reinterpret_cast<Texture*>(const_cast<char*>(title)), _graphics.size()));
|
||||
else
|
||||
{
|
||||
_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, _graphics.size()));
|
||||
_in->addWindow(_graphics.back()->getWindow());
|
||||
}
|
||||
return static_cast<void*>(&_graphics.back()->getID());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 15:13:55 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/15 21:04:50 by maldavid ### ########.fr */
|
||||
/* Updated: 2023/12/22 23:10:51 by kbz_8 ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -14,14 +14,30 @@
|
||||
|
||||
namespace mlx
|
||||
{
|
||||
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, const std::string& title, int id) :
|
||||
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, Texture* render_target, int id) :
|
||||
_window(nullptr),
|
||||
_text_put_pipeline(std::make_unique<TextPutPipeline>()),
|
||||
_renderer(std::make_unique<Renderer>()),
|
||||
_width(w),
|
||||
_height(h),
|
||||
_id(id)
|
||||
{
|
||||
_renderer->setWindow(nullptr);
|
||||
_renderer->init(render_target);
|
||||
_pixel_put_pipeline.init(w, h, *_renderer);
|
||||
_text_put_pipeline->init(_renderer.get());
|
||||
}
|
||||
|
||||
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id) :
|
||||
_window(std::make_shared<MLX_Window>(w, h, title)),
|
||||
_text_put_pipeline(std::make_unique<TextPutPipeline>()),
|
||||
_renderer(std::make_unique<Renderer>()),
|
||||
_width(w),
|
||||
_height(h),
|
||||
_id(id)
|
||||
{
|
||||
_renderer->setWindow(_window.get());
|
||||
_renderer->init();
|
||||
_renderer->init(nullptr);
|
||||
_pixel_put_pipeline.init(w, h, *_renderer);
|
||||
_text_put_pipeline->init(_renderer.get());
|
||||
}
|
||||
@@ -76,6 +92,7 @@ namespace mlx
|
||||
_text_put_pipeline->destroy();
|
||||
_pixel_put_pipeline.destroy();
|
||||
_renderer->destroy();
|
||||
_window->destroy();
|
||||
if(_window)
|
||||
_window->destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/04/02 14:49:49 by maldavid #+# #+# */
|
||||
/* Updated: 2023/12/11 19:47:03 by kbz_8 ### ########.fr */
|
||||
/* Updated: 2023/12/22 23:10:14 by kbz_8 ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -33,7 +33,8 @@ namespace mlx
|
||||
class GraphicsSupport : public non_copyable
|
||||
{
|
||||
public:
|
||||
GraphicsSupport(std::size_t w, std::size_t h, const std::string& title, int id);
|
||||
GraphicsSupport(std::size_t w, std::size_t h, Texture* render_target, int id);
|
||||
GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id);
|
||||
|
||||
inline int& getID() noexcept;
|
||||
inline std::shared_ptr<MLX_Window> getWindow();
|
||||
@@ -56,6 +57,8 @@ namespace mlx
|
||||
std::shared_ptr<MLX_Window> _window;
|
||||
std::unique_ptr<TextPutPipeline> _text_put_pipeline; // unique_ptr because of the size of the class
|
||||
std::unique_ptr<Renderer> _renderer;
|
||||
std::size_t _width = 0;
|
||||
std::size_t _height = 0;
|
||||
int _id;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mlx
|
||||
{
|
||||
if(!_renderer->beginFrame())
|
||||
return;
|
||||
_proj = glm::ortho<float>(0, _window->getWidth(), 0, _window->getHeight());
|
||||
_proj = glm::ortho<float>(0, _width, 0, _height);
|
||||
_renderer->getUniformBuffer()->setData(sizeof(_proj), &_proj);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user