SDF & MONOSPACE FONT RENDERING
This commit is contained in:
@@ -76,7 +76,9 @@ class PD_API GfxDriver : public DriverInterface {
|
||||
size_t CurrentVertex = 0;
|
||||
size_t pCountDrawcalls = 0;
|
||||
size_t pCountCommands = 0;
|
||||
// State Variables oder so
|
||||
TextureID CurrentTex = 0;
|
||||
bool CurrentTexIsSDF = false;
|
||||
Mat4 Projection;
|
||||
ivec2 ViewPort;
|
||||
std::unordered_map<TextureID, Li::Texture> pTextureRegestry;
|
||||
@@ -114,12 +116,14 @@ class GfxDriverBase : public GfxDriver {
|
||||
UploadPools();
|
||||
while (index < commands.size()) {
|
||||
CurrentTex = commands[index].Tex;
|
||||
CurrentTexIsSDF = commands[index].SDF;
|
||||
if (!CurrentTex) {
|
||||
CurrentTex = pWhite.GetID();
|
||||
}
|
||||
size_t startidx = commands[index].FirstIndex;
|
||||
size_t num_indices = 0;
|
||||
while (index < commands.size() &&
|
||||
CurrentTexIsSDF == commands[index].SDF &&
|
||||
(CurrentTex == commands[index].Tex ||
|
||||
(CurrentTex == pWhite.GetID() && commands[index].Tex == 0))) {
|
||||
num_indices += commands[index].IndexCount;
|
||||
|
||||
@@ -20,6 +20,7 @@ class Command {
|
||||
|
||||
int Layer = 0;
|
||||
ptr Tex = 0;
|
||||
bool SDF = false;
|
||||
size_t FirstVertex = 0;
|
||||
size_t FirstIndex = 0;
|
||||
size_t VertexCount = 0;
|
||||
|
||||
@@ -14,6 +14,13 @@ enum LiTextFlags_ : PD::u32 {
|
||||
LiTextFlags_NoOOS = 1 << 6, ///< No Out of Screen Rendering
|
||||
};
|
||||
|
||||
using LiFontFlags = PD::u32;
|
||||
enum LiFontFlags_ : PD::u32 {
|
||||
LiFontFlags_None = 0, ///< Not special (bitmap font)
|
||||
LiFontFlags_SDF = 1 << 0, ///< SDF Texture (and mode)
|
||||
LiFontFlags_Monospace = 1 << 1, ///< Monospace Rendering
|
||||
};
|
||||
|
||||
namespace PD {
|
||||
namespace Li {
|
||||
class Drawlist;
|
||||
@@ -24,24 +31,31 @@ class PD_API Font {
|
||||
fvec4 SimpleUV;
|
||||
size_t Tex = 0;
|
||||
fvec2 Size;
|
||||
float Offset = 0.f;
|
||||
fvec2 Offset;
|
||||
// float Offset = 0.f;
|
||||
float AdvanceX = 0.f;
|
||||
bool pInvalid = false;
|
||||
};
|
||||
Font() {}
|
||||
~Font() {}
|
||||
|
||||
bool IsMonospace() { return pFlags & LiFontFlags_Monospace; }
|
||||
bool IsSDF() { return pFlags & LiFontFlags_SDF; }
|
||||
|
||||
/**
|
||||
* Load a TTF File
|
||||
* @param path Path to the TTF file
|
||||
* @param px_height Pixelheight of the codepoints (limit by 64)
|
||||
*/
|
||||
void LoadTTF(const std::string& path, int px_height = 32);
|
||||
void LoadTTF(const std::string& path, int px_height = 32,
|
||||
LiFontFlags flags = LiFontFlags_None);
|
||||
/**
|
||||
* Load a TTF File from Memory
|
||||
* @param data File data
|
||||
* @param px_height Pixelheight of the codepoints (limit by 64)
|
||||
*/
|
||||
void LoadTTF(const std::vector<u8>& data, int px_height = 32);
|
||||
void LoadTTF(const std::vector<u8>& data, int px_height = 32,
|
||||
LiFontFlags flags = LiFontFlags_None);
|
||||
/**
|
||||
* Function that loads a default integrated font...
|
||||
* This will only work if PD_LI_INCLUDE_FONTS was set
|
||||
@@ -105,6 +119,7 @@ class PD_API Font {
|
||||
|
||||
private:
|
||||
size_t pCurrentTex = 0;
|
||||
LiFontFlags pFlags = 0;
|
||||
};
|
||||
} // namespace Li
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user