Example #1
0
        /// <summary>
        /// Load GPU kernels for planet rendering
        /// </summary>
        private void LoadKernels()
        {
            try
            {
                bool useSoftware = (_renderingType == RenderingType.OpenCLSoftware);

                _gpuClear = new GpuClear();

                _clProxy = new OpenCLProxy(useSoftware);

                if (Directory.Exists("Kernels"))
                {
                    KernelManager.GenerateKernels("Kernels");
                }
                else
                {
                    KernelManager.GenerateKernels("../../Kernels");
                }

                _clProxy.CreateIntArgument("resX", RenderUtils.ScreenWidth);
                _clProxy.CreateIntArgument("resY", RenderUtils.ScreenHeight);

                _clProxy.CreateDoubleArgument("cameraLeft", 0);
                _clProxy.CreateDoubleArgument("cameraTop", 0);

                _clProxy.CreateDoubleArgument("cameraWidth", 0);
                _clProxy.CreateDoubleArgument("cameraHeight", 0);

                _clProxy.CreateDoubleArgument("sunNormalX", 0);
                _clProxy.CreateDoubleArgument("sunNormalY", 0);

                _clProxy.CreateDoubleArgument("rotation", 0);

                _clProxy.CreateIntBuffer("image", new int[RenderUtils.ScreenArea], ComputeMemoryFlags.UseHostPointer);

                _gpuClear.Load(_clProxy);

                foreach (IGpuRenderable renderable in _massiveBodies)
                {
                    renderable.Load(_clProxy);
                }
            }
            catch (Exception)
            {
                _renderingType = RenderingType.GDIPlus;
            }
        }
Example #2
0
        /// <summary>
        /// Load GPU kernels for planet rendering
        /// </summary>
        private void LoadKernels()
        {
            try
            {
                bool useSoftware = _renderingType == RenderingType.OpenCLSoftware;

                _gpuClear = new GpuClear();

                _clProxy = new OpenCLProxy(useSoftware);

                KernelManager.GenerateKernels(Directory.Exists("Kernels") ? "Kernels" : "../../Kernels");

                _clProxy.CreateIntArgument("resX", RenderUtils.ScreenWidth);
                _clProxy.CreateIntArgument("resY", RenderUtils.ScreenHeight);

                _clProxy.CreateDoubleArgument("cX", 0);
                _clProxy.CreateDoubleArgument("cY", 0);

                _clProxy.CreateDoubleArgument("cWidth", 0);
                _clProxy.CreateDoubleArgument("cHeight", 0);

                _clProxy.CreateDoubleArgument("cRot", 0);

                _clProxy.CreateDoubleArgument("sunNormalX", 0);
                _clProxy.CreateDoubleArgument("sunNormalY", 0);

                _clProxy.CreateDoubleArgument("bodyX", 0);
                _clProxy.CreateDoubleArgument("bodyY", 0);
                _clProxy.CreateDoubleArgument("bodyRot", 0);

                _clProxy.CreateIntBuffer("image", new int[RenderUtils.ScreenArea], ComputeMemoryFlags.UseHostPointer);

                _gpuClear.Load(_clProxy);

                foreach (IGpuRenderable renderable in _massiveBodies)
                {
                    renderable.Load(_clProxy);
                }
            }
            catch (Exception)
            {
                _renderingType = RenderingType.GDIPlus;
            }

            UpdateLoadingPercentage(100);
        }