- Visual Studio 2017 with C++ development components installed
- In Visual Studio, create a new C++ console application:
- Add the HoloJs Nuget package. Since its a pre-release package, make sure to check the "Include
prerelease" checkbox when searching.
In the source file that contains your main function, add these headers:
using namespace std;
using namespace HoloJs;
Replace the main function body with these lines:
// Instantiate the HoloJs object
shared_ptr<IHoloJsScriptHost> scriptHost(CreateHoloJsScriptHost(), &DeleteHoloJsScriptHost);
// Create a default configuration
auto configuration = HoloJs::ViewConfiguration();
// Run the app; this method returns when the user closes the window on desktop or
// switches away from the app on VR and HoloLens.
Press F5 to run.
Without a VR headset, you should get a window that renders cubes floating in space:
If you have a VR headset connected, you should see cubes floating around you in a virtual room:
Debugging scripts running inside HoloJsWhen HoloJs is hosted inside a Win32 app, you will use Visual Studio Code to debug your scripts.
- Enable debugging in HoloJs by adding this line of code before you start the script app:
scriptHost->enableDebugger();Note: With the debugger enabled, the script app will not start until a debugger attaches. The window will appear hung until then.
- Start Visual Studio Code and open the folder where the scripts are located
Create a debug configuration
- Go to the debugger panel (Ctrl + Shift + D)
- Add a new debug configuration
Pick "node.js" from the options list
Add the following to the launch.json file:
- This debug configuration is now saved in .vscode/launch.json and it will work every time you open this folder in Visual Studio Code.
Note: The list of scripts running can be found in the debug panel, under "Loaded scripts"