本文整理汇总了C++中Viewport::color_pixel方法的典型用法代码示例。如果您正苦于以下问题:C++ Viewport::color_pixel方法的具体用法?C++ Viewport::color_pixel怎么用?C++ Viewport::color_pixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Viewport
的用法示例。
在下文中一共展示了Viewport::color_pixel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
/**
* @brief Runs the raytracer in a single thread.
*/
void RaytracerSinglethreaded::run()
{
Ray *init_ray = new Ray();
Color *col;
Vertex *eye, *pixel;
Viewport *viewport = world->get_viewport();
/* The origin of the initial ray is always the viewer's eye. */
eye = world->get_eye();
init_ray->set_origin(new Vertex(eye));
int i, j;
int height = viewport->get_height();
int width = viewport->get_width();
for (i = 0; i < width; i++)
{
for (j = 0; j < height; j++)
{
/* The displacement of the ray is the pixel's coordinates
* minus the eye's coordinates. */
viewport->map_pixel_to_vertex(i, j, &pixel);
init_ray->set_displacement(new Vertex(pixel->x - eye->x,
pixel->y - eye->y, pixel->z - eye->z));
delete pixel;
/* Trace this ray. */
trace(init_ray, &col);
/* Color the pixel. */
viewport->color_pixel(i, j, col);
delete col;
}
}
delete init_ray;
}