<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Madhavan Lakshminarayanan</title>
    <description>The latest articles on DEV Community by Madhavan Lakshminarayanan (@lmadhavan).</description>
    <link>https://dev.to/lmadhavan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F886369%2Fe3d6e1df-a829-4a8d-8e50-9ab917aea0db.png</url>
      <title>DEV Community: Madhavan Lakshminarayanan</title>
      <link>https://dev.to/lmadhavan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lmadhavan"/>
    <language>en</language>
    <item>
      <title>Building a Jekyll website using Visual Studio</title>
      <dc:creator>Madhavan Lakshminarayanan</dc:creator>
      <pubDate>Sun, 03 Jul 2022 05:24:17 +0000</pubDate>
      <link>https://dev.to/lmadhavan/building-a-jekyll-website-using-visual-studio-260d</link>
      <guid>https://dev.to/lmadhavan/building-a-jekyll-website-using-visual-studio-260d</guid>
      <description>&lt;p&gt;&lt;a href="https://jekyllrb.com/"&gt;Jekyll&lt;/a&gt; is a popular static site generator that takes Markdown content and renders it through templates to produce static pages, which you can then upload to a hosting service such as &lt;a href="https://pages.github.com/"&gt;GitHub Pages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm someone who likes to use an IDE whenever possible, and if you're a Windows developer like me who happens to have Visual Studio installed, then you've already got an excellent dev environment for Jekyll. A lightweight editor such as Visual Studio Code will work just as well, if not better, but I already had Visual Studio, so that's what I used.&lt;/p&gt;

&lt;p&gt;Once you've bootstrapped your Jekyll website (see &lt;a href="https://jekyllrb.com/docs/"&gt;Jekyll documentation&lt;/a&gt; for instructions), simply right-click your website folder in File Explorer and select &lt;em&gt;Open in Visual Studio&lt;/em&gt;. Out of the box, you get support for most of the file types you will be dealing with, including HTML/CSS, &lt;code&gt;_config.yml&lt;/code&gt; and &lt;code&gt;Gemfile&lt;/code&gt;. The two quality-of-life improvements that I made were related to Markdown support and a custom task for launching a local server.&lt;/p&gt;

&lt;h3&gt;
  
  
  Markdown support
&lt;/h3&gt;

&lt;p&gt;Most of the content in a Jekyll website is typically authored using Markdown, however the built-in Markdown support in Visual Studio is somewhat lacking. This is easily fixed by grabbing the excellent &lt;a href="https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor"&gt;Markdown Editor&lt;/a&gt; extension from the Visual Studio Marketplace, which improves syntax highlighting and adds live preview.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;VS Code supports these features out of the box, no extension needed.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom launch task
&lt;/h3&gt;

&lt;p&gt;Jekyll provides an easy way to test your website locally by running &lt;code&gt;bundle exec jekyll serve&lt;/code&gt;. I created a custom launch task for this so I could fire up the server without leaving the IDE. To do this, right-click any file in Solution Explorer and select &lt;em&gt;Configure Tasks&lt;/em&gt;. In the &lt;code&gt;tasks.vs.json&lt;/code&gt; file that opens up, replace the &lt;strong&gt;tasks&lt;/strong&gt; section with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"tasks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"taskLabel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Local Server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"appliesTo"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"${env.COMSPEC}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="s2"&gt;"bundle exec jekyll serve"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, when you right-click any file in Solution Explorer, you should see a &lt;em&gt;Run Local Server&lt;/em&gt; option. Clicking this will launch the server and Jekyll logs will go to the Output pane. You can continue editing files in the IDE and Jekyll will automatically pick up any changes. The server will terminate when you close Visual Studio; if you need to do this manually (for example, if you make changes to &lt;code&gt;_config.yml&lt;/code&gt;), select &lt;em&gt;Build &amp;gt; Cancel&lt;/em&gt; from the menu or use the &lt;code&gt;Ctrl+Break&lt;/code&gt; shortcut.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; &lt;em&gt;VS Code uses a nearly identical &lt;code&gt;tasks.json&lt;/code&gt; file for custom tasks. See the &lt;a href="https://code.visualstudio.com/docs/editor/tasks#_custom-tasks"&gt;documentation&lt;/a&gt; for more details.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>jekyll</category>
      <category>visualstudio</category>
    </item>
    <item>
      <title>Compiling a Direct2D linkable shader using Visual Studio</title>
      <dc:creator>Madhavan Lakshminarayanan</dc:creator>
      <pubDate>Sun, 03 Jul 2022 05:08:32 +0000</pubDate>
      <link>https://dev.to/lmadhavan/compiling-a-direct2d-linkable-shader-using-visual-studio-14lo</link>
      <guid>https://dev.to/lmadhavan/compiling-a-direct2d-linkable-shader-using-visual-studio-14lo</guid>
      <description>&lt;p&gt;Effect shader linking is a Direct2D optimization that links multiple shaders together so that they can be rendered in a single pass. If you're writing custom shaders, you want to ensure that they are linking compatible in order to take advantage of this optimization. The &lt;a href="https://docs.microsoft.com/en-us/windows/win32/direct2d/effect-shader-linking"&gt;official documentation&lt;/a&gt; explains how to author and compile such effects, however the default HLSL build in Visual Studio does not provide support for linking-compatible shaders. Instead, you need to configure a custom build step to do this, which is what this post will walk you through.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create a batch script to compile the shader
