Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] segfault when using mlx_create_cursor #72

Closed
xApologize opened this issue Jan 20, 2023 · 1 comment
Closed

[BUG] segfault when using mlx_create_cursor #72

xApologize opened this issue Jan 20, 2023 · 1 comment
Assignees
Labels
Bug Something isn't working or should get fixed

Comments

@xApologize
Copy link

xApologize commented Jan 20, 2023

Describe the bug
When i try to change the cursor in this small project, it segfaults when trying to do mlx_create_cursor

To Reproduce

#include <stdio.h>
#include "MLX42/MLX42.h"

int32_t	main(void)
{
	mlx_t	*mlx;

	mlx = mlx_init(500, 500, "MLX42", true);
	if (!mlx)
		return (0);
	printf("ok\n");
	mlx_texture_t* tex = mlx_load_png("./GitHub-Mark-32px.png");
	printf("ok1\n");
	mlx_create_cursor(tex);
	printf("ok2\n");
	mlx_loop(mlx);
	mlx_terminate(mlx);
	return (1);
}

Screenshots
If applicable, add screenshots to help explain your problem.
Screen Shot 2023-01-20 at 1 36 46 PM

Desktop (please complete the following information):

  • OS: MacOS
  • Version Catalina 10.15.7

Additional context
GitHub-Mark-32px the png i use.

@xApologize xApologize changed the title [BUG] [BUG] segfault when using mlx_create_cursor Jan 20, 2023
@W2Wizard W2Wizard added the Bug Something isn't working or should get fixed label Jan 23, 2023
@W2Wizard
Copy link
Collaborator

W2Wizard commented Jan 23, 2023

Ah alrighty. This is due to one of my commits where I changed the layout of the mlx_texture_t struct to keep the pixel buffer at the bottom. I forgot that it was on purpose that it wasn't as I was using it to perfectly map it to a GLFWImage.

Will fix this tomorrow and push the fix 👍

A quick fix is to simply swap the positions of the variables:

typedef struct mlx_texture
{
	uint32_t	width;
	uint32_t	height;
	
	// In the end the struct should look like this
	uint8_t*	pixels;
	uint8_t		bytes_per_pixel;
}	mlx_texture_t;

Result:

image

Thank you for reporting this!

@W2Wizard W2Wizard self-assigned this Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working or should get fixed
Projects
None yet
Development

No branches or pull requests

2 participants