GitHunt
EL

Electron7-7/nostalgia-game-engine

A game engine developed in C++, with the goal of capturing the feeling of PS2-era video games with modern sensibilities and quality of life features.

    Nostalgia

        

    (Or, "How I learned to stop crashing and love stable code")

(LolBit texture stolen from Puppet)

Check out the wiki for more info, guides, and documentation!

A New Old Game Engine

My goal for creating the Nostalgia game engine is for it to eventually be capable of capturing the feeling of PS2-era video games, albiet with modern sensibilities and quality of life features added on top. This is a very ambitious goal, considering that it's only my second game engine, but it's a goal nonetheless.

Building Nostalgia

Note for Windows users: there is currently no working DLL option, as it's much more complicated than building a shared library on Linux. If you can get it working before I do, please submit a pull request! The branch windows-debugging/build-dll is where I'll be trying to get it working, if you wanna take a crack at it yourself.

Nostalgia uses CMake to generate the build system but don't worry, this section was written with the assumption that you know next to nothing about CMake. If you do, however, know next to something about CMake, then the only thing you really need to know is that I highly recommend usin the presets located in CMakePresets.json. Up to you, though. Oh, and BUILD_SHARED_LIBS is how I differentiate between building the shared and static versions of the library; you can't build both at the same time, sorry.

One last thing to note: on Linux, you'll need to install directx-shader-compiler for Jolt to compile. However, at least on Arch and as of the time of writing, you may run into a seg-fault when compiling. If this happens, you'll need to build directx-shader-compiler from its git repo (or use yay -S directx-shader-compiler-git on Arch). You could also try setting the cmake variable JPH_USE_DXC to OFF and re-generating the build files, as this should force Jolt to use fxc instead of dxc.

Configuring the Build System

Configuring Nostalgia with the CMake GUI is exceptionally easy to do; just set the source directory to the repository (e.g: where CMakeLists.txt is located) and select your preset from the 'presets' dropdown. After that, you'll notice a build directory will be chosen for you; this is intentional and should not be changed (you can if you want to, but the .gitignore file won't ignore it so be mindful). After pressing 'configure' once, a lot of options will pop up; most of these are from the included libraries that Nostalgia depends on and shouldn't be configured (they'll be overridden internally, anyways). Currently, there aren't any options to set that aren't set by the presets (e.g: static/dynamic library, debug/release version); if I add any in the future, I'll also try to hide the thirdparty options and write up some documentation for them. If you want to generate a compile_commands.json file, add a boolean variable named CMAKE_EXPORT_COMPILE_COMMANDS and enable it (e.g: set it to 'ON'). Once you've pressed 'configure' twice and all the entries are no longer red, press 'generate' and wait for it to finish. Now, your build directory is prepared and you're ready to build and install Nostalgia (as well as the editor/testing app). Oh, and in case you didn't know: if you wanna set the compiler (say, to 'clang++'), you'll want to add/set the variable CMAKE_CXX_COMPILER to your compiler of choice.

If you're using CMake on the command-line, just pick your preset via --preset <preset> and set your extra variables with -D<variable>=<value>. If you're generating 'compile_commands.json' and you want the fixed version of the file, you'll need to run this command twice.

Actually Building Nostalgia

Actually building Nostalgia on Linux is pretty simple; after you've configured the build system using CMake, navigate to the repository in a terminal and run the command cmake --build <build_directory>. For example: to build the debug linux version (either static or dynamic) you would run cmake --build ./Linux_Debug (unless you manually specified a different build directory). If you wish to install Nostalgia (and its headers) after building it, run cmake --install <build_directory> to use the default installation location (typically /usr/local/lib) or cmake --install <build_directory> --prefix <output_location> to customize the installation location.

Building Nostalgia on Windows is a little less and a little more complicated. The initial process is very similar to Linux; use CMake to configure and generate the Visual Studio solution & project files. Then, open the solution file in Visual Studio 18. Nostalgia requires 'ClangCL' to be installed; to install clang, install the 'C++ Clang Compiler for Windows' and 'MSBuild support for LLVM (clang-cl) toolset' components via the Visual Studio updater. Once you have all of that, all you have to do is open and build the solution to get your files. Oh, and just a heads up if you didn't already know: you can choose to build either the 'Debug' or 'Release' versions via a dropdown in Visual Studio and it tends to default to 'Debug', so make sure to double check that you're building the version you want. To install the library, that's up to you; Windows doesn't have a standard way of doing this, especially for static libraries. In order to generate the header files, you'll need to manually build the INSTALL target/project; this will generate the proper "Nostalgia/" folder inside of your build directory, in a folder called "NostalgiaHeaderFiles". You can then move "Nostalgia/" to wherever you need it in whatever project you're working on.

Using Nostalgia

First things first, Nostalgia uses the Jolt physics engine and the task of fully abstracting Jolt into my own highly detailed physics implementation is... daunting to say the least. This means that I've exposed a lot of Jolt's headers in my own header files, requiring you to also have those headers installed. However, you don't need to install them yourself if you don't want to, as I've proved the NOSTALGIA_INCLUDE_JOLT_HEADERS cmake option; enabling this option (which is enabled by default) will include 'Nostalgia/thirdparty/Jolt/' when installing Nostalgia's header files via cmake --install <build_directory>. This also applies to GLM and the provided NOSTALGIA_INCLUDE_GLM_HEADERS option. When including Nostalgia headers, you'll usually need to have <Nostalgia/Nostalgia.hpp> included due to it being the library's pre-compiled header (similarly to Jolt's <Jolt/Jolt.h> header). If you're using a pre-compiled header, it'd speed up compilation a lot (and save your sanity) if you add <Nostalgia/Nostalgia.hpp> to your pch. Finally, if you want a quick and easy GUI, check out the editor/testing app as it demonstrates how to implement Nostalgia's UI interface/solution framework. Specifically, Editor/gui/imgui_implementor.cpp (and its accompanied header) can be copy-pasted into your own project for a quick and dirty implementation of ImGui into Nostalgia. The editor/testing app (located in Editor/) is effectively a 'Hello World' program and a great tool for showcasing how to build an app/game using the engine.