texture.hpp
1 2 3 4 5 6 7 8 9 10 | #pragma once #include <planet/sdl/ttf.hpp> #include <planet/vk/colour.hpp> #include <planet/vk/forward.hpp> #include <planet/vk/texture.hpp> namespace planet::vk::sdl { |
Convert a vk::colour
to a SDL_Color
14 15 16 17 18 19 | inline SDL_Color to_sdl_color(vk::colour const &c) noexcept { auto const convert = [](float const v) { return static_cast<std::uint8_t>(v * 255.0f); }; return {convert(c.r), convert(c.g), convert(c.b), convert(c.a)}; } |
Create a Vulkan texture from an SDL surface
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | texture create_texture_with_mip_levels( device_memory_allocator &image, command_pool &, planet::sdl::surface const &); texture create_texture_with_mip_levels( device_memory_allocator &staging, device_memory_allocator &image, command_pool &, planet::sdl::surface const &); texture create_texture_without_mip_levels( device_memory_allocator &staging, device_memory_allocator &image, command_pool &, planet::sdl::surface const &); texture create_texture_without_mip_levels( device_memory_allocator &image, command_pool &, planet::sdl::surface const &); |
Render text and turn it into a Vulkan texture
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | inline texture render(device_memory_allocator &staging, device_memory_allocator &image, command_pool &cp, planet::sdl::font const &f, char const *t, vk::colour const &col = vk::colour::white) { return create_texture_without_mip_levels( staging, image, cp, f.render(t, to_sdl_color(col))); } inline texture render(device_memory_allocator &image, command_pool &cp, planet::sdl::font const &f, char const *t, vk::colour const &col = vk::colour::white) { return create_texture_without_mip_levels( image, cp, f.render(t, to_sdl_color(col))); } } |