Ejemplo n.º 1
0
        public EarthApplication(ApplicationWindow window)
        {
            Window          = window;
            Window.Resized += HandleWindowResize;
            Window.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
            Window.GraphicsDeviceDestroyed += OnDeviceDestroyed;
            Window.Rendering += PreDraw;
            Window.Rendering += Draw;
            //首先创建一个场景对象
            _scene      = new Scene.Scene(window.Width, window.Height);
            globeRender = new RayCastedGlobe(_scene);
            var path = @"E:\swyy\Lib\PongGlobe\PongGlobe\assets\Vector\NaturalEarth\110m-admin-0-countries\110m_admin_0_countries.shp";

            vectorLayerRender = new Renders.VectorLayerRender(path, _scene);
            var shareRender = new ShareRender(_scene);

            renders.Add(shareRender);
            renders.Add(globeRender);
            renders.Add(vectorLayerRender);
            var pat2h       = @"E:\swyy\Lib\PongGlobe\PongGlobe\assets\Vector\NaturalEarth\110m-populated-places-simple\110m_populated_places_simple.shp";
            var vectorPoint = new PointVectorLayerRender(pat2h, _scene);
            //renders.Add(vectorPoint);
            //var drawline = new DrawLineTool(_scene);
            // renders.Add(drawline);
        }
Ejemplo n.º 2
0
 public EarthApplication(ApplicationWindow window)
 {
     Window          = window;
     Window.Resized += HandleWindowResize;
     Window.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
     Window.GraphicsDeviceDestroyed += OnDeviceDestroyed;
     Window.Rendering += PreDraw;
     Window.Rendering += Draw;
     //首先创建一个场景对象
     _scene = new Scene.Scene(window.Width, window.Height);
 }
Ejemplo n.º 3
0
        public unsafe UserControl1()
        {
            try
            {
                InitializeComponent();
                if (this.DesignMode)
                {
                    return;
                }
                this.MouseWheel += UserControl1_MouseWheel;

                //释放组件
                Disposed += OnDispose;
                //this.MouseMove += UserControl1_MouseMove    ;
                GraphicsDeviceOptions options = new GraphicsDeviceOptions(
                    debug: false,
                    swapchainDepthFormat: PixelFormat.R16_UNorm,
                    syncToVerticalBlank: true,
                    resourceBindingModel: ResourceBindingModel.Improved);
#if DEBUG
                options.Debug = true;
#endif
                //获取当前窗体的Hwnd
                var hwnd = this.Handle;
                var p    = hwnd.ToPointer();
                //这里创建的sld windows消息捕获出现了问题,

                //获取运行进程的handle
                var instance = Process.GetCurrentProcess().Handle;
                _gd      = VeldridStartup.CreateVulkanGraphicsDeviceForWin32(options, hwnd, instance, this.Width, this.Height);
                _factory = new DisposeCollectorResourceFactory(_gd.ResourceFactory);

                _scene = new PongGlobe.Scene.Scene(this.Width, this.Height);
                var globeRender = new RayCastedGlobe(_scene);
                var shareRender = new ShareRender(_scene);
                this.renders.Add(shareRender);
                this.renders.Add(globeRender);

                //创建完相关对象后注册事件
                this.GraphicsDeviceCreated   += OnGraphicsDeviceCreated;
                this.GraphicsDeviceDestroyed += OnDeviceDestroyed;
                this.Rendering += PreDraw;
                this.Rendering += Draw;


                GraphicsDeviceCreated?.Invoke(_gd, _factory, _gd.MainSwapchain);
                _window = new Sdl2Window(hwnd, false);
                //创建一个计时器
                sw = Stopwatch.StartNew();
                previousElapsed = sw.Elapsed.TotalSeconds;
                //this.ParentForm.Shown += ParentForm_Shown;
                //开始运行
                //Run();
                //创建一个线程执行run,使用多线程之后便需要考虑不同线程变量同步的问题了,例如isrunning变量的修改需要lock之后再修改,有时可以使用线程安全的集合来处理不同线程的变量交换,
                //c#封装了很多,这些都不是问题_coomadList并不是线程安全的,在主线程创建,在子线程使用,这样问题并不大,当时两个子线程同时使用commandLits便可能出现问题
                //这里的渲染仍然是单线程的,每个不同的render都可以独开线程并提交渲染任务
                _renderTask = Task.Factory.StartNew(() => { Run(); });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }