dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

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

  1. #1
    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 link.


    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
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    6,918

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

    The code on your machine is for a C++/CLI app - and not 'standard C++'. I think you're used the wrong template. If you find C++ code containing ^ after a name, then its fairly certain it's C++/CLI code and not 'standard C++'. Some people/documentation doesn't distinguish between the two, but they are very different beasts.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++17 Compiler: Microsoft VS2019 (16.4.0)

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,171

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

    The link you've supplied states the following: "Our starting point is to use the Direct3D Win32 Game project template. Install the VS 2015 / VS 2017 VSIX on your development system, and then start (or restart) Visual Studio."

    What it wants you to do is install a custom new project template (called 'Direct3D Win32 Game' project) into your Visual Studio. Now the template VSIX installer is made for VS2015 or VS2017 so it may not work on VS2019. However, if the VSIX install succeeds, you'll have a new 'Direct3D Win32 Game' project template and will use that to create a new project.

  4. #4
    Join Date
    Apr 2019
    Posts
    2

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

    Thanks for this info. I got the template installed on VS 2017 and everything works. Thanks.

  5. #5
    Join Date
    Jan 2019
    Location
    Slough
    Posts
    20

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

    hey thanks for the information

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)