mirror of
https://github.com/seekrs/MacroLibX.git
synced 2026-01-12 15:13:34 +00:00
yes
This commit is contained in:
@@ -42,7 +42,18 @@ extern "C"
|
||||
mlx::FatalError("invalid window size (%d x %d)", w, h);
|
||||
return NULL; // not nullptr for the C compatibility
|
||||
}
|
||||
return static_cast<mlx::Application*>(mlx)->NewGraphicsSuport(w, h, title);
|
||||
return static_cast<mlx::Application*>(mlx)->NewGraphicsSuport(w, h, title, false);
|
||||
}
|
||||
|
||||
void* mlx_new_resizable_window(void* mlx, int w, int h, const char* title)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
if(w <= 0 || h <= 0)
|
||||
{
|
||||
mlx::FatalError("invalid window size (%d x %d)", w, h);
|
||||
return NULL; // not nullptr for the C compatibility
|
||||
}
|
||||
return static_cast<mlx::Application*>(mlx)->NewGraphicsSuport(w, h, title, true);
|
||||
}
|
||||
|
||||
void mlx_set_window_position(void *mlx, void *win, int x, int y)
|
||||
@@ -51,7 +62,7 @@ extern "C"
|
||||
static_cast<mlx::Application*>(mlx)->SetGraphicsSupportPosition(win, x, y);
|
||||
}
|
||||
|
||||
int mlx_loop_hook(void* mlx, int (*f)(void*), void* param)
|
||||
void mlx_loop_hook(void* mlx, int (*f)(void*), void* param)
|
||||
{
|
||||
MLX_CHECK_APPLICATION_POINTER(mlx);
|
||||
static_cast<mlx::Application*>(mlx)->LoopHook(f, param);
|
||||
|
||||
@@ -16,9 +16,9 @@ namespace mlx
|
||||
p_scene = std::make_unique<Scene>();
|
||||
}
|
||||
|
||||
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id) :
|
||||
GraphicsSupport::GraphicsSupport(std::size_t w, std::size_t h, std::string title, int id, bool is_resizable) :
|
||||
m_put_pixel_manager(&m_renderer),
|
||||
p_window(std::make_shared<Window>(w, h, title)),
|
||||
p_window(std::make_shared<Window>(w, h, title, is_resizable)),
|
||||
m_id(id),
|
||||
m_has_window(true)
|
||||
{
|
||||
@@ -31,13 +31,10 @@ namespace mlx
|
||||
void GraphicsSupport::Render() noexcept
|
||||
{
|
||||
MLX_PROFILE_FUNCTION();
|
||||
if(m_renderer.BeginFrame())
|
||||
{
|
||||
m_renderer.BeginFrame();
|
||||
m_draw_layer = 0;
|
||||
m_scene_renderer.Render(*p_scene, m_renderer);
|
||||
m_renderer.EndFrame();
|
||||
}
|
||||
|
||||
m_renderer.EndFrame();
|
||||
#ifdef GRAPHICS_MEMORY_DUMP
|
||||
// dump memory to file every two seconds
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
@@ -47,12 +47,20 @@ namespace mlx
|
||||
DebugLog("SDL Manager initialized");
|
||||
}
|
||||
|
||||
Handle SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden, std::int32_t& id)
|
||||
Handle SDLManager::CreateWindow(const std::string& title, std::size_t w, std::size_t h, bool hidden, std::int32_t& id, bool is_resizable)
|
||||
{
|
||||
Internal::WindowInfos* infos = new Internal::WindowInfos;
|
||||
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));
|
||||
std::uint32_t flags = SDL_WINDOW_VULKAN;
|
||||
if(hidden)
|
||||
flags |= SDL_WINDOW_HIDDEN;
|
||||
else
|
||||
flags |= SDL_WINDOW_SHOWN;
|
||||
if(is_resizable)
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
|
||||
infos->window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, flags);
|
||||
if(!infos->window)
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user