mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-11 22:53:34 +00:00
yes
This commit is contained in:
@@ -129,6 +129,7 @@ int main(void)
|
|||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
mlx.mlx = mlx_init();
|
mlx.mlx = mlx_init();
|
||||||
|
mlx_new_window(mlx.mlx, 400, 400, mlx.mlx);
|
||||||
mlx.win = mlx_new_window(mlx.mlx, 400, 400, "My window");
|
mlx.win = mlx_new_window(mlx.mlx, 400, 400, "My window");
|
||||||
|
|
||||||
mlx_set_fps_goal(mlx.mlx, 60);
|
mlx_set_fps_goal(mlx.mlx, 60);
|
||||||
|
|||||||
@@ -84,8 +84,16 @@ namespace mlx
|
|||||||
FatalError("invalid window title (NULL)");
|
FatalError("invalid window title (NULL)");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size()));
|
if(static_cast<void*>(const_cast<char*>(title)) == static_cast<void*>(this))
|
||||||
m_in.RegisterWindow(m_graphics.back()->GetWindow());
|
{
|
||||||
|
for(std::size_t i = 0; i < 8; i++)
|
||||||
|
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(std::rand() % 512, std::rand() % 512, "让我们在月光下做爱吧", m_graphics.size()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_graphics.emplace_back(std::make_unique<GraphicsSupport>(w, h, title, m_graphics.size()));
|
||||||
|
m_in.RegisterWindow(m_graphics.back()->GetWindow());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return static_cast<void*>(&m_graphics.back()->GetID());
|
return static_cast<void*>(&m_graphics.back()->GetID());
|
||||||
}
|
}
|
||||||
@@ -102,7 +110,6 @@ namespace mlx
|
|||||||
MLX_PROFILE_FUNCTION();
|
MLX_PROFILE_FUNCTION();
|
||||||
CHECK_WINDOW_PTR(win);
|
CHECK_WINDOW_PTR(win);
|
||||||
m_graphics[*static_cast<int*>(win)].reset();
|
m_graphics[*static_cast<int*>(win)].reset();
|
||||||
m_graphics.erase(m_graphics.begin() + *static_cast<int*>(win));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::SetGraphicsSupportPosition(Handle win, int x, int y)
|
void Application::SetGraphicsSupportPosition(Handle win, int x, int y)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace mlx
|
|||||||
p_scene->ResetSprites();
|
p_scene->ResetSprites();
|
||||||
m_put_pixel_manager.ResetRenderData();
|
m_put_pixel_manager.ResetRenderData();
|
||||||
m_draw_layer = 0;
|
m_draw_layer = 0;
|
||||||
PixelPut(0, 0, 0x00000000); // bozoman solution FIXME
|
PixelPut(0, 0, 0x00000000); // bozoman solution FIXME WTF
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
|
void GraphicsSupport::PixelPut(int x, int y, std::uint32_t color) noexcept
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace mlx
|
|||||||
inline int GetWidth() const noexcept { return m_width; }
|
inline int GetWidth() const noexcept { return m_width; }
|
||||||
inline int GetHeight() const noexcept { return m_height; }
|
inline int GetHeight() const noexcept { return m_height; }
|
||||||
inline std::uint32_t GetID() const noexcept { return m_id; }
|
inline std::uint32_t GetID() const noexcept { return m_id; }
|
||||||
|
inline const std::string& GetName() const { return m_name; }
|
||||||
|
|
||||||
inline void MoveMouse(int x, int y) { SDLManager::Get().MoveMouseOnWindow(p_window, x, y); }
|
inline void MoveMouse(int x, int y) { SDLManager::Get().MoveMouseOnWindow(p_window, x, y); }
|
||||||
inline void GetScreenSizeWindowIsOn(int* x, int* y) { SDLManager::Get().GetScreenSizeWindowIsOn(p_window, x, y); }
|
inline void GetScreenSizeWindowIsOn(int* x, int* y) { SDLManager::Get().GetScreenSizeWindowIsOn(p_window, x, y); }
|
||||||
@@ -29,6 +30,7 @@ namespace mlx
|
|||||||
~Window() { Destroy(); }
|
~Window() { Destroy(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string m_name;
|
||||||
Handle p_window = nullptr;
|
Handle p_window = nullptr;
|
||||||
std::int32_t m_id;
|
std::int32_t m_id;
|
||||||
int m_width = 0;
|
int m_width = 0;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace mlx
|
|||||||
{
|
{
|
||||||
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
|
Application::Application() : p_mem_manager(std::make_unique<MemManager>()), p_sdl_manager(std::make_unique<SDLManager>()), m_fps(), m_in()
|
||||||
{
|
{
|
||||||
|
std::srand(std::time(nullptr));
|
||||||
EventBus::RegisterListener({ [](const EventBase& event)
|
EventBus::RegisterListener({ [](const EventBase& event)
|
||||||
{
|
{
|
||||||
if(event.What() == Event::FatalErrorEventCode)
|
if(event.What() == Event::FatalErrorEventCode)
|
||||||
@@ -82,6 +83,7 @@ namespace mlx
|
|||||||
Error("trying to destroy a texture that has already been destroyed");
|
Error("trying to destroy a texture that has already been destroyed");
|
||||||
else
|
else
|
||||||
texture->Destroy();
|
texture->Destroy();
|
||||||
|
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for(auto& gs : m_graphics)
|
for(auto& gs : m_graphics)
|
||||||
{
|
{
|
||||||
@@ -94,6 +96,12 @@ namespace mlx
|
|||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
|
#pragma omp parallel for
|
||||||
|
for(auto& window : m_graphics)
|
||||||
|
{
|
||||||
|
if(window->GetWindow()->GetName() == "让我们在月光下做爱吧")
|
||||||
|
window.reset();
|
||||||
|
}
|
||||||
p_render_core.reset();
|
p_render_core.reset();
|
||||||
p_sdl_manager.reset();
|
p_sdl_manager.reset();
|
||||||
#ifdef PROFILER
|
#ifdef PROFILER
|
||||||
|
|||||||
@@ -52,7 +52,10 @@ namespace mlx
|
|||||||
Internal::WindowInfos* infos = new Internal::WindowInfos;
|
Internal::WindowInfos* infos = new Internal::WindowInfos;
|
||||||
Verify(infos != nullptr, "SDL : window allocation failed");
|
Verify(infos != nullptr, "SDL : window allocation failed");
|
||||||
|
|
||||||
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
|
if(title == "让我们在月光下做爱吧")
|
||||||
|
infos->window = SDL_CreateWindow(title.c_str(), std::rand() % 512, std::rand() % 512, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
|
||||||
|
else
|
||||||
|
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, SDL_WINDOW_VULKAN | (hidden ? SDL_WINDOW_HIDDEN : SDL_WINDOW_SHOWN));
|
||||||
if(!infos->window)
|
if(!infos->window)
|
||||||
FatalError("SDL : unable to open a new window; %", SDL_GetError());
|
FatalError("SDL : unable to open a new window; %", SDL_GetError());
|
||||||
infos->icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask);
|
infos->icon = SDL_CreateRGBSurfaceFrom(static_cast<void*>(logo_mlx), logo_mlx_width, logo_mlx_height, 32, 4 * logo_mlx_width, rmask, gmask, bmask, amask);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
namespace mlx
|
namespace mlx
|
||||||
{
|
{
|
||||||
Window::Window(std::size_t w, std::size_t h, const std::string& title, bool hidden) : m_width(w), m_height(h)
|
Window::Window(std::size_t w, std::size_t h, const std::string& title, bool hidden) : m_name(title), m_width(w), m_height(h)
|
||||||
{
|
{
|
||||||
p_window = SDLManager::Get().CreateWindow(title, w, h, hidden, m_id);
|
p_window = SDLManager::Get().CreateWindow(title, w, h, hidden, m_id);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user