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

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

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

3,046 Views
1. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
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:

- 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!

Warning: Spoilers inside!

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.

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

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.

Last edited by Manurocker95, Dec 30, 2018
2. SupImBirDyMember

Newcomer
2
Aug 24, 2018
I was playing around with this and couldn’t geat it working so thank you for the tutorial!

3. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
For anything you need, just ask

4. SupImBirDyMember

Newcomer
2
Aug 24, 2018
Stubborness gets in The way my friend

5. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016

- Added Splash screen, title screen and game screen.
- Added SFX and Music classes.
- Added GUI Classes: Text, Sprite and Button.
- 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. eyelinerHas an itch needing to be scratched.

Member
5
Feb 17, 2006
Much praise, my hero!

7. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
Updated template to latest scripts from TIL NX.
Thanks man. Lets do cool stuff

8. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
Added Toggle and some changes to Sprite class for animations.

9. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
Added IntroScreen for initial cinematics and JSON Game Data + multilanguage support.

10. Manurocker95Game Developer & Pokémon Master

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

11. Manurocker95Game Developer & Pokémon Master

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

File size:
99.7 KB
Views:
0
12. UnknownProgrammerNewbie

Newcomer
1
Dec 31, 2018
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. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
Thanks man!!

Happy new yeaaaaar!!!!

14. lordelanGBAtemp Psycho!

Member
9
Jan 4, 2015
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. Manurocker95Game Developer & Pokémon Master

Member
4
May 29, 2016
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. lordelanGBAtemp Psycho!

Member
9
Jan 4, 2015
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).

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.

Last edited by lordelan, Jan 3, 2019

Member
4
May 29, 2016