&lt;/h3&gt;

&lt;p&gt;First, create a batch script in your Visual Studio project that will execute the two-step process to compile a linking-compatible shader, let's call it &lt;code&gt;buildshader.bat&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;fxc&lt;/span&gt; &lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.hlsl &lt;span class="na"&gt;/nologo /T &lt;/span&gt;&lt;span class="kd"&gt;lib_4_0&lt;/span&gt; &lt;span class="na"&gt;/D &lt;/span&gt;&lt;span class="kd"&gt;D2D_FUNCTION&lt;/span&gt; &lt;span class="na"&gt;/D &lt;/span&gt;&lt;span class="kd"&gt;D2D_ENTRY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;main&lt;/span&gt; &lt;span class="na"&gt;/Fl &lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.fxlib &lt;span class="na"&gt;/I &lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="kd"&gt;fxc&lt;/span&gt; &lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.hlsl &lt;span class="na"&gt;/nologo /T &lt;/span&gt;&lt;span class="kd"&gt;ps_4_0&lt;/span&gt; &lt;span class="na"&gt;/D &lt;/span&gt;&lt;span class="kd"&gt;D2D_FULL_SHADER&lt;/span&gt; &lt;span class="na"&gt;/D &lt;/span&gt;&lt;span class="kd"&gt;D2D_ENTRY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kd"&gt;main&lt;/span&gt; &lt;span class="na"&gt;/E &lt;/span&gt;&lt;span class="kd"&gt;main&lt;/span&gt; &lt;span class="na"&gt;/setprivate &lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.fxlib &lt;span class="na"&gt;/Fo&lt;/span&gt;:&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;.cso &lt;span class="na"&gt;/I &lt;/span&gt;&lt;span class="err"&gt;%&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is taken straight from the official documentation, except I've introduced a couple of parameters so it can be used as a custom build tool. The first is the input file and the second is the SDK include directory (which is required for the &lt;em&gt;d2d1effecthelpers&lt;/em&gt; include that you will be using in your shader). The outputs of this script are a .fxlib file (intermediate file) and a .cso file (final linking-compatible shader output).&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Configure a custom build tool for the HLSL file
&lt;/h3&gt;

&lt;p&gt;Next, for each HLSL file in your project, open up the property page and make the following changes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Item Type&lt;/strong&gt;&lt;br&gt;
Custom Build Tool&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Command Line&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;buildshader "%(Filename)" "$(UM_IncludePath)"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Outputs&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;%(Filename).fxlib;%(Filename).cso&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additional Dependencies&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;buildshader.bat&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PZXE_IN3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8lmc1m0oy2dv5th2tgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PZXE_IN3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h8lmc1m0oy2dv5th2tgt.png" alt="Custom build settings" width="880" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The outputs and additional dependencies let the build system know when to trigger a rebuild of the input file. You can read more about these options in the &lt;a href="https://docs.microsoft.com/en-us/cpp/build/specifying-custom-build-tools"&gt;Visual Studio documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And that's it! Your shaders will be automatically (re)built as part of the standard Visual Studio build process. If you want to look at an actual example, check out the &lt;a href="https://github.com/lmadhavan/fotografix/tree/master/Fotografix.Shaders"&gt;Fotografix repository on GitHub&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>direct2d</category>
      <category>directx</category>
      <category>shader</category>
      <category>visualstudio</category>
    </item>
  </channel>
</rss>
