Beginners: DirectX 3D graphics with DirectX tutorial, tutorial part 1

Yep, I wrote the word  tutorial twice, TWICE!  Why?  This is a tutorial on how to use the tutorial found at the link:

And the Quickstart

This is the second component of the DirectX 3D tutorial:

The first code module seems to indicate that the two lines should be together, actually  the second line is further down in the code, so use the find command to locate where it is in the code:

ComPtr<ID3D11RenderTargetView> m_renderTargetView;

//The Second line is further down in the code, use Ctrl+F to find it

m_d3dDeviceContext->OMSetRenderTargets(
    1,
    m_renderTargetView.GetAddressOf(),
    nullptr // use no depth stencil
    );

It might seem as if the example is broken, it isn’t, the assumption is that you would be looking at the first tutorial item you downloaded from

So if you go further down in the code you will see the following lines of code, note that the line:

  • const float clearColor[4] = { 0.071f, 0.04f, 0.561f, 1.0f };
  • If you change the line to:
    • const float clearColor[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
    • You get a nice scary red. 

Keeping the “clearColor[4]” generates a pleasing blue color, except for long term windows users, and then it seems it could be a “blue” screen of death and not a “clear” screen.  But here is the code, hopefully you are actually using the tutorial and real code (Scroll down to see more):

while (true)
       {
           // Process events incoming to the window.
           m_window->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);

           // Specify the render target we created as the output target.
           m_d3dDeviceContext->OMSetRenderTargets(
                1,
               m_renderTargetView.GetAddressOf(),
               nullptr // use no depth stencil
                );

           // Clear the render target to a solid color.
            const float clearColor[4] = { 0.071f, 0.04f, 0.561f, 1.0f };
           m_d3dDeviceContext->ClearRenderTargetView(
               m_renderTargetView.Get(),
               clearColor
               );

           // Present the rendered image to the window.  Because the maximum frame latency is set to 1,
           // the render loop will generally be throttled to the screen refresh rate, typically around
           // 60Hz, by sleeping the application on Present until the screen is refreshed.
           DX::ThrowIfFailed(
               m_swapChain->Present(1, 0)
               );
       }

SwapChain

Swap Chain is super duper fast!  Here is how it works, from Wikipedia:

The first framebuffer, the screenbuffer, is the buffer that is rendered to the output of the video card. Each time a new frame is displayed, the first back buffer in the swap chain takes the place of the screenbuffer, this is called presentation or swapping.

Where to get info on the SwapChain?

Sine the SwapChain is more about the GPU and less about the CPU, most of the good stuff is found in DirectX:

 

Finally some stuff I wrote, was going to delete and now want to share with you:

  • Back in the old days you didn’t get much RAM, like 8,000 bytes of RAM was insane amounts at one time. 
  • So you had to pull data from magnetic tape (those big machines in the background of old shows like Mission Impossible) fill your RAM, do something and then get some other data, the tape might be searching for the new data. 
  • This was very, very, slow compared to todays computers.  Boring too.
  • However, the CPUs were pretty slow too.  This meant that the operation would read a record do something with the record, while the other part of memory was waiting for the tape to find the other information somewhere on the miles of tape.  As long as the tape didn’t stretch, then it was unreadable.
  • The rooms were cool and no one could smoke, that doesn’t seem like much, but back before the 1990s, everyone smoked heavily and I didn’t.
  • You also got some pretty lights.  I miss the pretty lights, but not too much.