void 												
World::render_scene(const std::vector<Pixel>& pixels) const {

	RGBColor	pixel_color;	 	
	Ray			ray;					
	int 		hres 	= vp.hres;
	int 		vres 	= vp.vres;
	float		s		= vp.s;
	float		zw		= 100.0;				// hardwired in
	
	list<RenderedPixel> render;   // for send every row
	RenderedPixel pixel;		  // "
	int count = 0;
	int jump  = 0;
	int depth = 0;

	ray.d = Vector3D(0, 0, -1);
	
	for(unsigned int i = 0; i< pixels.size(); i++)
	{			
			Pixel screen_pixel = pixels[i];		
			ray.o = Point3D(s * (screen_pixel.x - hres / 2.0 + 0.5), s * (screen_pixel.y - vres / 2.0 + 0.5), zw);
			pixel_color = tracer_ptr->trace_ray(ray, depth, count, jump);
			pixel.color = pixel_color;			// for send every row
			pixel.xy = Point2D(screen_pixel.x,screen_pixel.y);	// "
			render.push_back(pixel);    // "

				if(stop_rendering())       // if the program is asked to close, we need end this now
				{	display_pixel(render);  
					render.clear();	
					return; 	}	

				if(render_display() == EVERY_PIXEL)
				{	display_pixel(render);   // send to the screen buffer every pixel rendered
					render.clear();	
				}
				else if(render_display() == EVERY_ROW)
				{	
					if(i % (pixels.size()/10) == 0)
					{
						display_pixel(render);   // send to the screen buffer every pixel rendered
						render.clear();	
					}
				}
	}	
	if(render_display() == EVERY_JOB || render_display() == EVERY_ROW)
	{	display_pixel(render);   // send to the screen buffer every row of pixels rendered
		render.clear();	
	}		

	
}  
示例#2
0
文件: rtv1.c 项目: ebaudet/Raytracer
void	display_scene(t_img *img)
{
	int			x;
	int			y;
	t_ray		*rayon;
	t_data		*d;
	int			time;

	d = data_init();
	rayon = ray_new();
	time = 0;
	y = 0;
	while (y < d->win_size_y)
	{
		x = 0;
		while (x < d->win_size_x)
		{
			display_pixel(img, x, y, rayon);
			x++;
			time++;
			if (time % 100000 == 0)
				eb_waiting(time/100000);
		}
		y++;
	}
}
示例#3
0
文件: World.cpp 项目: chrysl666/rayT
void 												
World::render_scene(void) const {

	/*
	RGBColor	pixel_color;	 	
	Ray			ray;					
	int 		hres 	= vp.hres;
	int 		vres 	= vp.vres;
	float		s		= vp.s;
	float		zw		= 100.0;				// hardwired in

	ray.d = Vector3D(0, 0, -1);
	
	for (int r = 0; r < vres; r++)			// up
		for (int c = 0; c <= hres-1; c++) {	// across 					
			ray.o = Point3D(s * (c - hres / 2.0 + 0.5), s * (r - vres / 2.0 + 0.5), zw);
			pixel_color = tracer_ptr->trace_ray(ray);
			display_pixel(r, c, pixel_color);
		}	
	 
	 
	 */
	
	
	RGBColor	pixel_color;	 	
	Ray			ray;					
	int 		hres 	= vp.hres;
	int 		vres 	= vp.vres;
	float		s		= vp.s;
	float		zw		= 100.0;				// hardwired in
	int           n = (int)sqrt( (float)vp.num_samples);
	Point2D pp;
	
	
	
	ray.d = Vector3D(0, 0, -1);
	
	for (int r = 0; r < vres; r++)			// up
		for (int c = 0; c <= hres-1; c++) {	// across
			pixel_color = black;
			
			for(int p = 0 ; p < n; p++)
			{
				for(int q = 0 ; q < n; q++)
				{
					pp.x = vp.s * (c - 0.5 * vp.hres + (q + 0.5) /n);
					pp.y = vp.s * (r -0.5 *  vp.vres + ( p + 0.5)/n);
					
					ray.o = Point3D(pp.x , pp.y , zw);
					pixel_color = tracer_ptr->trace_ray(ray);
					display_pixel(r, c, pixel_color);
				}
			}
		}	

	
}  
示例#4
0
void 												
World::render_scene(void) const {

	RGBColor	pixel_color;	 	
	Ray			ray;					
	int 		hres 	= vp.hres;
	int 		vres 	= vp.vres;
	float		s		= vp.s;
	float		zw		= 100.0;				// hardwired in

	ray.d = Vector3D(0, 0, -1);
	
	for (int r = 0; r < vres; r++)			// up
		for (int c = 0; c <= hres; c++) {	// across 					
			ray.o = Point3D(s * (c - hres / 2.0 + 0.5), s * (r - vres / 2.0 + 0.5), zw);
			pixel_color = tracer_ptr->trace_ray(ray);
			display_pixel(r, c, pixel_color);
		}	
}  
示例#5
0
文件: video.c 项目: Benderx2/FVM
void update_ppu_display(PPU_t* ppu)
{
	int buf_len = screen->pitch * screen->h;
	if(buf_len < TOTAL_PPU_MEM) { printf(" [FATAL: Current Video State cannot support PPU display\n"); FVM_EXIT(FVM_PROGRAM_ERR); }
	printf("screen_formakt: %d %d\n", screen->w, screen->h);
	uint32_t* ppu32_mem = (uint32_t*)ppu->memory;
	int j, k;
	k = 0; j = 0;
	for(int i = 0; i < TOTAL_PPU_MEM; i++)
	{
		if(j >= screen->w) { k++; j = 0; }
		if(k >= screen->h) { break; }
		display_pixel(j, k, ppu32_mem[i]);
		j++;
	}
	//private_ppu_check(ppu);
	printf("TOTAL_PPU_MEM: %d\n", TOTAL_PPU_MEM);
	FVM_SDL_updatedisplay(screen);
}