diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-03-01 22:30:37 +0100 |
|---|---|---|
| committer | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2021-03-01 22:30:37 +0100 |
| commit | 5c546234343f5d31d3030c2a4ee0188c76c6264a (patch) | |
| tree | 50d3c1e02dff5dc5fc3139501cb1eb30cd728c3d | |
| parent | a27bb22c63c9944c354b40d9d0d9ee5630b9574e (diff) | |
tests
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | CrowWindow/VkCrowWindow.cs | 19 | ||||
| -rwxr-xr-x[-rw-r--r--] | clean.sh | 0 | ||||
| -rw-r--r-- | src/VkChess.cs | 55 | ||||
| -rw-r--r-- | ui/chess.style | 53 | ||||
| -rw-r--r-- | ui/main.crow | 6 |
6 files changed, 70 insertions, 64 deletions
@@ -2,4 +2,5 @@ build obj bin .vs +.vscode *.user diff --git a/CrowWindow/VkCrowWindow.cs b/CrowWindow/VkCrowWindow.cs index d72b801..6cfba67 100644 --- a/CrowWindow/VkCrowWindow.cs +++ b/CrowWindow/VkCrowWindow.cs @@ -40,6 +40,7 @@ namespace vke { VkDescriptorSetLayoutBinding dslBinding = new VkDescriptorSetLayoutBinding (0, VkShaderStageFlags.Fragment, VkDescriptorType.CombinedImageSampler); + FrameBuffers frameBuffers; protected override void initVulkan () { base.initVulkan (); @@ -63,7 +64,7 @@ namespace vke { ui.Start (); } protected virtual void CreateRenderPass () { - renderPass = new RenderPass (dev, swapChain.ColorFormat, dev.GetSuitableDepthFormat (), VkSampleCountFlags.SampleCount1); + renderPass = new RenderPass (dev, swapChain.ColorFormat, VkSampleCountFlags.SampleCount1); } @@ -144,11 +145,16 @@ namespace vke { dev.WaitIdle (); initCrowSurface (); iFace.ProcessResize (new Rectangle (0, 0, (int)Width, (int)Height)); + + frameBuffers?.Dispose(); + frameBuffers = renderPass.CreateFrameBuffers(swapChain); } - protected virtual void recordUICmd (CommandBuffer cmd) { + protected virtual void recordUICmd (PrimaryCommandBuffer cmd, int imageIndex) { + renderPass.Begin(cmd, frameBuffers[imageIndex]); fsqPl.BindDescriptorSet (cmd, descSet, 0); fsqPl.RecordDraw (cmd); + renderPass.End (cmd); } void crowThread () { @@ -223,12 +229,8 @@ namespace vke { System.Diagnostics.Debug.WriteLine (ex.Message); } } - protected void loadIMLFragment (string imlFragment, object dataSource = null) { - try { - iFace.LoadIMLFragment (imlFragment).DataSource = dataSource; - } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine (ex.Message); - } + protected void loadIMLFragment (string imlFragment, object dataSource = null) { + iFace.LoadIMLFragment (imlFragment).DataSource = dataSource; } protected void closeWindow (string path) { Widget g = iFace.FindByName (path); @@ -241,6 +243,7 @@ namespace vke { dev.WaitIdle (); running = false; + frameBuffers?.Dispose(); fsqPl.Dispose (); dsPool.Dispose (); cmdPoolCrow.Dispose (); diff --git a/src/VkChess.cs b/src/VkChess.cs index ac90567..c31e4dd 100644 --- a/src/VkChess.cs +++ b/src/VkChess.cs @@ -9,7 +9,7 @@ using vke; using vke.glTF; using Glfw; using Vulkan; -using System.Runtime.InteropServices; +using System.Reflection; namespace vkChess { @@ -19,6 +19,24 @@ namespace vkChess public enum PieceType { Pawn, Rook, Knight, Bishop, King, Queen }; public class VkChess : CrowWindow { +#if NETCOREAPP + static IntPtr resolveUnmanaged (Assembly assembly, String libraryName) { + + switch (libraryName) + { + case "glfw3": + return System.Runtime.InteropServices.NativeLibrary.Load("glfw", assembly, null); + case "rsvg-2.40": + return System.Runtime.InteropServices.NativeLibrary.Load("rsvg-2", assembly, null); + } + Console.WriteLine ($"[UNRESOLVE] {assembly} {libraryName}"); + return IntPtr.Zero; + } + + static VkChess () { + System.Runtime.Loader.AssemblyLoadContext.Default.ResolvingUnmanagedDll+=resolveUnmanaged; + } +#endif static void Main (string [] args) { Instance.VALIDATION = true; //Instance.RENDER_DOC_CAPTURE = true; @@ -126,8 +144,7 @@ namespace vkChess }; DeferredPbrRenderer renderer; - - [StructLayout (LayoutKind.Sequential)] + public struct InstanceData { public Vector4 color; @@ -172,7 +189,8 @@ namespace vkChess statPool.End (cmds[i]); #else renderer.recordDraw (cmds [i], i, instanceBuff, instancedCmds?.ToArray ()); - this.recordUICmd (cmds[i]); + + this.recordUICmd (cmds[i], i); #endif cmds [i].End (); } @@ -492,6 +510,35 @@ namespace vkChess EnableHint = hintIsEnabled; } } + public string StockfishDirectory { + get { + try + { + return System.IO.Path.GetDirectoryName(StockfishPath); + } + catch + { + return Directory.GetCurrentDirectory(); + } + + } + } + + void onFindStockfishPath (object sender, MouseButtonEventArgs e) { + /*loadIMLFragment (@" + <FileDialog Caption='Select SDK Folder' CurrentDirectory='/home' + ShowFiles='true' ShowHidden='true' OkClicked='onSelectStockfishPath'/> + ",this);*/ + + loadIMLFragment (@" + <FileDialog/> + ",this); + } + public void onSelectStockfishPath (object sender, EventArgs e) + { + StockfishPath = (sender as FileDialog).SelectedFileFullPath; + } + void onNewGameClick (object sender, MouseButtonEventArgs e) { loadWindow ("ui/newGame.crow", this); } diff --git a/ui/chess.style b/ui/chess.style index 1a057be..fd5d67d 100644 --- a/ui/chess.style +++ b/ui/chess.style @@ -1,6 +1,4 @@ -Window { - Background="0.01,0.01,0.01,0.8"; -} + icon { Width="14"; Height="14"; @@ -27,55 +25,6 @@ labStatus2 { TextAlignment="Center"; } -MemberViewLabel { - Margin="1"; - Height="Fit"; - Width="50%"; - Background="White"; -} -MemberViewHStack { - Focusable="true"; - Height="Fit"; - Spacing="1"; - MouseEnter="{Background=SteelBlue}"; - MouseLeave="{Background=Transparent}"; -} - -IcoBut { - Template = "#Crow.Coding.ui.IcoBut.template"; - MinimumSize = "10,10"; - Width = "8"; - Height = "14"; - Background = "White"; -} -TabItem { - AllowDrag="false"; - Background="Jet"; -} -TreeItemBorder { - CornerRadius="2"; - Margin="0"; - Focusable="true"; - Height="Fit"; - Width="Stretched"; - Foreground="Transparent"; - MouseEnter="{Foreground=DimGrey}"; - MouseLeave="{Foreground=Transparent}"; -} -TreeIcon { - Margin="0"; - Width="14"; - Height="14"; -} -NormalizedFloat { - Minimum="0.0"; - Maximum="1.0"; - SmallIncrement="0.01"; - LargeIncrement="0.1"; - Decimals="2"; - Width="60"; - Foreground="Black"; -} CheckBox { Template = "ui/checkBox.tmp"; Height= "Fit"; diff --git a/ui/main.crow b/ui/main.crow index 4a9474b..10dde48 100644 --- a/ui/main.crow +++ b/ui/main.crow @@ -1,6 +1,12 @@ <?xml version="1.0"?> <Window Caption="Options" Left="10" Top="1" Width="70%" Height="50%" CornerRadius="5" > <VerticalStack Spacing="1" Margin="10" > + <HorizontalStack Height="Fit" Margin="5"> + <Label Text="Stockfish executable path:"/> + <Image Width="30" Height="20" Path="#Crow.Icons.IconAlerte.svg" Visible="{StockfishNotFound}"/> + <TextBox Width="Stretched" Text="{²StockfishPath}"/> + <Button Caption="..." MinimumSize="1,1" Width="Fit" MouseClick="onFindStockfishPath"/> + </HorizontalStack> <HorizontalStack Height="Fit"> <VerticalStack Spacing="3" Width="50%" > <HorizontalStack Height="Fit"> |