Esempio n. 1
0
        public NeoDemo()
        {
            WindowCreateInfo windowCI = new WindowCreateInfo
            {
                X                  = 50,
                Y                  = 50,
                WindowWidth        = 960,
                WindowHeight       = 540,
                WindowInitialState = WindowState.Normal,
                WindowTitle        = "Veldrid NeoDemo"
            };
            GraphicsDeviceCreateInfo gdCI = new GraphicsDeviceCreateInfo();

            //gdCI.Backend = GraphicsBackend.Vulkan;
#if DEBUG
            gdCI.DebugDevice = true;
#endif

            VeldridStartup.CreateWindowAndGraphicsDevice(ref windowCI, ref gdCI, out _window, out _gd);
            _window.Resized += () => _windowResized = true;

            CommandList initCL = _gd.ResourceFactory.CreateCommandList();
            _gd.SetResourceName(initCL, "Initialization Command List");
            initCL.Begin();

            _scene = new Scene(_window.Width, _window.Height);

            _sc.SetCurrentScene(_scene, initCL);

            _igRenderable   = new ImGuiRenderable(_window.Width, _window.Height);
            _resizeHandled += (w, h) => _igRenderable.WindowResized(w, h);
            _scene.AddRenderable(_igRenderable);
            _scene.AddUpdateable(_igRenderable);

            Skybox skybox = Skybox.LoadDefaultSkybox();
            _scene.AddRenderable(skybox);

            AddSponzaAtriumObjects(initCL);
            _sc.Camera.Position = new Vector3(-80, 25, -4.3f);
            _sc.Camera.Yaw      = -MathF.PI / 2;
            _sc.Camera.Pitch    = -MathF.PI / 9;

            ShadowmapDrawer texDrawer = new ShadowmapDrawer(() => _window, () => _sc.NearShadowMapView);
            _resizeHandled    += (w, h) => texDrawer.OnWindowResized();
            texDrawer.Position = new Vector2(10, 25);
            _scene.AddRenderable(texDrawer);

            ShadowmapDrawer texDrawer2 = new ShadowmapDrawer(() => _window, () => _sc.MidShadowMapView);
            _resizeHandled     += (w, h) => texDrawer2.OnWindowResized();
            texDrawer2.Position = new Vector2(20 + texDrawer2.Size.X, 25);
            _scene.AddRenderable(texDrawer2);

            ShadowmapDrawer texDrawer3 = new ShadowmapDrawer(() => _window, () => _sc.FarShadowMapView);
            _resizeHandled     += (w, h) => texDrawer3.OnWindowResized();
            texDrawer3.Position = new Vector2(30 + (texDrawer3.Size.X * 2), 25);
            _scene.AddRenderable(texDrawer3);

            CreateAllObjects();
        }
Esempio n. 2
0
        public NeoDemo()
        {
            WindowCreateInfo windowCI = new WindowCreateInfo
            {
                X                  = 50,
                Y                  = 50,
                WindowWidth        = 960,
                WindowHeight       = 540,
                WindowInitialState = WindowState.Normal,
                WindowTitle        = "Veldrid NeoDemo"
            };
            GraphicsDeviceOptions gdOptions = new GraphicsDeviceOptions(false, null, false, ResourceBindingModel.Improved, true, true, _colorSrgb);

#if DEBUG
            gdOptions.Debug = true;
#endif
            VeldridStartup.CreateWindowAndGraphicsDevice(
                windowCI,
                gdOptions,
                //VeldridStartup.GetPlatformDefaultBackend(),
                //GraphicsBackend.Metal,
                // GraphicsBackend.Vulkan,
                // GraphicsBackend.OpenGL,
                //GraphicsBackend.OpenGLES,
                out _window,
                out _gd);
            _window.Resized += () => _windowResized = true;

            Sdl2Native.SDL_Init(SDLInitFlags.GameController);
            Sdl2ControllerTracker.CreateDefault(out _controllerTracker);

            _scene = new Scene(_gd, _window, _controllerTracker);

            _sc.SetCurrentScene(_scene);

            _igRenderable   = new ImGuiRenderable(_window.Width, _window.Height);
            _resizeHandled += (w, h) => _igRenderable.WindowResized(w, h);
            _scene.AddRenderable(_igRenderable);
            _scene.AddUpdateable(_igRenderable);

            Skybox skybox = Skybox.LoadDefaultSkybox();
            _scene.AddRenderable(skybox);

            AddSponzaAtriumObjects();
            _sc.Camera.Position = new Vector3(-80, 25, -4.3f);
            _sc.Camera.Yaw      = -MathF.PI / 2;
            _sc.Camera.Pitch    = -MathF.PI / 9;

            ShadowmapDrawer texDrawIndexeder = new ShadowmapDrawer(() => _window, () => _sc.NearShadowMapView);
            _resizeHandled           += (w, h) => texDrawIndexeder.OnWindowResized();
            texDrawIndexeder.Position = new Vector2(10, 25);
            _scene.AddRenderable(texDrawIndexeder);

            ShadowmapDrawer texDrawIndexeder2 = new ShadowmapDrawer(() => _window, () => _sc.MidShadowMapView);
            _resizeHandled            += (w, h) => texDrawIndexeder2.OnWindowResized();
            texDrawIndexeder2.Position = new Vector2(20 + texDrawIndexeder2.Size.X, 25);
            _scene.AddRenderable(texDrawIndexeder2);

            ShadowmapDrawer texDrawIndexeder3 = new ShadowmapDrawer(() => _window, () => _sc.FarShadowMapView);
            _resizeHandled            += (w, h) => texDrawIndexeder3.OnWindowResized();
            texDrawIndexeder3.Position = new Vector2(30 + (texDrawIndexeder3.Size.X * 2), 25);
            _scene.AddRenderable(texDrawIndexeder3);

            ShadowmapDrawer reflectionTexDrawer = new ShadowmapDrawer(() => _window, () => _sc.ReflectionColorView);
            _resizeHandled += (w, h) => reflectionTexDrawer.OnWindowResized();
            reflectionTexDrawer.Position = new Vector2(40 + (reflectionTexDrawer.Size.X * 3), 25);
            _scene.AddRenderable(reflectionTexDrawer);

            ScreenDuplicator duplicator = new ScreenDuplicator();
            _scene.AddRenderable(duplicator);

            _fsq = new FullScreenQuad();
            _scene.AddRenderable(_fsq);

            CreateAllObjects();
            ImGui.StyleColorsClassic();
        }