# HG changeset patch # User Sam # Date 1677603666 -25200 # Node ID 8011e4d6372dabd5d1b65489fc973a5d103ab8c2 # Parent f036546f5ea24f5380062ee568d4e54f7d84508d add: consistent way to define platform-specific code diff -r f036546f5ea2 -r 8011e4d6372d README.md --- a/README.md Tue Feb 28 23:51:07 2023 +0700 +++ b/README.md Wed Mar 01 00:01:06 2023 +0700 @@ -4,32 +4,24 @@ Hi there This is a very simplistic little game engine, mainly trying to wrap around vulkan and the operating system's windowing, input and audio system. -This is using the last programming language you will ever need, [Nim](https://nim-lang.org/) +I am using the last programming language you will ever need, [Nim](https://nim-lang.org/) Building -------- -Run ```nim help``` to see a list of available build commands. - -It is required to download the glslangValidator binary into the ```examples/``` directory in order to be able to build. -There is a nim command for this that works on linux. - -Compilation on Windows ----------------------- +Requires Nim to be installed and ```glslangValidator``` to be downloaded to the +directory of the main compilation file (e.g. into ```examples/``` in order to +compile the examples). It can be downloaded at +https://github.com/KhronosGroup/glslang/releases/. -Requires a Windows SDK to be installed (e.g. via Visual Studio Build Tools). -Also, using Nim on Windows with mingw seems to be way faster than with vcc/lc. -For compilation with vcc/ls, install additionaly (with Visual Studio Build Tools): -- Windows Universal C Runtime (some important files) -- Windows CRT SDK (some important header files) -- Some version of MSVC (the compiler) - -glslangValidator cannot yet be downloaded automatically on windows, check config.nim for instructions. +Run ```nim help``` to see a list of available build commands. Roadmap ------- -Still tons to do, but it feels like the worst things (except audio maybe?) are over the hill. +Still tons to do. Making render pipeline and scenegraph somewhat compatible +seems like it will require quite a bit more of work. Also, audio might require +quite a bit of work, no experience there. Rendering: @@ -41,7 +33,7 @@ - [ ] Depth buffering - [ ] Mipmaps - [ ] Multisampling -- [~] Instanced drawing (currently can use instance attributes, but we only support a single instance per mesh) +- [~] Instanced drawing (currently can use instance attributes, but we only support a single instance per draw call) - [ ] Fullscreen mode + switch between modes - [x] Fixed framerate - [ ] Allow multipel Uniform blocks @@ -52,7 +44,7 @@ Asset handling: - [ ] Mesh files (Wavefront OBJ, MTL) (use something from sketchfab for testing, https://sketchfab.com/) - [ ] Image files (BMP RGB + BMP Graysscale for transparency) -- [ ] Audio files (WAV) +- [ ] Audio files (AU) Quality improvments: @@ -65,8 +57,7 @@ - [x] Win32 - [ ] Config files ala \*.ini files (use std/parsecfg) - [ ] Input-mapping configuration -- [ ] Audio (Alsa, Windows Waveform API?) -- [ ] Game controller input handling +- [ ] Audio playing (Alsa, Windows Waveform API?) Advanced features: - [ ] Text rendering @@ -74,3 +65,4 @@ - [ ] Sprite system - [ ] Particle system - [ ] Query and display rendering information from Vulkan +- [ ] Game controller input handling diff -r f036546f5ea2 -r 8011e4d6372d src/semicongine/platform/linux/vulkanExtensions.nim --- a/src/semicongine/platform/linux/vulkanExtensions.nim Tue Feb 28 23:51:07 2023 +0700 +++ b/src/semicongine/platform/linux/vulkanExtensions.nim Wed Mar 01 00:01:06 2023 +0700 @@ -1,1 +1,1 @@ -const REQUIRED_PLATFORM_EXTENSIONS* = ["VK_KHR_xlib_surface"] +const REQUIRED_PLATFORM_EXTENSIONS* = @["VK_KHR_xlib_surface"] diff -r f036546f5ea2 -r 8011e4d6372d src/semicongine/platform/vulkanExtensions.nim --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/semicongine/platform/vulkanExtensions.nim Wed Mar 01 00:01:06 2023 +0700 @@ -0,0 +1,6 @@ +when defined(linux): + include ./linux/vulkanExtensions +elif defined(windows): + include ./windows/vulkanExtensions + +export vulkanExtensions diff -r f036546f5ea2 -r 8011e4d6372d src/semicongine/platform/windows/vulkanExtensions.nim --- a/src/semicongine/platform/windows/vulkanExtensions.nim Tue Feb 28 23:51:07 2023 +0700 +++ b/src/semicongine/platform/windows/vulkanExtensions.nim Wed Mar 01 00:01:06 2023 +0700 @@ -1,1 +1,1 @@ -const REQUIRED_PLATFORM_EXTENSIONS* = @["VK_KHR_win32_surface".cstring] +const REQUIRED_PLATFORM_EXTENSIONS* = @["VK_KHR_win32_surface"] diff -r f036546f5ea2 -r 8011e4d6372d src/semicongine/vulkan.nim --- a/src/semicongine/vulkan.nim Tue Feb 28 23:51:07 2023 +0700 +++ b/src/semicongine/vulkan.nim Wed Mar 01 00:01:06 2023 +0700 @@ -15,5 +15,3 @@ import ./vulkan/memory export memory - - diff -r f036546f5ea2 -r 8011e4d6372d src/semicongine/vulkan/instance.nim --- a/src/semicongine/vulkan/instance.nim Tue Feb 28 23:51:07 2023 +0700 +++ b/src/semicongine/vulkan/instance.nim Wed Mar 01 00:01:06 2023 +0700 @@ -3,10 +3,7 @@ import ./api import ./utils -when defined(linux): - include ../platform/linux/vulkanExtensions -elif defined(windows): - include ../platform/windows/vulkanExtensions +import ../platform/vulkanExtensions type Instance* = object @@ -47,9 +44,11 @@ engine = "defaultEngine", ): Instance = - let requiredExtensions = @REQUIRED_PLATFORM_EXTENSIONS & @["VK_KHR_surface"] & instanceExtensions - for i in layers: assert i in getLayers() - for i in requiredExtensions: assert i in getInstanceExtensions() + let requiredExtensions = REQUIRED_PLATFORM_EXTENSIONS & @["VK_KHR_surface"] & instanceExtensions + for i in layers: + assert i in getLayers(), $i + for i in requiredExtensions: + assert i in getInstanceExtensions(), $i var layersC = allocCStringArray(layers) instanceExtensionsC = allocCStringArray(requiredExtensions)