Merge branch 'master' into using_std_fs_path
This commit is contained in:
@@ -223,7 +223,7 @@ namespace OpenVulkano::AR
|
|||||||
|
|
||||||
virtual void LockExposureTime(bool locked) {};
|
virtual void LockExposureTime(bool locked) {};
|
||||||
|
|
||||||
virtual void LockWhitebalance(bool locked) {};
|
virtual void LockWhiteBalance(bool locked) {};
|
||||||
|
|
||||||
virtual void SetFlashlightOn(bool on) {};
|
virtual void SetFlashlightOn(bool on) {};
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace OpenVulkano::AR::ArKit
|
|||||||
void SetRenderer(IRenderer* renderer) override;
|
void SetRenderer(IRenderer* renderer) override;
|
||||||
|
|
||||||
void LockExposureTime(bool locked) override;
|
void LockExposureTime(bool locked) override;
|
||||||
void LockWhitebalance(bool locked) override;
|
void LockWhiteBalance(bool locked) override;
|
||||||
void SetFlashlightOn(bool on) override;
|
void SetFlashlightOn(bool on) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Makre usre the Molten include is first!
|
// Make sure the Molten include is first!
|
||||||
#include <MoltenVK/mvk_vulkan.h>
|
#include <MoltenVK/mvk_vulkan.h>
|
||||||
#include <vulkan/vulkan_metal.h>
|
#include <vulkan/vulkan_metal.h>
|
||||||
|
|
||||||
@@ -223,7 +223,7 @@ namespace OpenVulkano::AR::ArKit
|
|||||||
[dev setExposureMode: locked ? AVCaptureExposureModeLocked : AVCaptureExposureModeContinuousAutoExposure];
|
[dev setExposureMode: locked ? AVCaptureExposureModeLocked : AVCaptureExposureModeContinuousAutoExposure];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArSessionArKitInternal::LockWhitebalance(bool locked)
|
void ArSessionArKitInternal::LockWhiteBalance(bool locked)
|
||||||
{
|
{
|
||||||
AVCaptureDevice* dev = [ARWorldTrackingConfiguration configurableCaptureDeviceForPrimaryCamera];
|
AVCaptureDevice* dev = [ARWorldTrackingConfiguration configurableCaptureDeviceForPrimaryCamera];
|
||||||
if (!m_lockedConfiguration) m_lockedConfiguration |=[dev lockForConfiguration:nil];
|
if (!m_lockedConfiguration) m_lockedConfiguration |=[dev lockForConfiguration:nil];
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#define SPDLOG_DEBUG_ON
|
#define SPDLOG_DEBUG_ON
|
||||||
#define SPDLOG_TRACE_ON
|
#define SPDLOG_TRACE_ON
|
||||||
|
|
||||||
|
#include "Extensions/FmtFormatter.hpp"
|
||||||
#include <spdlog/spdlog.h>
|
#include <spdlog/spdlog.h>
|
||||||
|
|
||||||
namespace OpenVulkano
|
namespace OpenVulkano
|
||||||
|
|||||||
45
openVulkanoCpp/Extensions/FmtFormatter.hpp
Normal file
45
openVulkanoCpp/Extensions/FmtFormatter.hpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#if __has_include("fmt/format.h")
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#elif __has_include("spdlog/fmt/fmt.h")
|
||||||
|
#include <spdlog/fmt/fmt.h>
|
||||||
|
#else
|
||||||
|
#error "Failed to find fmt include"
|
||||||
|
#endif
|
||||||
|
#include "Math/ByteSize.hpp"
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
template<> struct fmt::formatter<OpenVulkano::ByteSize>
|
||||||
|
{
|
||||||
|
template<typename ParseContext> constexpr auto parse(ParseContext& ctx)
|
||||||
|
{
|
||||||
|
return ctx.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename FormatContext> auto format(const OpenVulkano::ByteSize& bs, FormatContext& ctx) const
|
||||||
|
{
|
||||||
|
return fmt::format_to(ctx.out(), "{}", bs.Format());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct fmt::formatter<std::filesystem::path> : fmt::formatter<std::string>
|
||||||
|
{
|
||||||
|
template<typename PATH = std::filesystem::path>
|
||||||
|
auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v<std::filesystem::path::value_type, char>
|
||||||
|
{
|
||||||
|
return formatter<std::string>::format(path.native(), ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename PATH = std::filesystem::path>
|
||||||
|
auto format(const std::filesystem::path& path, format_context& ctx) const requires std::is_same_v<std::filesystem::path::value_type, wchar_t>
|
||||||
|
{
|
||||||
|
return formatter<std::string>::format(path.string(), ctx);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,22 +11,13 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
|
||||||
#if __has_include("fmt/format.h")
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#elif __has_include("spdlog/fmt/fmt.h")
|
|
||||||
#include <spdlog/fmt/fmt.h>
|
|
||||||
#else
|
|
||||||
#warning "Failed to find fmt include"
|
|
||||||
#define OVKMBS_FMT_MISSING
|
|
||||||
#endif
|
|
||||||
#include <magic_enum.hpp>
|
#include <magic_enum.hpp>
|
||||||
|
|
||||||
namespace OpenVulkano
|
namespace OpenVulkano
|
||||||
{
|
{
|
||||||
namespace ByteSizeUnitHelper
|
namespace ByteSizeUnitHelper
|
||||||
{
|
{
|
||||||
constexpr std::array<uint64_t, 13> BuildFactors()
|
consteval std::array<uint64_t, 13> BuildFactors()
|
||||||
{
|
{
|
||||||
std::array<uint64_t, 13> factors = { 1 };
|
std::array<uint64_t, 13> factors = { 1 };
|
||||||
for(uint64_t j = 1, i = 10; i < 70; i += 10, j++)
|
for(uint64_t j = 1, i = 10; i < 70; i += 10, j++)
|
||||||
@@ -40,7 +31,7 @@ namespace OpenVulkano
|
|||||||
return factors;
|
return factors;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::array<double, 13> BuildDivisors()
|
consteval std::array<double, 13> BuildDivisors()
|
||||||
{
|
{
|
||||||
std::array<uint64_t, 13> factors = BuildFactors();
|
std::array<uint64_t, 13> factors = BuildFactors();
|
||||||
std::array<double, 13> divs{{1}};
|
std::array<double, 13> divs{{1}};
|
||||||
@@ -59,7 +50,7 @@ namespace OpenVulkano
|
|||||||
public:
|
public:
|
||||||
enum Unit : int { B = 0, kiB, MiB, GiB, TiB, PiB, EiB, kB, MB, GB, TB, PB, EB };
|
enum Unit : int { B = 0, kiB, MiB, GiB, TiB, PiB, EiB, kB, MB, GB, TB, PB, EB };
|
||||||
|
|
||||||
constexpr ByteSizeUnit(Unit unit) : unit(unit) {}
|
constexpr ByteSizeUnit(const Unit unit) : unit(unit) {}
|
||||||
|
|
||||||
[[nodiscard]] constexpr uint64_t GetFactor() const { return FACTORS[unit]; }
|
[[nodiscard]] constexpr uint64_t GetFactor() const { return FACTORS[unit]; }
|
||||||
|
|
||||||
@@ -97,10 +88,10 @@ namespace OpenVulkano
|
|||||||
uint64_t bytes;
|
uint64_t bytes;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr ByteSize(uint64_t size = 0) : bytes(size) {}
|
constexpr ByteSize(const uint64_t size = 0) : bytes(size) {}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
constexpr ByteSize(T size, ByteSizeUnit unit)
|
constexpr ByteSize(const T size, const ByteSizeUnit unit)
|
||||||
: bytes(size * unit.GetFactor()) {}
|
: bytes(size * unit.GetFactor()) {}
|
||||||
|
|
||||||
ByteSize(const std::string& str)
|
ByteSize(const std::string& str)
|
||||||
@@ -114,7 +105,7 @@ namespace OpenVulkano
|
|||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os) const { return FormatStream(os); }
|
std::ostream& operator<<(std::ostream& os) const { return FormatStream(os); }
|
||||||
|
|
||||||
std::ostream& FormatStream(std::ostream& oss, bool si = false) const
|
std::ostream& FormatStream(std::ostream& oss, const bool si = false) const
|
||||||
{
|
{
|
||||||
oss << std::setprecision(3);
|
oss << std::setprecision(3);
|
||||||
auto unit = ByteSizeUnit::GetClosestUnit(bytes, si);
|
auto unit = ByteSizeUnit::GetClosestUnit(bytes, si);
|
||||||
@@ -122,7 +113,7 @@ namespace OpenVulkano
|
|||||||
return oss;
|
return oss;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] std::string Format(bool si = false) const
|
[[nodiscard]] std::string Format(const bool si = false) const
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
FormatStream(oss, si);
|
FormatStream(oss, si);
|
||||||
@@ -145,44 +136,30 @@ namespace OpenVulkano
|
|||||||
ByteSize& operator -=(const ByteSize other) { bytes -= other.bytes; return *this; }
|
ByteSize& operator -=(const ByteSize other) { bytes -= other.bytes; return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
inline constexpr ByteSize operator"" _kiB(long double num) { return { num, ByteSizeUnit::kiB }; }
|
constexpr ByteSize operator"" _kiB(long double num) { return { num, ByteSizeUnit::kiB }; }
|
||||||
inline constexpr ByteSize operator"" _MiB(long double num) { return { num, ByteSizeUnit::MiB }; }
|
constexpr ByteSize operator"" _MiB(long double num) { return { num, ByteSizeUnit::MiB }; }
|
||||||
inline constexpr ByteSize operator"" _GiB(long double num) { return { num, ByteSizeUnit::GiB }; }
|
constexpr ByteSize operator"" _GiB(long double num) { return { num, ByteSizeUnit::GiB }; }
|
||||||
inline constexpr ByteSize operator"" _TiB(long double num) { return { num, ByteSizeUnit::TiB }; }
|
constexpr ByteSize operator"" _TiB(long double num) { return { num, ByteSizeUnit::TiB }; }
|
||||||
inline constexpr ByteSize operator"" _PiB(long double num) { return { num, ByteSizeUnit::PiB }; }
|
constexpr ByteSize operator"" _PiB(long double num) { return { num, ByteSizeUnit::PiB }; }
|
||||||
inline constexpr ByteSize operator"" _EiB(long double num) { return { num, ByteSizeUnit::EiB }; }
|
constexpr ByteSize operator"" _EiB(long double num) { return { num, ByteSizeUnit::EiB }; }
|
||||||
inline constexpr ByteSize operator"" _kB(long double num) { return { num, ByteSizeUnit::kB }; }
|
constexpr ByteSize operator"" _kB(long double num) { return { num, ByteSizeUnit::kB }; }
|
||||||
inline constexpr ByteSize operator"" _MB(long double num) { return { num, ByteSizeUnit::MB }; }
|
constexpr ByteSize operator"" _MB(long double num) { return { num, ByteSizeUnit::MB }; }
|
||||||
inline constexpr ByteSize operator"" _GB(long double num) { return { num, ByteSizeUnit::GB }; }
|
constexpr ByteSize operator"" _GB(long double num) { return { num, ByteSizeUnit::GB }; }
|
||||||
inline constexpr ByteSize operator"" _TB(long double num) { return { num, ByteSizeUnit::TB }; }
|
constexpr ByteSize operator"" _TB(long double num) { return { num, ByteSizeUnit::TB }; }
|
||||||
inline constexpr ByteSize operator"" _PB(long double num) { return { num, ByteSizeUnit::PB }; }
|
constexpr ByteSize operator"" _PB(long double num) { return { num, ByteSizeUnit::PB }; }
|
||||||
inline constexpr ByteSize operator"" _EB(long double num) { return { num, ByteSizeUnit::EB }; }
|
constexpr ByteSize operator"" _EB(long double num) { return { num, ByteSizeUnit::EB }; }
|
||||||
inline constexpr ByteSize operator"" _B(unsigned long long int num) { return { num }; }
|
constexpr ByteSize operator"" _B(unsigned long long int num) { return { num }; }
|
||||||
inline constexpr ByteSize operator"" _kiB(unsigned long long int num) { return { num << 10 }; }
|
constexpr ByteSize operator"" _kiB(unsigned long long int num) { return { num << 10 }; }
|
||||||
inline constexpr ByteSize operator"" _MiB(unsigned long long int num) { return { num << 20 }; }
|
constexpr ByteSize operator"" _MiB(unsigned long long int num) { return { num << 20 }; }
|
||||||
inline constexpr ByteSize operator"" _GiB(unsigned long long int num) { return { num << 30 }; }
|
constexpr ByteSize operator"" _GiB(unsigned long long int num) { return { num << 30 }; }
|
||||||
inline constexpr ByteSize operator"" _TiB(unsigned long long int num) { return { num << 40 }; }
|
constexpr ByteSize operator"" _TiB(unsigned long long int num) { return { num << 40 }; }
|
||||||
inline constexpr ByteSize operator"" _PiB(unsigned long long int num) { return { num << 50 }; }
|
constexpr ByteSize operator"" _PiB(unsigned long long int num) { return { num << 50 }; }
|
||||||
inline constexpr ByteSize operator"" _EiB(unsigned long long int num) { return { num << 60 }; }
|
constexpr ByteSize operator"" _EiB(unsigned long long int num) { return { num << 60 }; }
|
||||||
inline constexpr ByteSize operator"" _kB(unsigned long long int num) { return { num, ByteSizeUnit::kB }; }
|
constexpr ByteSize operator"" _kB(unsigned long long int num) { return { num, ByteSizeUnit::kB }; }
|
||||||
inline constexpr ByteSize operator"" _MB(unsigned long long int num) { return { num, ByteSizeUnit::MB }; }
|
constexpr ByteSize operator"" _MB(unsigned long long int num) { return { num, ByteSizeUnit::MB }; }
|
||||||
inline constexpr ByteSize operator"" _GB(unsigned long long int num) { return { num, ByteSizeUnit::GB }; }
|
constexpr ByteSize operator"" _GB(unsigned long long int num) { return { num, ByteSizeUnit::GB }; }
|
||||||
inline constexpr ByteSize operator"" _TB(unsigned long long int num) { return { num, ByteSizeUnit::TB }; }
|
constexpr ByteSize operator"" _TB(unsigned long long int num) { return { num, ByteSizeUnit::TB }; }
|
||||||
inline constexpr ByteSize operator"" _PB(unsigned long long int num) { return { num, ByteSizeUnit::PB }; }
|
constexpr ByteSize operator"" _PB(unsigned long long int num) { return { num, ByteSizeUnit::PB }; }
|
||||||
inline constexpr ByteSize operator"" _EB(unsigned long long int num) { return { num, ByteSizeUnit::EB }; }
|
constexpr ByteSize operator"" _EB(unsigned long long int num) { return { num, ByteSizeUnit::EB }; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef OVKMBS_FMT_MISSING
|
|
||||||
template<> struct fmt::formatter<OpenVulkano::ByteSize>
|
|
||||||
{
|
|
||||||
template<typename ParseContext> constexpr auto parse(ParseContext& ctx)
|
|
||||||
{
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename FormatContext> auto format(const OpenVulkano::ByteSize& bs, FormatContext& ctx)
|
|
||||||
{
|
|
||||||
return fmt::format_to(ctx.out(), "{}", bs.Format());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenVulkano::Scene
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto [allGlyphs, atlasWidth] = InitGlyphsForPacking(chset, face);
|
auto [allGlyphs, atlasWidth] = InitGlyphsForPacking(chset, face);
|
||||||
std::vector<Shelf> shelves = Shelf::CreateShelves(atlasWidth, allGlyphs, face, m_channelsCount);
|
std::vector<Shelf> shelves = Shelf::CreateShelves(atlasWidth, allGlyphs, face.get(), m_channelsCount);
|
||||||
uint32_t atlasHeight = 0;
|
uint32_t atlasHeight = 0;
|
||||||
std::for_each(shelves.begin(), shelves.end(), [&](const Shelf& shelf) { atlasHeight += shelf.GetHeight(); });
|
std::for_each(shelves.begin(), shelves.end(), [&](const Shelf& shelf) { atlasHeight += shelf.GetHeight(); });
|
||||||
const Math::Vector2ui atlasResolution = { atlasWidth, atlasHeight };
|
const Math::Vector2ui atlasResolution = { atlasWidth, atlasHeight };
|
||||||
@@ -183,7 +183,7 @@ namespace OpenVulkano::Scene
|
|||||||
void BitmapFontAtlasGenerator::FillSubpixelData(const FT_Bitmap& bitmap, const GlyphForPacking& glyph)
|
void BitmapFontAtlasGenerator::FillSubpixelData(const FT_Bitmap& bitmap, const GlyphForPacking& glyph)
|
||||||
{
|
{
|
||||||
Texture* tex = m_atlasData->GetTexture();
|
Texture* tex = m_atlasData->GetTexture();
|
||||||
char* texBuffer = static_cast<char*>(tex->textureBuffer);
|
uint8_t* texBuffer = static_cast<uint8_t*>(tex->textureBuffer);
|
||||||
if (m_subpixelLayout.IsHorizontalSubpixelLayout())
|
if (m_subpixelLayout.IsHorizontalSubpixelLayout())
|
||||||
{
|
{
|
||||||
// RGB RGB RGB
|
// RGB RGB RGB
|
||||||
|
|||||||
48
openVulkanoCpp/Scene/Text/Shelf.cpp
Normal file
48
openVulkanoCpp/Scene/Text/Shelf.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Shelf.hpp"
|
||||||
|
#include "Extensions/FreetypeHelper.hpp"
|
||||||
|
|
||||||
|
namespace OpenVulkano::Scene
|
||||||
|
{
|
||||||
|
std::vector<Shelf> Shelf::CreateShelves(uint32_t atlasWidth, std::vector<GlyphForPacking>& glyphs,
|
||||||
|
FT_FaceRec_* face, int channelsCount)
|
||||||
|
{
|
||||||
|
std::vector<Shelf> shelves;
|
||||||
|
for (GlyphForPacking& glyph : glyphs)
|
||||||
|
{
|
||||||
|
FT_Error error = FT_Load_Char(face, glyph.code, FT_LOAD_RENDER);
|
||||||
|
if (error) continue;
|
||||||
|
|
||||||
|
bool needNewShelf = true;
|
||||||
|
uint32_t totalPrevShelvesHeight = 0;
|
||||||
|
for (Shelf& shelf : shelves)
|
||||||
|
{
|
||||||
|
if (std::optional<std::pair<uint32_t, uint32_t>> opt = shelf.AddGlyph(glyph.size.x, glyph.size.y))
|
||||||
|
{
|
||||||
|
glyph.firstGlyphByteInAtlas = opt->second;
|
||||||
|
glyph.atlasPos.x = opt->first;
|
||||||
|
glyph.atlasPos.y = totalPrevShelvesHeight;
|
||||||
|
needNewShelf = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
totalPrevShelvesHeight += shelf.GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needNewShelf)
|
||||||
|
{
|
||||||
|
shelves.emplace_back(atlasWidth, glyph.size.y, channelsCount, totalPrevShelvesHeight);
|
||||||
|
Shelf& shelf = shelves.back();
|
||||||
|
uint32_t firstByte = (*shelf.AddGlyph(glyph.size.x, glyph.size.y)).second;
|
||||||
|
glyph.firstGlyphByteInAtlas = firstByte;
|
||||||
|
glyph.atlasPos.x = 0;
|
||||||
|
glyph.atlasPos.y = totalPrevShelvesHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return shelves;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,10 +7,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Math/Math.hpp"
|
#include "Math/Math.hpp"
|
||||||
#include "Extensions/FreetypeHelper.hpp"
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
struct FT_FaceRec_;
|
||||||
|
|
||||||
namespace OpenVulkano::Scene
|
namespace OpenVulkano::Scene
|
||||||
{
|
{
|
||||||
struct GlyphForPacking
|
struct GlyphForPacking
|
||||||
@@ -23,11 +24,10 @@ namespace OpenVulkano::Scene
|
|||||||
|
|
||||||
struct Shelf
|
struct Shelf
|
||||||
{
|
{
|
||||||
inline static std::vector<Shelf> CreateShelves(uint32_t atlasWidth, std::vector<GlyphForPacking>& glyphs,
|
static std::vector<Shelf> CreateShelves(uint32_t atlasWidth, std::vector<GlyphForPacking>& glyphs, FT_FaceRec_* face, int channelsCount);
|
||||||
const FtFaceRecPtr& face, int channelsCount);
|
|
||||||
|
|
||||||
Shelf(uint32_t width, uint32_t height, int pixelSize, uint32_t prevShelvesHeight)
|
Shelf(uint32_t width, uint32_t height, int pixelSize, uint32_t prevShelvesHeight)
|
||||||
: m_width(width), m_height(height), m_remainingWidth(width), m_pixelSize(pixelSize), m_prevShelvesHeight(prevShelvesHeight) {}
|
: m_width(width), m_height(height), m_remainingWidth(width), m_prevShelvesHeight(prevShelvesHeight), m_pixelSize(pixelSize) {}
|
||||||
bool HasSpaceForGlyph(uint32_t glyphWidth, uint32_t glyphHeight) const
|
bool HasSpaceForGlyph(uint32_t glyphWidth, uint32_t glyphHeight) const
|
||||||
{
|
{
|
||||||
return m_remainingWidth >= glyphWidth && m_height >= glyphHeight;
|
return m_remainingWidth >= glyphWidth && m_height >= glyphHeight;
|
||||||
@@ -65,45 +65,4 @@ namespace OpenVulkano::Scene
|
|||||||
uint32_t m_prevShelvesHeight;
|
uint32_t m_prevShelvesHeight;
|
||||||
int m_pixelSize;
|
int m_pixelSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Shelf> Shelf::CreateShelves(uint32_t atlasWidth, std::vector<GlyphForPacking>& glyphs,
|
|
||||||
const FtFaceRecPtr& face, int channelsCount)
|
|
||||||
{
|
|
||||||
std::vector<Shelf> shelves;
|
|
||||||
for (GlyphForPacking& glyph : glyphs)
|
|
||||||
{
|
|
||||||
FT_Error error = FT_Load_Char(face.get(), glyph.code, FT_LOAD_RENDER);
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_GlyphSlot slot = face->glyph;
|
|
||||||
bool needNewShelf = true;
|
|
||||||
uint32_t totalPrevShelvesHeight = 0;
|
|
||||||
for (Shelf& shelf : shelves)
|
|
||||||
{
|
|
||||||
if (std::optional<std::pair<uint32_t, uint32_t>> opt = shelf.AddGlyph(glyph.size.x, glyph.size.y))
|
|
||||||
{
|
|
||||||
glyph.firstGlyphByteInAtlas = opt->second;
|
|
||||||
glyph.atlasPos.x = opt->first;
|
|
||||||
glyph.atlasPos.y = totalPrevShelvesHeight;
|
|
||||||
needNewShelf = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
totalPrevShelvesHeight += shelf.GetHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needNewShelf)
|
|
||||||
{
|
|
||||||
shelves.emplace_back(atlasWidth, glyph.size.y, channelsCount, totalPrevShelvesHeight);
|
|
||||||
Shelf& shelf = shelves.back();
|
|
||||||
uint32_t firstByte = (*shelf.AddGlyph(glyph.size.x, glyph.size.y)).second;
|
|
||||||
glyph.firstGlyphByteInAtlas = firstByte;
|
|
||||||
glyph.atlasPos.x = 0;
|
|
||||||
glyph.atlasPos.y = totalPrevShelvesHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return shelves;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,10 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Extensions/FmtFormatter.hpp"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if __has_include("fmt/format.h")
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#elif __has_include("spdlog/fmt/fmt.h")
|
|
||||||
#include <spdlog/fmt/fmt.h>
|
|
||||||
#else
|
|
||||||
#error "Failed to find fmt include"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace ImGui
|
namespace ImGui
|
||||||
{
|
{
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
|||||||
Reference in New Issue
Block a user