Sunday, July 12, 2020

UE4: Using Visual Studio Code for UE4 c++ project

It's possible to get UE4 to work with Visual Studio Code without installing Visual Studio.

My setup:
  • Windows 10
  • Visual Studio Code 1.47.0
  • Unreal Engine 4.24.2
Install Build Tools for Visual Studio
From the Visual Studio Downloads page, scroll down until you see Tools for Visual Studio under the All downloads section and select the download for Build Tools for Visual Studio.

Open vs_BuildTools.exe. Under Workloads, select C++ build tools. On the right, make sure to keep the optional component MSVC vXXX - VS 2019 C++ x64/x86 build tools and Windows 10 SDK checked. You can uncheck Testing tools core features - Build Tools and C++ AddressSanitizer (Experimental) to save some space.

Under Workloads, select .Net desktop build tools. You can uncheck all the optional components to save ~1.68 GB. You will be prompted to reboot once the installation is completed.

Change default editor to Visual Studio Code
Open UE4, you should now be able to create a new c++ game project. Once the project is generated, open UE4 and go to Edit > Editor Preferences.... Under General > Source Code, change Source Code Editor to Visual Studio Code. Then restart UE4.

Generate Visual Studio Code project files
Now when you right-click on your .uproject in Windows Explorer, Generate Visual Studio project files should now create MyProject.code-workspace for Visual Studio Code.

Configure build task in Visual Studio Code
In Visual Studio Code, install the c++ extension if you haven't already. To configure the build task, go to Terminal > Configure Default Build Task..., select MyProjectEditor Win64 Development Build. Press Ctrl + Shift + B to build the project, and hot reload should work as expected.

Configure Visual Studio Code for Microsoft C++

Saturday, July 11, 2020

Haxe: Compile game through hashlink/c code on Win10

Here is my setup
  • Windows 10
  • Visual Studio 2017
  • haxe 4.0.5
  • hashlink 1.11 
  • heaps 1.8.0
note: cpp targeting is not currently supported by heaps
note: hashlink 1.11 comes with x64 libraries, so we'll be compiling our game for x64. If you want to target x86, you will likely need to compile hashlink yourself to get the x86 libs for linking.

Main.hx -- this is the hello world sample from
class Main extends hxd.App {
    override function init() {
        var tf = new h2d.Text(hxd.res.DefaultFont.get(), s2d);
        tf.text = "Hello World !";
    static function main() {
        new Main();

-lib heaps
-lib hldx
-hl out/main.c
-main Main

Compile it into c code
haxe build.hxml

We will use Visual Studio to compile the c code
  1. start menu > x64 Native Tools Command Prompt for VS
    1. alternatively, open cmd and run vcvars64.bat (since we are targeting x64)
      for VS 2017, it should be located at C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat
  2. cd "path to your project directory"
  3. cl /Ox /Fo:main.obj /Fe:main.exe out/main.c /I out /I C:/HaxeToolkit/hl-1.11.0-win/include /link /LIBPATH:C:/HaxeToolkit/hl-1.11.0-win libhl.lib ssl.lib ui.lib directx.lib openal.lib fmt.lib
If everything goes well, a main.exe would be created in your project's directory. This is what the output looks like
C:\my_game>cl /Ox /Fo:main.obj /Fe:main.exe out/main.c /I out /I C:/HaxeToolkit/hl-1.11.0-win/include /link /LIBPATH:C:/HaxeToolkit/hl-1.11.0-win libhl.lib ssl.lib ui.lib directx.lib openal.lib fmt.lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.16.27035 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 14.16.27035.0
Copyright (C) Microsoft Corporation.  All rights reserved.



If you want to hide the console window, call hl.UI.closeConsole() at startup as ncannasse suggested.

How to compile c files generated by HashLink
Error on Compile C generated files using CL.EXE
How to compile x64 code with Visual Studio in command line?
How to resolve the module machine type 'X86' conflicts with target machine type 'x64' Visual Studio
HashLink/C Compilation - Haxe - The Cross-platform Toolkit
Getting started with Haxe/C++ - Haxe - The Cross-platform Toolkit
MSVC compiler options
MSVC linker options 
[SOLVED] Error when compiling heaps to cpp Windows -

Monday, February 3, 2020

Sunday, February 2, 2020

Python: setting up virtual environment

The commands I use to create a virtual environment in Python.
  1. python -m venv env
  2. env\Scripts\activate
  3. pythonw -m idlelib

Sunday, December 8, 2019

Steam: Move game files to another drive

1. Steam > Settings > Downloads > Steam Library Folders
2. Add Library Folder and select the desired location
3. Click OK to apply the settings
4. Right-click on the game which you want to move > Properties...
5. Local Files > Move Install Folder

How to Move a Steam Game to Another Drive, The Easy Way

Saturday, December 7, 2019

ASUS ROG GL531: Disable keyboard LED when in sleep mode

When I put the laptop in sleep mode, the keyboard LED blinks in RED, which can be annoying. One option is to close the lid. Alternatively, it can be turned off through ASUS's Armoury Crate.

1. open Armoury Crate
2. Device > System
3. Lighting > Settings
4. set Sleep to OFF