This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto static default_validation_layers() -> std::vector<char const*> { | |
| return std::vector<char const*> { | |
| #if !defined(NDEBUG) | |
| "VK_LAYER_KHRONOS_validation" | |
| #endif | |
| }; | |
| } | |
| auto static default_instance_extensions() -> std::vector<char const*> { | |
| return std::vector<char const*> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module GTK | |
| class OpenEntity | |
| def move_to(target, duration, easing, &block) | |
| Fiber.new do | |
| start_time = $gtk.args.state.tick_count | |
| until self.x == target[:x] && self.y == target[:y] | |
| t = $gtk.args.easing.ease(start_time, $gtk.args.state.tick_count, duration, easing) | |
| self.x += t * (target[:x] - self.x) | |
| self.y += t * (target[:y] - self.y) | |
| Fiber.yield |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <vulkan/vulkan.hpp> | |
| #include <shaderc/shaderc.hpp> | |
| #include <GLFW/glfw3.h> | |
| auto constexpr window_title {"Vulkan Prototype"}; | |
| auto constexpr window_width {1280}; | |
| auto constexpr window_height {720}; | |
| auto static error_callback(int error, char const* description) -> void { printf("glfw error: %s", description); } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```bash | |
| # Create (VM has 128G disk) | |
| cgdisk /dev/vda | |
| EFI, 512M as ef00 | |
| Root, 115G as 8300 | |
| remaining as 8200 (should be around 1.5x larger than RAM for resume) | |
| # Format | |
| mkfs.vfat -F32 /dev/vda1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Renderer | |
| attr_accessor(:background, :foreground, :overlay) | |
| def initialize | |
| @background = [] | |
| @foreground = [] | |
| @overlay = [] | |
| end | |
| def draw_override(ffi_draw) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto create_shader(vk::raii::Device const& device, std::string const& source) { | |
| auto static compiler = shaderc::Compiler{}; | |
| auto result{compiler.CompileGlslToSpv(source, shaderc_glsl_infer_from_source, "", {})}; | |
| if (result.GetCompilationStatus()) throw std::runtime_error(result.GetErrorMessage()); | |
| auto code = std::vector<std::uint32_t>(result.begin(), result.end()); | |
| return std::make_unique<vk::raii::ShaderModule>(device, vk::ShaderModuleCreateInfo{{}, code}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define LOG_INFO(fmt, ...) do { SDL_LogInfo (SDL_LOG_CATEGORY_APPLICATION, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0) | |
| #define LOG_WARN(fmt, ...) do { SDL_LogWarn (SDL_LOG_CATEGORY_APPLICATION, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0) | |
| #define LOG_ERROR(fmt, ...) do { char message[120]; snprintf(message, 120, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", message, nullptr) < 0) SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0) | |
| #define LOG_VERBOSE(fmt, ...) do { SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); } while (0) | |
| auto static default_debug_utils_messenger() -> vk::DebugUtilsMessengerCreateInfoEXT{ | |
| return vk::DebugUtilsMessengerCreateInfoEXT{ | |
| vk::DebugUtilsMessengerCreateFlagsEXT{}, | |
| vk::Deb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| auto static create_shader(vk::raii::Device const& device, vk::ArrayProxy<char const* const> shader_source, vk::ShaderStageFlagBits const& shader_stage) -> vk::raii::ShaderModule { | |
| auto const& stage = [&shader_stage]() { | |
| switch (shader_stage) { | |
| default: throw std::runtime_error("Unknown shader stage"); | |
| case vk::ShaderStageFlagBits::eVertex: return EShLangVertex; | |
| case vk::ShaderStageFlagBits::eCompute: return EShLangCompute; | |
| case vk::ShaderStageFlagBits::eFragment: return EShLangFragment; | |
| } | |
| }(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cmake_minimum_required(VERSION 3.21) | |
| include(CMakeRC.cmake) | |
| project(test) | |
| file(GLOB_RECURSE ENGINE_SOURCES "${CMAKE_SOURCE_DIR}/engine/*.cpp") | |
| file(GLOB_RECURSE GAME_SOURCES "${CMAKE_SOURCE_DIR}/game/*.cpp") | |
| # Resource compiler | |
| file(GLOB_RECURSE ASSETS "${CMAKE_SOURCE_DIR}/assets/*.*") | |
| cmrc_add_resource_library(game-resources ALIAS game::resources NAMESPACE resources ${ASSETS}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Vec2Extensions | |
| def + other | |
| return super other if other.is_a? Vec2 | |
| vec2 x + other, y + other if other.is_a? Numeric | |
| end | |
| def - other | |
| return vec2 x - other.x, y - other.y if other.is_a? Vec2 | |
| vec2 x - other, y - other if other.is_a? Numeric | |
| end |
OlderNewer