[Tutorial] Setting up Visual Studio 2017 environment for Nintendo Switch homebrew development

Discussion in 'Switch - Tutorials' started by Manurocker95, Dec 12, 2018.

  1. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Hello everyone!

    After a whole week fighting with SDL2 I decided to make a similar tutorial to my first one: https://gbatemp.net/threads/tutoria...for-nintendo-3ds-homebrew-development.461083/
    so anyone can easily create stuff for Nintendo Switch.

    This tutorial is mainly made for Windows, so there are maybe some things you cannot use on MAC/Linux. Just change those as needed.

    There's a simple console tutorial made by @WerWolv, so be sure to check it out here.

    Introduction:

    This guide shows how to set up the initial Nintendo Switch homebrew development environment using Visual Studio 2017 Community Edition. This guide should also apply to Visual Studio 2017 Professional/Enterprise and up. This setup will allow you to use Visual Studio's IntelliSense when working with your code, while being able to compile your code into .NRO files for homebrew applications. We can create .NSP o our homebrews with NRO2NSPBuilder.

    By following this guide, you will be creating your own project from scratch in C++. However, should you feel like using a pre-made Visual Studio project template, you may use devkitPro Examples or my own template. If you want a game as reference, check any of my games: Good examples are T-REKT NX or TIL NX which has drag functions.

    We will call Visual Studio 2017 Community as "VS2017" from here on out. As I mentioned before, Enterprise and Professional editions can be used as well.

    Microsoft Visual C/C++ is not bundled with VS2017 by default. You must choose to install this package, as it is required for Nintendo Switch homebrew development. If you cannot find it in the VS2017 Installer, you can follow the instructions to obtain this package below.

    Minum Requirements:

    - Latest version of Visual Studio 2017 Community: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx
    - Microsoft Visual C/C++ package for Visual Studio 2017 Community.
    - Latest stable version of devkitPro: http://devkitpro.org/wiki/Getting_Started
    - Switch packages obtained by pacman packages
    - Knowledge in C or C++.
    - Creativity and time to make good stuff.

    Notes:

    To explain the inconsistencies of slashes, "\" and "/", used in this guide:

    In Windows, of any editions, it uses backslashes "\" as file separators, and not forward slashes "/". This also means in Visual Studio of any editions, it natively uses backslashes "\" as file separators. If you see forward slashes "/", this clearly means it is used in Makefiles.

    The usage of backslashes "\" was due to the forward slashes "/" being used as indicators for "switches" or "flags" (cmd.exe /w, or /help) in IBM software, and is not compatible to parse as file separators. MS-DOS adopted this, and to this day, forward slash switches are still used in many places.

    Setup:

    Warning: Spoilers inside!

    Adding more packages for devkitPro:

    Warning: Spoilers inside!

    Using SDL in your project:

    We will use NX-Shell's my SDL Helper modification. Let's see how it works:

    Warning: Spoilers inside!

    Testing the homebrew:

    YuZu now supports SDL Rendering in latest Canary:

    https://github.com/yuzu-emu/yuzu-canary/releases

    For testing in Real-Hardware we have two options:

    - Copy the generated .nro to the SD/switch folder and test it from the HBMenu.
    - Use NX Link:

    NXLink is already installed with devkitpro if Switch tools are installed. If you don't have it, install switch tools with pacman.

    - Go to the HBMenu in your switch and press Y to start the netloader. A pop-up will appear with the IP of your switch (It must be connected to Internet).
    - Go back to your computer and create a text file with this commands:

    Code:
    cd path\to\devkitPro\tools\bin
    nxlink -s -a 192.xxx.xxx.xxx path\to\homebrew.nro
    
    Where the numbers are the IP shown in your switch's screen

    Save the text file with .bat extension.

    Just double click on the bat and it will start sending the HB to your switch. After the copy, the homebrew will run automatically.

    Template:

    In the template you will find a good example of how to create a game easily with template classes: Splash Screen, Title Screen, Intro Screen (cinematic) and Game Screen.

    It has some UI classes for creating sprites, buttons and toggles. Sprites can be animated by frames. Sprites can be draggable with the Switch touch screen.

    It has game data and multilanguage support with JSON.

    Take a look to it, and if you need help, just ask.

    Credits:

    Warning: Spoilers inside!

    If this tutorial has been useful to you, credits are appreaciated. :D
    For anything, just leave a comment below.
     
    Last edited by Manurocker95, Dec 30, 2018
  2. SupImBirDy

    SupImBirDy Member

    Newcomer
    2
    Aug 24, 2018
    United States
    I was playing around with this and couldn’t geat it working so thank you for the tutorial!:yayswitch:
     
  3. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    For anything you need, just ask :D
     
  4. SupImBirDy

    SupImBirDy Member

    Newcomer
    2
    Aug 24, 2018
    United States
    Stubborness gets in The way my friend
     
  5. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    New Additions:

    - Added Splash screen, title screen and game screen.
    - Added Loading screen and more modifications to load custom fonts in ttf format.
    - Added SFX and Music classes.
    - Added GUI Classes: Text, Sprite and Button.
    - Added Save Data.
    - Everything is more noob-friendly.

    Check out my last game: https://gbatemp.net/threads/touch-game-til-nx.526417/
     
    Last edited by Manurocker95, Dec 17, 2018
    lordelan and SupImBirDy like this.
  6. eyeliner

    eyeliner Has an itch needing to be scratched.

    Member
    5
    Feb 17, 2006
    Portugal
    Much praise, my hero!
     
  7. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Updated template to latest scripts from TIL NX.
    Thanks man. Lets do cool stuff :D
     
  8. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Added Toggle and some changes to Sprite class for animations.
     
  9. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Added IntroScreen for initial cinematics and JSON Game Data + multilanguage support.
     
  10. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Added draw functions for rotated images. Drag functions are now in sprite class. Any sprite can be draggable.
     
  11. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    YUZU now renders SDL2 .nro soo it's the best option for testing.
     

    Attached Files:

  12. UnknownProgrammer

    UnknownProgrammer Newbie

    Newcomer
    1
    Dec 31, 2018
    United States
    This was incredibly helpful for someone just getting into Switch development. Thank you!!

    If you're having issues with BaseTsd.h make sure to install "Windows 8.1 SDK and UCRT SDK" from the Visual Studio Installer.
     
    Manurocker95 likes this.
  13. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    Thanks man!!

    Happy new yeaaaaar!!!!
     
  14. lordelan

    lordelan GBAtemp Psycho!

    Member
    9
    Jan 4, 2015
    Germany
    Thx for the tutorial. Haven't read it yet but I will try it out. I set up an environment on Linux a few month ago and had some issues which lead to a lack of interest but I'll try this. :)
     
  15. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    you are welcome, m8. This is mainly for windows but it shouldn't be so different to set this up for Linux
     
    lordelan likes this.
  16. lordelan

    lordelan GBAtemp Psycho!

    Member
    9
    Jan 4, 2015
    Germany
    No no, I'd try it on Windows, don't worry.
    I don't think I would use VS under Linux lol. Even with Wine.

    Edit: Btw you should edit your signature and make sure that words like "Nintendo Switch Games" are not inside any color tags.
    Because right now those words are completely invisible for users using the gbatemp dark theme (like me). :P

    Edit 2: Since you're crediting this guy would you mind to be the person who finally fullfills my wish of a Blobby Volley 2 Switch port? :)

    Edit 3: Okay that's not BV2 but "just" a simple rewrite of BV1 but that's something. Maybe I'll try it on my own. :P
     
    Last edited by lordelan, Jan 3, 2019
  17. Manurocker95
    OP

    Manurocker95 Game Developer & Pokémon Master

    Member
    4
    May 29, 2016
    Spain
    Madrid
    If you do it, I'll give it a try :P I may include physics libs like box2D in my template sometime
     
    lordelan likes this.
  18. lordelan

    lordelan GBAtemp Psycho!

    Member
    9
    Jan 4, 2015
    Germany
    Very appreciated! :P
     
Loading...