Initial commit with the chapter-0 code working.
This commit is contained in:
commit
7298568818
19 changed files with 8380 additions and 0 deletions
31
.gitignore
vendored
Normal file
31
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
# ---> Vim
|
||||
# Swap
|
||||
[._]*.s[a-v][a-z]
|
||||
!*.svg # comment out if you don't need vector files
|
||||
[._]*.sw[a-p]
|
||||
[._]s[a-rt-v][a-z]
|
||||
[._]ss[a-gi-z]
|
||||
[._]sw[a-p]
|
||||
|
||||
# Session
|
||||
Session.vim
|
||||
Sessionx.vim
|
||||
|
||||
# Temporary
|
||||
.netrwhist
|
||||
*~
|
||||
# Auto-generated tag files
|
||||
tags
|
||||
# Persistent undo
|
||||
[._]*.un~
|
||||
|
||||
subprojects
|
||||
builddir
|
||||
ttassets
|
||||
backup
|
||||
*.exe
|
||||
*.dll
|
||||
*.world
|
||||
coverage
|
||||
coverage/*
|
||||
.venv
|
||||
1
.vimrc_proj
Normal file
1
.vimrc_proj
Normal file
|
|
@ -0,0 +1 @@
|
|||
set makeprg=make\ -f\ ../Makefile\ build
|
||||
53
Makefile
Normal file
53
Makefile
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
all: build test
|
||||
|
||||
reset:
|
||||
ifeq '$(OS)' 'Windows_NT'
|
||||
powershell -executionpolicy bypass .\scripts\reset_build.ps1
|
||||
else
|
||||
sh -x ./scripts/reset_build.sh
|
||||
endif
|
||||
|
||||
%.cpp : %.rl
|
||||
ragel -I $(ROOT_DIR) -G1 -o $@ $<
|
||||
|
||||
%.dot: %.rl
|
||||
ragel -Vp -I $(ROOT_DIR) -o $@ $<
|
||||
|
||||
%.png: %.dot
|
||||
dot -Tpng $< -o $@
|
||||
|
||||
build:
|
||||
meson compile -j 10 -C $(ROOT_DIR)/builddir
|
||||
|
||||
release_build:
|
||||
meson --wipe builddir -Db_ndebug=true --buildtype release
|
||||
meson compile -j 10 -C builddir
|
||||
|
||||
debug_build:
|
||||
meson setup --wipe builddir -Db_ndebug=true --buildtype debugoptimized
|
||||
meson compile -j 10 -C builddir
|
||||
|
||||
run: build
|
||||
ifeq '$(OS)' 'Windows_NT'
|
||||
powershell "cp ./builddir/hellovulk.exe ."
|
||||
./hellovulk
|
||||
else
|
||||
./builddir/hellovulk
|
||||
endif
|
||||
|
||||
debug: build
|
||||
gdb --nx -x .gdbinit --ex run --args builddir/hellovulk
|
||||
|
||||
debug_run: build
|
||||
gdb --nx -x .gdbinit --batch --ex run --ex bt --ex q --args builddir/hellovulk
|
||||
|
||||
clean:
|
||||
meson compile --clean -C builddir
|
||||
|
||||
debug_test: build
|
||||
gdb --nx -x .gdbinit --ex run --ex bt --ex q --args builddir/runtests -e "[pathing]"
|
||||
|
||||
money:
|
||||
scc --exclude-dir subprojects
|
||||
14
main.cpp
Normal file
14
main.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include <vk_engine.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
VulkanEngine engine;
|
||||
|
||||
engine.init();
|
||||
|
||||
engine.run();
|
||||
|
||||
engine.cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
86
meson.build
Normal file
86
meson.build
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
# clang might need _LIBCPP_ENABLE_CXX26_REMOVED_CODECVT
|
||||
|
||||
project('hellovulk', 'cpp',
|
||||
version: '0.1.0',
|
||||
default_options: [
|
||||
'cpp_std=c++23',
|
||||
'cpp_args=-D_GLIBCXX_DEBUG=1 -D_GLIBCXX_DEBUG_PEDANTIC=1',
|
||||
])
|
||||
|
||||
# use this for common options only for our executables
|
||||
cpp_args=[]
|
||||
link_args=[]
|
||||
# these are passed as override_defaults
|
||||
exe_defaults = [ 'warning_level=2' ]
|
||||
|
||||
cc = meson.get_compiler('cpp')
|
||||
dependencies = []
|
||||
|
||||
if build_machine.system() == 'windows'
|
||||
add_global_link_arguments(
|
||||
'-static-libgcc',
|
||||
'-static-libstdc++',
|
||||
'-static',
|
||||
language: 'cpp',
|
||||
)
|
||||
|
||||
sdl2_main = subproject('sld2').get_variable('sdl2_main')
|
||||
opengl32 = cc.find_library('opengl32', required: true)
|
||||
winmm = cc.find_library('winmm', required: true)
|
||||
gdi32 = cc.find_library('gdi32', required: true)
|
||||
|
||||
dependencies += [
|
||||
opengl32, winmm, gdi32, sdl2_main
|
||||
]
|
||||
exe_defaults += ['werror=true']
|
||||
|
||||
elif build_machine.system() == 'darwin'
|
||||
add_global_link_arguments(
|
||||
language: 'cpp',
|
||||
)
|
||||
|
||||
opengl = dependency('OpenGL')
|
||||
corefoundation = dependency('CoreFoundation')
|
||||
carbon = dependency('Carbon')
|
||||
cocoa = dependency('Cocoa')
|
||||
iokit = dependency('IOKit')
|
||||
corevideo = dependency('CoreVideo')
|
||||
|
||||
link_args += ['-ObjC']
|
||||
exe_defaults += ['werror=false']
|
||||
dependencies += [
|
||||
opengl, corefoundation, carbon, cocoa, iokit, corevideo
|
||||
]
|
||||
endif
|
||||
|
||||
vma = subproject('vulkan-memory-allocator').get_variable('vma_allocator_dep')
|
||||
vulkanheaders = subproject('vulkan-headers').get_variable('vulkan_headers_dep')
|
||||
|
||||
vkbootstrap = subproject('vk-bootstrap').get_variable('vk_bootstrap_dep')
|
||||
glm = subproject('glm').get_variable('glm_dep')
|
||||
imgui = subproject('imgui').get_variable('imgui_dep')
|
||||
sdl2 = subproject('sdl2').get_variable('sdl2_dep')
|
||||
|
||||
dependencies += [
|
||||
vma,
|
||||
vulkanheaders,
|
||||
vkbootstrap,
|
||||
glm,
|
||||
imgui,
|
||||
sdl2,
|
||||
]
|
||||
|
||||
sources = [
|
||||
'vk_initializers.cpp',
|
||||
'vk_engine.cpp',
|
||||
'main.cpp',
|
||||
]
|
||||
|
||||
tests = [
|
||||
]
|
||||
|
||||
executable('hellovulk', sources,
|
||||
cpp_args: cpp_args,
|
||||
link_args: link_args,
|
||||
override_options: exe_defaults,
|
||||
dependencies: dependencies)
|
||||
10
scripts/reset_build.sh
Normal file
10
scripts/reset_build.sh
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
mv -f ./subprojects/packagecache .
|
||||
rm -rf subprojects builddir
|
||||
mkdir subprojects
|
||||
mv -f packagecache ./subprojects/ && true
|
||||
mkdir builddir
|
||||
cp wraps/*.wrap subprojects/
|
||||
# on OSX you can't do this with static
|
||||
meson setup --default-library=static --prefer-static builddir
|
||||
7988
stb_image.h
Normal file
7988
stb_image.h
Normal file
File diff suppressed because it is too large
Load diff
60
vk_engine.cpp
Normal file
60
vk_engine.cpp
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
|
||||
#include "vk_engine.h"
|
||||
#include <print>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_vulkan.h>
|
||||
|
||||
#include <vk_types.h>
|
||||
#include <vk_initializers.h>
|
||||
|
||||
void VulkanEngine::init()
|
||||
{
|
||||
// We initialize SDL and create a window with it.
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
SDL_WindowFlags window_flags = (SDL_WindowFlags)(SDL_WINDOW_VULKAN);
|
||||
|
||||
_window = SDL_CreateWindow(
|
||||
"Vulkan Engine",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
int(_windowExtent.width),
|
||||
int(_windowExtent.height),
|
||||
window_flags
|
||||
);
|
||||
|
||||
//everything went fine
|
||||
_isInitialized = true;
|
||||
}
|
||||
void VulkanEngine::cleanup()
|
||||
{
|
||||
if (_isInitialized) {
|
||||
SDL_DestroyWindow(_window);
|
||||
}
|
||||
}
|
||||
|
||||
void VulkanEngine::draw()
|
||||
{
|
||||
//nothing yet
|
||||
}
|
||||
|
||||
void VulkanEngine::run()
|
||||
{
|
||||
SDL_Event e;
|
||||
bool bQuit = false;
|
||||
|
||||
//main loop
|
||||
while (!bQuit)
|
||||
{
|
||||
//Handle events on queue
|
||||
while (SDL_PollEvent(&e) != 0)
|
||||
{
|
||||
//close the window when user alt-f4s or clicks the X button
|
||||
if (e.type == SDL_QUIT) bQuit = true;
|
||||
}
|
||||
|
||||
draw();
|
||||
}
|
||||
}
|
||||
|
||||
29
vk_engine.h
Normal file
29
vk_engine.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// vulkan_guide.h : Include file for standard system include files,
|
||||
// or project specific include files.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vk_types.h>
|
||||
|
||||
class VulkanEngine {
|
||||
public:
|
||||
|
||||
bool _isInitialized{ false };
|
||||
int _frameNumber {0};
|
||||
|
||||
VkExtent2D _windowExtent{ 1700 , 900 };
|
||||
|
||||
struct SDL_Window* _window{ nullptr };
|
||||
|
||||
//initializes everything in the engine
|
||||
void init();
|
||||
|
||||
//shuts down the engine
|
||||
void cleanup();
|
||||
|
||||
//draw loop
|
||||
void draw();
|
||||
|
||||
//run main loop
|
||||
void run();
|
||||
};
|
||||
1
vk_initializers.cpp
Normal file
1
vk_initializers.cpp
Normal file
|
|
@ -0,0 +1 @@
|
|||
#include <vk_initializers.h>
|
||||
12
vk_initializers.h
Normal file
12
vk_initializers.h
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// vulkan_guide.h : Include file for standard system include files,
|
||||
// or project specific include files.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vk_types.h>
|
||||
|
||||
namespace vkinit {
|
||||
|
||||
//vulkan init code goes here
|
||||
}
|
||||
|
||||
8
vk_types.h
Normal file
8
vk_types.h
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// vulkan_guide.h : Include file for standard system include files,
|
||||
// or project specific include files.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
//we will add our main reusable types here
|
||||
11
wraps/catch2.wrap
Normal file
11
wraps/catch2.wrap
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[wrap-file]
|
||||
directory = Catch2-3.11.0
|
||||
source_url = https://github.com/catchorg/Catch2/archive/v3.11.0.tar.gz
|
||||
source_filename = Catch2-3.11.0.tar.gz
|
||||
source_hash = 82fa1cb59dc28bab220935923f7469b997b259eb192fb9355db62da03c2a3137
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.11.0-1/Catch2-3.11.0.tar.gz
|
||||
wrapdb_version = 3.11.0-1
|
||||
|
||||
[provide]
|
||||
catch2 = catch2_dep
|
||||
catch2-with-main = catch2_with_main_dep
|
||||
13
wraps/glm.wrap
Normal file
13
wraps/glm.wrap
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[wrap-file]
|
||||
directory = glm-1.0.1
|
||||
source_url = https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
||||
source_filename = glm-1.0.1.tar.gz
|
||||
source_hash = 9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c
|
||||
patch_filename = glm_1.0.1-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glm_1.0.1-1/get_patch
|
||||
patch_hash = 25679275e26bc4c36bb617d1b4a52197039402af828d2a4bf67b3c0260a5df6a
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/glm_1.0.1-1/glm-1.0.1.tar.gz
|
||||
wrapdb_version = 1.0.1-1
|
||||
|
||||
[provide]
|
||||
glm = glm_dep
|
||||
13
wraps/imgui.wrap
Normal file
13
wraps/imgui.wrap
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[wrap-file]
|
||||
directory = imgui-1.91.6
|
||||
source_url = https://github.com/ocornut/imgui/archive/refs/tags/v1.91.6.tar.gz
|
||||
source_filename = imgui-1.91.6.tar.gz
|
||||
source_hash = c5fbc5dcab1d46064001c3b84d7a88812985cde7e0e9ced03f5677bec1ba502a
|
||||
patch_filename = imgui_1.91.6-3_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/imgui_1.91.6-3/get_patch
|
||||
patch_hash = 2f7977114ba07d06559aaf8890a92a4ebd25186592d4447954605aaf2244634d
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/imgui_1.91.6-3/imgui-1.91.6.tar.gz
|
||||
wrapdb_version = 1.91.6-3
|
||||
|
||||
[provide]
|
||||
imgui = imgui_dep
|
||||
15
wraps/sdl2.wrap
Normal file
15
wraps/sdl2.wrap
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[wrap-file]
|
||||
directory = SDL2-2.32.8
|
||||
source_url = https://github.com/libsdl-org/SDL/releases/download/release-2.32.8/SDL2-2.32.8.tar.gz
|
||||
source_filename = SDL2-2.32.8.tar.gz
|
||||
source_hash = 0ca83e9c9b31e18288c7ec811108e58bac1f1bb5ec6577ad386830eac51c787e
|
||||
patch_filename = sdl2_2.32.8-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/sdl2_2.32.8-1/get_patch
|
||||
patch_hash = 5df17ea39ca418826db20e96bd821fa52b5718dac64b6225119fb6588c2744f0
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/sdl2_2.32.8-1/SDL2-2.32.8.tar.gz
|
||||
wrapdb_version = 2.32.8-1
|
||||
|
||||
[provide]
|
||||
sdl2 = sdl2_dep
|
||||
sdl2main = sdl2main_dep
|
||||
sdl2_test = sdl2_test_dep
|
||||
9
wraps/vk-bootstrap.wrap
Normal file
9
wraps/vk-bootstrap.wrap
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[wrap-git]
|
||||
directory=vk-bootstrap-1.4.332
|
||||
url=https://github.com/charles-lunarg/vk-bootstrap.git
|
||||
revision=HEAD
|
||||
depth=1
|
||||
method=cmake
|
||||
|
||||
[provide]
|
||||
vkbootstrap = vkbootstrap_dep
|
||||
13
wraps/vulkan-headers.wrap
Normal file
13
wraps/vulkan-headers.wrap
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[wrap-file]
|
||||
directory = Vulkan-Headers-1.3.283
|
||||
source_url = https://github.com/KhronosGroup/Vulkan-Headers/archive/v1.3.283.tar.gz
|
||||
source_filename = vulkan-headers-1.3.283.tar.gz
|
||||
source_hash = a76ff77815012c76abc9811215c2167128a73a697bcc23948e858d1f7dd54a85
|
||||
patch_filename = vulkan-headers_1.3.283-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/vulkan-headers_1.3.283-1/get_patch
|
||||
patch_hash = 00e30d35117ae90a19b5b8878746fceaf31b41778b817ca9e6b3ae6063be8233
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/vulkan-headers_1.3.283-1/vulkan-headers-1.3.283.tar.gz
|
||||
wrapdb_version = 1.3.283-1
|
||||
|
||||
[provide]
|
||||
vulkanheaders = vulkan_headers_dep
|
||||
13
wraps/vulkan-memory-allocator.wrap
Normal file
13
wraps/vulkan-memory-allocator.wrap
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[wrap-file]
|
||||
directory = VulkanMemoryAllocator-3.1.0
|
||||
source_url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator/archive/refs/tags/v3.1.0.tar.gz
|
||||
source_filename = VulkanMemoryAllocator-3.1.0.tar.gz
|
||||
source_hash = ae134ecc37c55634f108e926f85d5d887b670360e77cd107affaf3a9539595f2
|
||||
patch_filename = vulkan-memory-allocator_3.1.0-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/vulkan-memory-allocator_3.1.0-1/get_patch
|
||||
patch_hash = d62a983856146f4529c5c5a46b13c0451a4f7e02d0966606dcd054a204c5fd80
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/vulkan-memory-allocator_3.1.0-1/VulkanMemoryAllocator-3.1.0.tar.gz
|
||||
wrapdb_version = 3.1.0-1
|
||||
|
||||
[provide]
|
||||
vulkan-memory-allocator = vma_allocator_dep
|
||||
Loading…
Add table
Add a link
Reference in a new issue