Example #1
0
        void Render(void)
        {
            TraceStrategy trace(_Shapes, _Lights);
            RenderStrategy render(_ScreenWidth, _ScreenHeight);

            Vector3D eyeLoc = {0.0, 0.0, -EyeDepth};

            render([&trace, &eyeLoc, this](int i, int j)
            {
                double x, y;
                _ScreenToLogical(i, j, x, y);

                Vector3D screenPosition = {x, y, 0.0};

                Ray principleRay(eyeLoc, screenPosition - eyeLoc);

                Vector3D pixelColor = trace(principleRay);

                Vector3D suppressedColor = pixelColor.Clip(1.0);

                int red = suppressedColor.I() * 255;
                int green = suppressedColor.J() * 255;
                int blue = suppressedColor.K() * 255;

                _Screen[(j * _ScreenWidth + i) * 3] = red;
                _Screen[(j * _ScreenWidth + i) * 3 + 1] = green;
                _Screen[(j * _ScreenWidth + i) * 3 + 2] = blue;
            });
        }