Esempio n. 1
0
        public void RenderCl(OpenCLProxy clProxy)
        {
            if (clProxy.HardwareAccelerationEnabled)
            {
                clProxy.RunKernel(_computeKernel, RenderUtils.ScreenArea);
            }
            else
            {
                int totalSize = RenderUtils.ScreenArea;

                for (int i = 0; i < totalSize; i++)
                {
                    _kernel.Run(clProxy.ReadIntBuffer("image", totalSize), 0, 0, 0, 0, 0, 0, 0, 0, 0);
                }

                _kernel.Finish();
            }
        }
Esempio n. 2
0
        public void RenderCl(OpenCLProxy clProxy, RectangleD cameraBounds, IPhysicsBody sun)
        {
            RectangleD bounds = ComputeBoundingBox();

            // Not in range easy return
            if (!cameraBounds.IntersectsWith(bounds))
            {
                return;
            }

            DVector2 sunNormal = DVector2.Zero;

            if (sun != null)
            {
                sunNormal = sun.Position - Position;

                sunNormal.Normalize();
            }

            var normalizedPosition = new DVector2(cameraBounds.X - Position.X, cameraBounds.Y - Position.Y);

            if (clProxy.HardwareAccelerationEnabled)
            {
                clProxy.UpdateDoubleArgument("cameraLeft", normalizedPosition.X);
                clProxy.UpdateDoubleArgument("cameraTop", normalizedPosition.Y);

                clProxy.UpdateDoubleArgument("cameraWidth", cameraBounds.Width);
                clProxy.UpdateDoubleArgument("cameraHeight", cameraBounds.Height);

                clProxy.UpdateDoubleArgument("sunNormalX", sunNormal.X);
                clProxy.UpdateDoubleArgument("sunNormalY", sunNormal.Y);

                clProxy.UpdateDoubleArgument("rotation", Rotation);

                clProxy.RunKernel(_computeKernel, RenderUtils.ScreenArea);
            }
            else
            {
                int totalSize = RenderUtils.ScreenArea;

                for (int i = 0; i < totalSize; i++)
                {
                    Kernel.Run(clProxy.ReadIntBuffer("image", totalSize), RenderUtils.ScreenWidth, RenderUtils.ScreenHeight,
                                                    normalizedPosition.X, normalizedPosition.Y, cameraBounds.Width, cameraBounds.Height,
                                                    sunNormal.X, sunNormal.Y, Rotation);
                }

                Kernel.Finish();
            }
        }