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))
|
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
|
LIBFT = libft.a
|
||||||
|
@ -59,7 +59,7 @@ $(NAME): $(OBJ) $(LIBFT_FOLDER)$(LIBFT) $(MLX_FOLDER)$(MLX)
|
||||||
$(OBJDIR)%.o : $(SRCDIR)%.c
|
$(OBJDIR)%.o : $(SRCDIR)%.c
|
||||||
$(CC) $(FLAGS) $(INC) -c $< -o $@
|
$(CC) $(FLAGS) $(INC) -c $< -o $@
|
||||||
|
|
||||||
$(LIBFOLDER)$(LIB):
|
$(LIBFT_FOLDER)$(LIBFT):
|
||||||
make -C $(LIBFT_FOLDER)
|
make -C $(LIBFT_FOLDER)
|
||||||
|
|
||||||
$(MLX_FOLDER)$(MLX):
|
$(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;
|
len = len2;
|
||||||
}
|
}
|
||||||
/* strcpy(copy,str); */
|
/* strcpy(copy,str); */
|
||||||
strlcpy(copy, str, len2+1);
|
strncpy(copy, str, len2+1);
|
||||||
return (copy);
|
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)
|
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 tw = {0,10};
|
||||||
struct timespec tr;
|
//struct timespec tr;
|
||||||
|
|
||||||
int temp_y;
|
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)
|
while(init_y < side)
|
||||||
{
|
{
|
||||||
mlx_pixel_put(mlx, mlx_w, init_x, init_y, hex_rgb);
|
mlx_pixel_put(mlx, mlx_w, init_x, init_y, hex_rgb);
|
||||||
nanosleep(&tw, &tr);
|
//nanosleep(&tw, &tr);
|
||||||
init_y++;
|
init_y++;
|
||||||
}
|
}
|
||||||
init_x++;
|
init_x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
void *mlx;
|
void *mlx;
|
||||||
void *mlx_window;
|
void *mlx_window;
|
||||||
|
void *image;
|
||||||
int y;
|
int y;
|
||||||
int x;
|
int x;
|
||||||
int hex;
|
//int hex;
|
||||||
|
|
||||||
mlx = mlx_init();
|
mlx = mlx_init();
|
||||||
mlx_window = mlx_new_window(mlx, 400, 400, "mlx test");
|
mlx_window = mlx_new_window(mlx, 2400, 1600, "CATT!!!11");
|
||||||
y = 50;
|
// y= 50;
|
||||||
hex = 0xFFA6FB;
|
// hex = 0xFFA6FB;
|
||||||
while (y < 100)
|
// while (y < 100)
|
||||||
{
|
// {
|
||||||
x = 50;
|
// x = 50;
|
||||||
while (x < 100)
|
// while (x < 100)
|
||||||
{
|
// {
|
||||||
put_square(100, x, y, mlx, mlx_window, hex);
|
// put_square(100, x, y, mlx, mlx_window, hex);
|
||||||
mlx_clear_window(mlx, mlx_window);
|
// //mlx_clear_window(mlx, mlx_window);
|
||||||
printf("y = %d\n", y);
|
// printf("y = %d\n", y);
|
||||||
hex += 0xFFA6FB;
|
// hex += 0xFFA6FB;
|
||||||
x++;
|
// x++;
|
||||||
}
|
// }
|
||||||
y++;
|
// 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);
|
mlx_loop(mlx);
|
||||||
return (0);
|
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