Exemple #1
0
void			*send_work(void *arg)
{
  t_client		*client;
  u_pixels		pixel_line;
  int			y;
  unsigned int		x;

  client = (t_client *)arg;
  while (42)
    {
      if ((y = ++line - 1) >= HEIGHT)
	pthread_exit(NULL);
      my_printf(" %d% \r", ((y + 1) * 100) / HEIGHT);
      if (send(client->csock, &y, sizeof(y), 0) == -1)
	my_error("error: send(): Failed.\n", 0);
      receive_pixels(client, &pixel_line);
      x = -1;
      while (++x < WIDTH)
	put_pixel_in_img(*client->mlx, x, y, pixel_line.pixel[x]);
    }
}
Exemple #2
0
void			*server_work(void *arg)
{
  t_rt			*rt;
  int			pixel[WIDTH];
  int			y;
  int			x;

  rt = (t_rt *)arg;
  while (42)
    {
      if ((y = ++line - 1) >= HEIGHT)
	pthread_exit(NULL);
      my_printf(" %d% \r", ((y + 1) * 100) / HEIGHT);
      x = -1;
      while (++x < WIDTH)
	{
	  calculate_pixel(rt, x, y, pixel);
	  put_pixel_in_img(rt->mlx, x, y, pixel[x]);
	}
    }
}
Exemple #3
0
int		expose_hook(t_d *d)
{
	int		x = 0;
	int		y = 0;
	int		pos;

	printf("Enter in expose\n");
	if ((d->img = mlx_new_image(d->mlx, 500, 500)) == NULL)
		exitProg("Fail to init a new image in minilibx.\n");	
	d->strimg = mlx_get_data_addr(d->img, &(d->bpp), &(d->size_line), &(d->endian));
	d->color = mlx_get_color_value(d->mlx, 0xFFFAFA);
	while (x < 250)
	{
		put_pixel_in_img(d, x, y);
		x++;
		if (x == 250 && y < 250)
		{
			x = 0;
			y++;
		}
		/* == CA MARCHE
		   y = 0;
		   while (y < 250)
		   {
		   pos = y * d->size_line + 4 * x;
		   d->strimg[pos] = 255;
		   y++;

		   }
		   x++;*/
	}
	mlx_put_image_to_window(d->mlx, d->win, d->img, 0, 0);
	//mlx_destroy_image(d->mlx, d->img);
	printf("End of expose\n");
	return (0);
}