[mlx] miniLibX 활용 이미지 출력하기

J_JEON·2022년 5월 26일
0

miniLbiX

목록 보기
3/4

mlx 라이브러리

  • 렌더링을 위한 가장 기본적인 작업을 수행할 수 있는 작은 그래픽 라이브러리
  • 간단한 윈도우를 생성하고, 그리기, 이벤트관리 등을 제공함
  • mlx.h 파일을 include 하여 사용가능
    컴파일시 gcc -L(mlx폴더) -lmlx -framework OpenGL -framework - AppKit *.c

miniLibX 활용 이미지 출력

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

int	main(void)
{
	void	*mlx;
	void	*win;
	void	*img;
	int		img_width;
	int		img_height;

	mlx = mlx_init();
	win = mlx_new_window(mlx, 500, 500, "putImage");
	img = mlx_xpm_file_to_image(mlx, "imgs/ground.xpm", &img_width, &img_height);
    //xpm 파일을 불러와 이미지로 변환하고 img에 저장해줌
	mlx_put_image_to_window(mlx, win, img, 50, 50);
    // xpm에서 이미지로 변환한 img를 화면에 (50,50)위치에 띄워줌
	mlx_loop(mlx);
	return (0);
}
  • 결과
profile
늅늅

0개의 댓글