working image displaying
This commit is contained in:
parent
bcec94cab3
commit
9722974bee
5 changed files with 1893 additions and 24 deletions
4
Makefile
4
Makefile
|
@ -28,7 +28,7 @@ SRC = $(addprefix $(SRCDIR), $(SRC_FILES))
|
|||
OBJ = $(addprefix $(OBJDIR), $(OBJ_FILES))
|
||||
|
||||
|
||||
INC = -I ./inc -I $(LIBFT_FOLDER) -I $(MLX_FOLDER)
|
||||
INC = -I ./inc -I $(LIBFT_FOLDER)/includes/ -I $(MLX_FOLDER)
|
||||
|
||||
|
||||
LIBFT = libft.a
|
||||
|
@ -59,7 +59,7 @@ $(NAME): $(OBJ) $(LIBFT_FOLDER)$(LIBFT) $(MLX_FOLDER)$(MLX)
|
|||
$(OBJDIR)%.o : $(SRCDIR)%.c
|
||||
$(CC) $(FLAGS) $(INC) -c $< -o $@
|
||||
|
||||
$(LIBFOLDER)$(LIB):
|
||||
$(LIBFT_FOLDER)$(LIBFT):
|
||||
make -C $(LIBFT_FOLDER)
|
||||
|
||||
$(MLX_FOLDER)$(MLX):
|
||||
|
|
Binary file not shown.
|
@ -59,7 +59,7 @@ char *mlx_int_static_line(char **xpm_data,int *pos,int size)
|
|||
len = len2;
|
||||
}
|
||||
/* strcpy(copy,str); */
|
||||
strlcpy(copy, str, len2+1);
|
||||
strncpy(copy, str, len2+1);
|
||||
return (copy);
|
||||
}
|
||||
|
||||
|
|
49
src/main.c
49
src/main.c
|
@ -13,8 +13,8 @@
|
|||
|
||||
void put_square(int side, int init_x, int init_y, void *mlx, void *mlx_w, int hex_rgb)
|
||||
{
|
||||
struct timespec tw = {0,10};
|
||||
struct timespec tr;
|
||||
//struct timespec tw = {0,10};
|
||||
//struct timespec tr;
|
||||
|
||||
int temp_y;
|
||||
|
||||
|
@ -25,38 +25,45 @@ void put_square(int side, int init_x, int init_y, void *mlx, void *mlx_w, int he
|
|||
while(init_y < side)
|
||||
{
|
||||
mlx_pixel_put(mlx, mlx_w, init_x, init_y, hex_rgb);
|
||||
nanosleep(&tw, &tr);
|
||||
//nanosleep(&tw, &tr);
|
||||
init_y++;
|
||||
}
|
||||
init_x++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
void *mlx;
|
||||
void *mlx_window;
|
||||
void *image;
|
||||
int y;
|
||||
int x;
|
||||
int hex;
|
||||
//int hex;
|
||||
|
||||
mlx = mlx_init();
|
||||
mlx_window = mlx_new_window(mlx, 400, 400, "mlx test");
|
||||
y = 50;
|
||||
hex = 0xFFA6FB;
|
||||
while (y < 100)
|
||||
{
|
||||
x = 50;
|
||||
while (x < 100)
|
||||
{
|
||||
put_square(100, x, y, mlx, mlx_window, hex);
|
||||
mlx_clear_window(mlx, mlx_window);
|
||||
printf("y = %d\n", y);
|
||||
hex += 0xFFA6FB;
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
mlx_window = mlx_new_window(mlx, 2400, 1600, "CATT!!!11");
|
||||
// y= 50;
|
||||
// hex = 0xFFA6FB;
|
||||
// while (y < 100)
|
||||
// {
|
||||
// x = 50;
|
||||
// while (x < 100)
|
||||
// {
|
||||
// put_square(100, x, y, mlx, mlx_window, hex);
|
||||
// //mlx_clear_window(mlx, mlx_window);
|
||||
// printf("y = %d\n", y);
|
||||
// hex += 0xFFA6FB;
|
||||
// x++;
|
||||
// }
|
||||
// y++;
|
||||
// }
|
||||
y = 1600;
|
||||
x = 2400;
|
||||
if (argc != 2)
|
||||
return (1);
|
||||
image = mlx_xpm_file_to_image(mlx, argv[1], &x, &y);
|
||||
mlx_put_image_to_window (mlx, mlx_window, image, 0, 0);
|
||||
mlx_loop(mlx);
|
||||
return (0);
|
||||
}
|
||||
|
|
1862
tests/cat.xpm
Normal file
1862
tests/cat.xpm
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue