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();
        }
Esempio n. 3
0
        public NeoDemo()
        {
            WindowCreateInfo windowCI = new WindowCreateInfo
            {
                X                  = 50,
                Y                  = 50,
                WindowWidth        = 960,
                WindowHeight       = 540,
                WindowInitialState = WindowState.Normal,
                WindowTitle        = "Veldrid NeoDemo"
            };
            RenderContextCreateInfo rcCI = new RenderContextCreateInfo();

            rcCI.DebugContext = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);

            VeldridStartup.CreateWindowAndRenderContext(ref windowCI, ref rcCI, out _window, out _rc);
            _window.Resized += () => _windowResized = true;

            _sc.CreateDeviceObjects(_rc);
            CommonMaterials.CreateAllDeviceObjects(_rc);

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

            _sc.SetCurrentScene(_scene);

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

            InfiniteGrid grid = new InfiniteGrid();

            grid.CreateDeviceObjects(_rc);
            _scene.AddRenderable(grid);

            Skybox skybox = Skybox.LoadDefaultSkybox();

            skybox.CreateDeviceObjects(_rc);
            _scene.AddRenderable(skybox);

            AddTexturedMesh(
                "Textures/spnza_bricks_a_diff.png",
                PrimitiveShapes.Box(10, 10, 10, 10),
                new Vector3(0, 0, -5),
                Quaternion.Identity,
                Vector3.One);

            AddTexturedMesh(
                "Textures/spnza_bricks_a_diff.png",
                PrimitiveShapes.Box(5, 5, 5, 5f),
                new Vector3(-3, -9, 2),
                Quaternion.Identity,
                Vector3.One);

            AddTexturedMesh(
                "Textures/spnza_bricks_a_diff.png",
                PrimitiveShapes.Box(27, 3, 27, 27f),
                new Vector3(-5, -16, 5),
                Quaternion.Identity,
                Vector3.One);

            AddTexturedMesh(
                "Textures/spnza_bricks_a_diff.png",
                PrimitiveShapes.Plane(100, 100, 5),
                new Vector3(0, -20, 0),
                Quaternion.Identity,
                Vector3.One);

            ShadowmapDrawer texDrawer = new ShadowmapDrawer(_window, () => _sc.NearShadowMapBinding);

            texDrawer.CreateDeviceObjects(_rc);
            texDrawer.Position = new Vector2(10, 25);
            _scene.AddRenderable(texDrawer);

            texDrawer = new ShadowmapDrawer(_window, () => _sc.MidShadowMapBinding);
            texDrawer.CreateDeviceObjects(_rc);
            texDrawer.Position = new Vector2(20 + texDrawer.Size.X, 25);
            _scene.AddRenderable(texDrawer);

            texDrawer = new ShadowmapDrawer(_window, () => _sc.FarShadowMapBinding);
            texDrawer.CreateDeviceObjects(_rc);
            texDrawer.Position = new Vector2(30 + (texDrawer.Size.X * 2), 25);
            _scene.AddRenderable(texDrawer);
        }