示例#1
0
        /// <summary>
        /// Initializes the graphic library using the specified surface target.
        /// </summary>
        /// <param name="targetSurface">The surface which the library will target.</param>
        public override void Initialize(ISurface targetSurface)
        {
            base.Initialize(targetSurface);

            SharpVk.Version engineVersion = new SharpVk.Version
                                            (
                Engine.Version.Major,
                Engine.Version.Minor,
                Engine.Version.Revision
                                            );

            SharpVk.Version gameVersion = new SharpVk.Version
                                          (
                Engine.GameVersion.Major,
                Engine.GameVersion.Minor,
                Engine.GameVersion.Revision
                                          );

            ApplicationInfo appInfo = new ApplicationInfo
            {
                ApplicationName    = Engine.GameName,
                EngineName         = Engine.Name,
                EngineVersion      = engineVersion,
                ApplicationVersion = gameVersion
            };

            DebugReportCallbackCreateInfo debugInfo = new DebugReportCallbackCreateInfo
            {
                Callback = DebugCallback,
                Flags    = DebugFlags(),
                UserData = IntPtr.Zero
            };

            List <string> validationLayers = new List <string>();
            var           layers           = Instance.EnumerateLayerProperties();

            if (layers.Any(x => x.LayerName == "VK_LAYER_LUNARG_standard_validation"))
            {
                validationLayers.Add("VK_LAYER_LUNARG_standard_validation");
            }

            if (layers.Any(x => x.LayerName == "VK_LAYER_LUNARG_monitor"))
            {
                validationLayers.Add("VK_LAYER_LUNARG_monitor");
            }

            if (layers.Any(x => x.LayerName == "VK_LAYER_KHRONOS_validation"))
            {
                validationLayers.Add("VK_LAYER_KHRONOS_validation");
            }

            // - Creates the vulkan instance
            Handle = Instance.Create(validationLayers.ToArray(), targetSurface.Extensions, null, appInfo, debugInfo);
        }
示例#2
0
        public void Run()
        {
            // SDL Init
            if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
            {
                Destroy();
                throw new Exception(SDL_GetError());
            }

            Running = true;

            // Create Window
            Window = SDL_CreateWindow(
                "Vukan Test",
                SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1600, 900,
                SDL_WindowFlags.SDL_WINDOW_SHOWN |
                SDL_WindowFlags.SDL_WINDOW_VULKAN |
                SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI |
                SDL_WindowFlags.SDL_WINDOW_RESIZABLE
                );
            WindowID = SDL_GetWindowID(Window);

            Version version = Instance.EnumerateVersion();

            Output.WriteLine($"Vulkan - Version: {version.Major}.{version.Minor}.{version.Patch}");             // Debug

            InitialiseVulkan();

            while (Running)
            {
                PollEvents();

                DrawFrame();
            }

            TearDown();
        }