<?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: Konrad Chmielecki</title>
    <description>The latest articles on DEV Community by Konrad Chmielecki (@3mam).</description>
    <link>https://dev.to/3mam</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%2F656725%2Fe75f771f-8bdb-4fb3-a1c2-41ed142bae41.jpg</url>
      <title>DEV Community: Konrad Chmielecki</title>
      <link>https://dev.to/3mam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/3mam"/>
    <language>en</language>
    <item>
      <title>my experience with blazor</title>
      <dc:creator>Konrad Chmielecki</dc:creator>
      <pubDate>Mon, 18 Apr 2022 20:42:00 +0000</pubDate>
      <link>https://dev.to/3mam/my-experience-with-blazor-djp</link>
      <guid>https://dev.to/3mam/my-experience-with-blazor-djp</guid>
      <description>&lt;p&gt;When I wrote my first &lt;a href="https://github.com/3mam/PolySnake"&gt;project&lt;/a&gt; in this year, I don't even planed to used blazor. But my childlike curiosity directed me on that path. &lt;br&gt;
I wanted to know, haw hard will be port game from desktop to web browser in .net. And I found out is not that hard.&lt;br&gt;
But I have experience with similar tools before. I used &lt;a href="https://github.com/gopherjs/gopherjs"&gt;gopherjs&lt;/a&gt; and &lt;a href="https://emscripten.org"&gt;emscripten&lt;/a&gt;.&lt;br&gt;
Thanks to that I know what must to do, to communicate c# with javasrcipt.&lt;br&gt;
I made working blazor port pretty fast. Not only server side but webassembly to.&lt;br&gt;
Of curs create port for different platform always generate some problems.&lt;br&gt;
Most weird problem I have in blazor is how floating point number behave.&lt;br&gt;
I received in some cases NaN values. This problem I resolve adding value like &lt;strong&gt;0.0001&lt;/strong&gt; in calculation.&lt;/p&gt;

&lt;p&gt;Blazor server work differently then wasm. But I don't expected that server version will be cause game to flickering.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jp859JGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58q4h0r3yqejsbpve6ty.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jp859JGv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/58q4h0r3yqejsbpve6ty.gif" alt="game flickering" width="640" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is happen when server don't have enough cpu power.&lt;/p&gt;

&lt;p&gt;Now when I know pros and cons of blazor for creating game, I start thinking about next game.&lt;br&gt;
But I focus only on wasm version and smartphones. This will be challenge, I do not doubt that. &lt;br&gt;
Maybe blazor is not perfect tool for this task. But I see some potential, and is nice to use c# in web browser.&lt;/p&gt;

</description>
      <category>blazor</category>
    </item>
    <item>
      <title>webgl context, canvas and blazor pages</title>
      <dc:creator>Konrad Chmielecki</dc:creator>
      <pubDate>Fri, 08 Apr 2022 15:11:43 +0000</pubDate>
      <link>https://dev.to/3mam/webgl-context-canvas-and-blazor-pages-35bc</link>
      <guid>https://dev.to/3mam/webgl-context-canvas-and-blazor-pages-35bc</guid>
      <description>&lt;p&gt;When I developed my simple game &lt;a href="http://github.com/3mam/PolySnake"&gt;PolySnake&lt;/a&gt;, I decided to experimenting with Blazor. Creating port for server and webassembly don't took me too much time. But as usual, supporting different platform is tedious task.&lt;/p&gt;

&lt;p&gt;Problem I had, is lose connection between &lt;strong&gt;gl&lt;/strong&gt; context and &lt;strong&gt;canvas&lt;/strong&gt;. This happen when &lt;strong&gt;page&lt;/strong&gt; is changed. When switching pages is happening, &lt;strong&gt;html&lt;/strong&gt; components from previous page are removed.&lt;/p&gt;

&lt;p&gt;Return to previous page causes components to be creating agin. But for &lt;strong&gt;webGL&lt;/strong&gt; is not thad same &lt;strong&gt;canvas&lt;/strong&gt;.&lt;br&gt;
And sadly &lt;strong&gt;webGL&lt;/strong&gt; context it does not allow to by signed to other &lt;strong&gt;canvas&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For me initializing everything one more time is not good idea. This is not efficient and require heavy changes in architecture of my game. &lt;br&gt;
And I started thinking, that I can creating &lt;strong&gt;canvas&lt;/strong&gt; in javascript. This &lt;strong&gt;canvas&lt;/strong&gt; will be alive that long as is required. And only need is attached that &lt;strong&gt;canvas&lt;/strong&gt; to other component.&lt;/p&gt;

&lt;p&gt;This component take focus and handling keyboard inputs. Now when &lt;strong&gt;page&lt;/strong&gt; will be changed, &lt;br&gt;
that same &lt;strong&gt;canvas&lt;/strong&gt; will be reattach to proper place.&lt;/p&gt;

