This file contains 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 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 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
# This is an experiment with using bit fields to store AABB values | |
# It is currently a little slower in general than the array based approach but is more stable | |
# It could be a good fit if doing a lot of position comparisons or the other version is causing too much stutter | |
# max value for Fixnum is 2**62-1 so using a 60-bit field | |
AABB_MASK = 0b000000000000000000000000000000000000000000000000000000000000 | |
MIN_X_MASK = 0b000000000000000000000000000000000000000000000111111111111111 # 0x7FFF | |
MIN_X_SHIFT = 0 | |
MIN_Y_MASK = 0b000000000000000000000000000000111111111111111000000000000000 # 0x3FFF8000 | |
MIN_Y_SHIFT = 15 |
This file contains 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 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 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 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 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 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 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 { \ | |
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s:%d \n\t%s()\n\t\t" fmt, __FILE__, __LINE__, __func__, __VA_ARGS__); \ |
OlderNewer