2023-04-26 07:39:03 -04:00
|
|
|
/* ************************************************************************** */
|
|
|
|
/* */
|
|
|
|
/* :::::::: */
|
|
|
|
/* mlx_cursor.c :+: :+: */
|
|
|
|
/* +:+ */
|
2023-04-26 08:03:40 -04:00
|
|
|
/* By: W2Wizard <w2.wizzard@gmail.com> +#+ */
|
2023-04-26 07:39:03 -04:00
|
|
|
/* +#+ */
|
|
|
|
/* Created: 2022/01/18 20:10:54 by W2Wizard #+# #+# */
|
2023-04-26 08:03:40 -04:00
|
|
|
/* Updated: 2022/11/22 08:58:23 by jvan-hal ######## odam.nl */
|
2023-04-26 07:39:03 -04:00
|
|
|
/* */
|
|
|
|
/* ************************************************************************** */
|
|
|
|
|
|
|
|
#include "MLX42/MLX42_Int.h"
|
|
|
|
|
|
|
|
//= Public =//
|
|
|
|
|
2023-04-26 08:03:40 -04:00
|
|
|
void* mlx_create_std_cursor(cursor_t type)
|
2023-04-26 07:39:03 -04:00
|
|
|
{
|
|
|
|
MLX_ASSERT(type >= MLX_CURSOR_ARROW && type < MLX_CURSOR_VRESIZE, "Invalid standard cursor type");
|
|
|
|
|
|
|
|
GLFWcursor* cursor;
|
|
|
|
if ((cursor = glfwCreateStandardCursor(type)))
|
|
|
|
return (cursor);
|
|
|
|
return ((void *)mlx_error(MLX_MEMFAIL));
|
|
|
|
}
|
|
|
|
|
2023-04-26 08:03:40 -04:00
|
|
|
void* mlx_create_cursor(mlx_texture_t* texture)
|
2023-04-26 07:39:03 -04:00
|
|
|
{
|
|
|
|
MLX_NONNULL(texture);
|
|
|
|
|
|
|
|
GLFWcursor* cursor;
|
|
|
|
GLFWimage image = (GLFWimage) {
|
|
|
|
.width = texture->width,
|
|
|
|
.height = texture->height,
|
|
|
|
.pixels = texture->pixels
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((cursor = glfwCreateCursor(&image, 0, 0)))
|
|
|
|
return (cursor);
|
|
|
|
return ((void *)mlx_error(MLX_MEMFAIL));
|
|
|
|
}
|
|
|
|
|
2023-04-26 08:03:40 -04:00
|
|
|
void mlx_set_cursor(mlx_t* mlx, void* cursor)
|
2023-04-26 07:39:03 -04:00
|
|
|
{
|
|
|
|
MLX_NONNULL(mlx);
|
|
|
|
MLX_NONNULL(cursor);
|
|
|
|
|
|
|
|
glfwSetCursor(mlx->window, cursor);
|
|
|
|
}
|
|
|
|
|
|
|
|
void mlx_set_cursor_mode(mlx_t* mlx, mouse_mode_t mode)
|
|
|
|
{
|
|
|
|
MLX_NONNULL(mlx);
|
|
|
|
|
|
|
|
glfwSetInputMode(mlx->window, GLFW_CURSOR, mode);
|
|
|
|
}
|