&lt;p&gt;This is how it is looking in my code &lt;a href="https://github.com/3mam/PolySnake/blob/main/BlazorWasm/Pages/Index.razor"&gt;Index.razor&lt;/a&gt; and &lt;a href="https://github.com/3mam/PolySnake/blob/main/BlazorWasm/wwwroot/main.js"&gt;main.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blazor</category>
      <category>webgl</category>
    </item>
    <item>
      <title>gl uniform</title>
      <dc:creator>Konrad Chmielecki</dc:creator>
      <pubDate>Thu, 01 Jul 2021 08:36:00 +0000</pubDate>
      <link>https://dev.to/3mam/gl-uniform-1dm6</link>
      <guid>https://dev.to/3mam/gl-uniform-1dm6</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BL8jyw-A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8luisd316hs5t15iyjo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BL8jyw-A--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8luisd316hs5t15iyjo9.png" alt="square and triangle in suits"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lately I had problem with variable in my code. Variable that I send to GLSL don't work. It turned out I forgot &lt;strong&gt;uniform&lt;/strong&gt; instruction before variable type.&lt;br&gt;
Of course my memory is good but short.&lt;/p&gt;

&lt;p&gt;Tabel of functions that use &lt;strong&gt;uniform&lt;/strong&gt; instructions.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;uniform types&lt;/th&gt;
&lt;th&gt;functions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;gl.uniform1f gl.uniform1fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vec2&lt;/td&gt;
&lt;td&gt;gl.uniform2f gl.uniform2fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vec3&lt;/td&gt;
&lt;td&gt;gl.uniform3f gl.uniform3fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;vec4&lt;/td&gt;
&lt;td&gt;gl.uniform4f gl.uniform4fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;int&lt;/td&gt;
&lt;td&gt;gl.uniform1i gl.uniform1iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ivec2&lt;/td&gt;
&lt;td&gt;gl.uniform2i gl.uniform2iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ivec3&lt;/td&gt;
&lt;td&gt;gl.uniform3i gl.uniform3iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ivec4&lt;/td&gt;
&lt;td&gt;gl.uniform4i gl.uniform4iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sampler2D&lt;/td&gt;
&lt;td&gt;gl.uniform1i gl.uniform1iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;samplerCube&lt;/td&gt;
&lt;td&gt;gl.uniform1i gl.uniform1iv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mat2&lt;/td&gt;
&lt;td&gt;gl.uniformMatrix2fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mat3&lt;/td&gt;
&lt;td&gt;gl.uniformMatrix3fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mat4&lt;/td&gt;
&lt;td&gt;gl.uniformMatrix4fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bool&lt;/td&gt;
&lt;td&gt;gl.uniform1i gl.uniform1f gl.uniform1iv gl.uniform1fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bvec2&lt;/td&gt;
&lt;td&gt;gl.uniform2i gl.uniform2f gl.uniform2iv gl.uniform2fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bvec3&lt;/td&gt;
&lt;td&gt;gl.uniform3i gl.uniform3f gl.uniform3iv gl.uniform3fv&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;bvec4&lt;/td&gt;
&lt;td&gt;gl.uniform4i gl.uniform4f gl.uniform4iv gl.uniform4fv&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each functions in table take handle to GLSL variable in first argument &lt;/p&gt;

&lt;p&gt;In functions prefix &lt;strong&gt;i&lt;/strong&gt; is int, &lt;strong&gt;f&lt;/strong&gt; float and &lt;strong&gt;v&lt;/strong&gt; is table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;gl.getUniformLocation(glsl_program, variable_name)&lt;/strong&gt; return handle to variable in GLSL.&lt;/p&gt;

&lt;p&gt;In WebGL handle will be represented by WebGLUniformLocation interface.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>denosaur faster</title>
      <dc:creator>Konrad Chmielecki</dc:creator>
      <pubDate>Sun, 27 Jun 2021 12:07:12 +0000</pubDate>
      <link>https://dev.to/3mam/denosaur-faster-3mcc</link>
      <guid>https://dev.to/3mam/denosaur-faster-3mcc</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_d9QIfJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1traxp0qcdkt02abots.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_d9QIfJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i1traxp0qcdkt02abots.gif" alt="denosaur Text"&gt;&lt;/a&gt;&lt;br&gt;
Thanks to the parameter &lt;strong&gt;--no-check&lt;/strong&gt; you can in &lt;strong&gt;deno&lt;/strong&gt; disable type checking.&lt;br&gt;
Which significantly speeds up &lt;strong&gt;typescript&lt;/strong&gt; processing. &lt;br&gt;
Useful when combined with &lt;strong&gt;vscode&lt;/strong&gt;, which validates code on development.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
