카테고리 없음

[FdF] MiniLibX mlx_new_image

Or71nH 2022. 6. 19. 13:54

이녀석은 뭔가 많다

맨에 몇개가 빠진거 같지만 외부 파일에 있나보다

./win_os/libmlx.a(mlx_new_image.o):
0000000000000098 T _add_img_to_ctx
                 U _bzero
                 U _free
                 U _glBindBuffer
                 U _glBindTexture
                 U _glBufferData
                 U _glDeleteBuffers
                 U _glDeleteTextures
                 U _glGenBuffers
                 U _glGenTextures
                 U _glTexImage2D
                 U _glTexParameteri
                 U _malloc
0000000000000398 T _mlx_destroy_image
0000000000000294 T _mlx_get_color_value
0000000000000274 T _mlx_get_data_addr
0000000000000000 T _mlx_new_image
00000000000001ac T _mlx_put_image_to_window
000000000000029c T _mlx_string_put
                 U _objc_msgSend

SYNOPSYS
       void *
       mlx_new_image ( void *mlx_ptr, int width, int height );

       char *
       mlx_get_data_addr ( void *img_ptr, int *bits_per_pixel, int *size_line, int *endian );

       int
       mlx_put_image_to_window ( void *mlx_ptr, void *win_ptr, void *img_ptr, int x, int y );

       unsigned int
       mlx_get_color_value ( void *mlx_ptr, int color );

       void *
       mlx_xpm_to_image ( void *mlx_ptr, char **xpm_data, int *width, int *height );

       void *
       mlx_xpm_file_to_image ( void *mlx_ptr, char *filename, int *width, int *height );

       int
       mlx_destroy_image ( void *mlx_ptr, void *img_ptr );

일단 mlx_new_image 부터 살펴보자

void    *mlx_new_image(mlx_ptr_t *mlx_ptr, int width, int height)
{
  mlx_img_list_t        *newimg;

  //  if (mlx_ptr->win_list == NULL)
  //    return (NULL);  // need at leat one window created to have openGL context and create texture
  if ((newimg = malloc(sizeof(*newimg))) == NULL)
    return ((void *)0);
  newimg->next = mlx_ptr->img_list;
  mlx_ptr->img_list = newimg;
  newimg->width = width;
  newimg->height = height;
  newimg->vertexes[0] = 0.0;  newimg->vertexes[1] = 0.0;
  newimg->vertexes[2] = width;  newimg->vertexes[3] = 0.0;
  newimg->vertexes[4] = width;  newimg->vertexes[5] = -height;
  newimg->vertexes[6] = 0.0;  newimg->vertexes[7] = -height;
  newimg->buffer = malloc(UNIQ_BPP*width*height);
  // #define UNIQ_BPP	4
  bzero(newimg->buffer, UNIQ_BPP*width*height);
  /*
    아직은 왜 0.0 을 넣고 width 그리고 -height 를 넣는지 이해하지 못한다 나중에 확인을 해보자
  */
  return (newimg);
}

구조체는 이런식이고

typedef struct	mlx_img_list_s
{
  int			width;
  int			height;
  char			*buffer;
  GLfloat		vertexes[8];
  struct mlx_img_list_s	*next;
} mlx_img_list_t;

음 결과적으로는 새로운 이미지를 말록해서 xml_ptr->img_list 맨앞에 넣는거 뿐인거 같다

다음으로 가자~