Thread: Beginning C++ with MS Github Tutorial Boilerplate Code Difference

  1. #1
    Registered User
    Join Date
    Apr 2019
    Posts
    2

    Beginning C++ with MS Github Tutorial Boilerplate Code Difference

    Hi,


    I'm starting out with C++ and DirectX and I decided to follow along with the micrsoft github tutorial on DirectX12 found here The basic game loop * Microsoft/DirectXTK Wiki * GitHub.


    I installed the following workloads:



    • Game development with C++
    • Desktop development with C++
    • Universal Windows Platform development
    • C++ Universal Windows Platform tools



    The example in the link above says I should see this code:


    Code:
    // Initialize the Direct3D resources required to run.
    void Game::Initialize(HWND window, int width, int height)
    {
        m_window = window;
        m_outputWidth = std::max( width, 1 );
        m_outputHeight = std::max( height, 1 );
    
    
        CreateDevice();
    
    
        CreateResources();
    
    
        // TODO: Change the timer settings if you want something other than the default
        // variable timestep mode.
        // e.g. for 60 FPS fixed timestep update logic, call:
        /*
        m_timer.SetFixedTimeStep(true);
        m_timer.SetTargetElapsedSeconds(1.0 / 60);
        */
    }

    However, when I created a project I found some of the code above is in a different function:


    Code:
    // Loads and initializes application assets when the application is loaded.
    App1Main::App1Main()
    {
        // TODO: Change the timer settings if you want something other than the default variable timestep mode.
        // e.g. for 60 FPS fixed timestep update logic, call:
        /*
        m_timer.SetFixedTimeStep(true);
        m_timer.SetTargetElapsedSeconds(1.0 / 60);
        */
    }

    And the Initialize function has this code instead:


    Code:
    // The first method called when the IFrameworkView is being created.
    void App::Initialize(CoreApplicationView^ applicationView)
    {
        // Register event handlers for app lifecycle. This example includes Activated, so that we
        // can make the CoreWindow active and start rendering on the window.
        applicationView->Activated +=
            ref new TypedEventHandler<CoreApplicationView^, IActivatedEventArgs^>(this, &App::OnActivated);
    
    
        CoreApplication::Suspending +=
            ref new EventHandler<SuspendingEventArgs^>(this, &App::OnSuspending);
    
    
        CoreApplication::Resuming +=
            ref new EventHandler<Platform::Object^>(this, &App::OnResuming);
    }

    Teaching myself and I'm stuck because the code on my machine is different from the tutorial. Boilerplate should be the same. I made no alterations. Code runs and makes a spinning cube.


    What am I missing here? Is the tutorial out of date or did I do something wrong?


    I'm using VS2019 if that matters.


    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    The tutorial looks like it was written for C++, whereas your sample code looks like it is written in C++/CLI, which is a variant of C++, but is ultimately not C++.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2019
    Posts
    2
    Quote Originally Posted by laserlight View Post
    The tutorial looks like it was written for C++, whereas your sample code looks like it is written in C++/CLI, which is a variant of C++, but is ultimately not C++.
    Thanks for the insight. I thought I was going crazy as C++ has changed alot in the years since i used it last (2005). I found a template VSIX file belonging to that tutorial and installed it for VS2017. Everything works as it should and the C++ code on the site is the same as the template files.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to use github?
    By endrick in forum Tech Board
    Replies: 9
    Last Post: 01-09-2016, 11:34 PM
  2. Confusing Error in the beginning of my c++ code
    By bry in forum C++ Programming
    Replies: 9
    Last Post: 05-07-2013, 12:41 AM
  3. Replies: 2
    Last Post: 05-03-2013, 08:50 AM
  4. Replies: 11
    Last Post: 07-05-2011, 01:09 AM
  5. troubleshooting beginning array code
    By killerwhalepat in forum C Programming
    Replies: 2
    Last Post: 06-24-2011, 07:22 AM

Tags for this Thread