Skip to content

Commit

Permalink
resolving merge (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kbz-8 authored Sep 13, 2024
2 parents 6bc505d + 33d2b98 commit 20ec13d
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
13 changes: 12 additions & 1 deletion includes/mlx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
/* Updated: 2024/01/18 14:36:12 by maldavid ### ########.fr */
/* Updated: 2024/09/12 01:28:12 by tdelage ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -53,6 +53,17 @@ MLX_API void* mlx_init();
*/
MLX_API void* mlx_new_window(void* mlx, int w, int h, const char* title);

/**
* @brief Creates a new window
*
* @param mlx Internal MLX application
* @param win Internal window to move
* @param x New x position
* @param y New y position
*
*/
MLX_API void mlx_set_window_position(void *mlx, void *win, int x, int y);


/**
* @brief Gives a function to be executed at each loop turn
Expand Down
3 changes: 2 additions & 1 deletion src/core/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 21:49:46 by maldavid #+# #+# */
/* Updated: 2024/01/26 11:26:54 by maldavid ### ########.fr */
/* Updated: 2024/09/12 01:30:35 by tdelage ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,6 +45,7 @@ namespace mlx::core
inline void* newGraphicsSuport(std::size_t w, std::size_t h, const char* title);
inline void clearGraphicsSupport(void* win);
inline void destroyGraphicsSupport(void* win);
inline void setWindowPosition(void *win, int x, int y);

inline void pixelPut(void* win, int x, int y, std::uint32_t color) const noexcept;
inline void stringPut(void* win, int x, int y, std::uint32_t color, char* str);
Expand Down
13 changes: 13 additions & 0 deletions src/core/application.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/* */
/* ************************************************************************** */

#include <SDL2/SDL_video.h>
#include <algorithm>
#include <core/application.h>

#define CHECK_WINDOW_PTR(win) \
Expand Down Expand Up @@ -70,6 +72,17 @@ namespace mlx::core
_in->onEvent(_graphics[*static_cast<int*>(win)]->getWindow()->getID(), event, funct_ptr, param);
}

void Application::setWindowPosition(void* win, int x, int y)
{
CHECK_WINDOW_PTR(win);
if(!_graphics[*static_cast<int*>(win)]->hasWindow())
{
error::report(e_kind::warning, "trying to move a window that is targeting an image and not a real window, this is not allowed");
return;
}
SDL_SetWindowPosition(_graphics[*static_cast<int*>(win)]->getWindow()->getNativeWindow(), x, y);
}

void Application::getScreenSize(void* win, int* w, int* h) noexcept
{
CHECK_WINDOW_PTR(win);
Expand Down
8 changes: 7 additions & 1 deletion src/core/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 17:35:20 by maldavid #+# #+# */
/* Updated: 2024/02/23 22:37:24 by maldavid ### ########.fr */
/* Updated: 2024/09/12 01:29:33 by tdelage ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -62,6 +62,12 @@ extern "C"
return 0;
}

void mlx_set_window_position(void *mlx, void *win, int x, int y)
{
MLX_CHECK_APPLICATION_POINTER(mlx);
static_cast<mlx::core::Application*>(mlx)->setWindowPosition(win, x, y);
}

int mlx_loop(void* mlx)
{
MLX_CHECK_APPLICATION_POINTER(mlx);
Expand Down
1 change: 1 addition & 0 deletions src/core/graphics.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/* */
/* ************************************************************************** */

#include <algorithm>
#include <core/graphics.h>

namespace mlx
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/command/vk_cmd_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
/* ::: :::::::: */
/* vk_cmd_buffer.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* By: bonsthie <bonsthie@42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/06 18:25:42 by maldavid #+# #+# */
/* Updated: 2024/01/07 01:25:50 by maldavid ### ########.fr */
/* Updated: 2024/08/08 17:46:00 by bonsthie ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -17,6 +17,7 @@
#include <volk.h>
#include <renderer/core/vk_fence.h>
#include <vector>
#include <algorithm>

namespace mlx
{
Expand Down

0 comments on commit 20ec13d

Please sign in to comment.