luna engine
software engine
Loading...
Searching...
No Matches
luna::vulkan::vulkanFont Class Reference

font implementation in vulkan. More...

#include <vulkanTexture.h>

Inheritance diagram for luna::vulkan::vulkanFont:
Collaboration diagram for luna::vulkan::vulkanFont:

Classes

struct  glyph
 

Public Member Functions

 vulkanFont (const std::string &filePath)
 
virtual ~vulkanFont ()=default
 
virtual ref< renderer::texturegetGlyph (char character) override
 
virtual glm::vec2 getAdvance (char character) override
 
virtual glm::vec2 getScale (char character) override
 
- Public Member Functions inherited from luna::renderer::font
virtual ~font ()=default
 
virtual ref< texturegetGlyph (char character)=0
 
virtual glm::vec2 getAdvance (char character)=0
 
virtual glm::vec2 getScale (char charcater)=0
 
uint64_t handle ()
 

Private Member Functions

void createFontTexture ()
 allocates and creates the atlas texture from wich glyph can be sampled from. More...
 
stbi_uc * createGlyph (const stbtt_fontinfo *info, int codePoint, float *xscale, float *yscale, int *newXoff, int *newYoff)
 creates a font glyph and gurantees the texture height and width to be 300 by 300 pixels. More...
 
void writeGlyphsIntoBuffer ()
 

Private Attributes

VkBuffer testBuffer = VK_NULL_HANDLE
 
std::vector< VkBuffer > buffer
 
VkImage imageHandle = VK_NULL_HANDLE
 
VkImageView imageViewHandle = VK_NULL_HANDLE
 

Static Private Attributes

static const int width = 4800
 
static const int height = 4800
 

Additional Inherited Members

- Static Public Member Functions inherited from luna::renderer::font
static ref< fontcreate (const std::string &filePath)
 
- Protected Attributes inherited from luna::renderer::font
stbtt_fontinfo fontInfo
 
uint64_t _handle
 
void * data
 
std::vector< glm::vec2 > glypScales
 
std::vector< glm::vec2 > glypAdvances
 
- Static Protected Attributes inherited from luna::renderer::font
static const char startIndex = 0
 

Detailed Description

font implementation in vulkan.

Constructor & Destructor Documentation

◆ vulkanFont()

luna::vulkan::vulkanFont::vulkanFont ( const std::string &  filePath)

◆ ~vulkanFont()

virtual luna::vulkan::vulkanFont::~vulkanFont ( )
virtualdefault

Member Function Documentation

◆ createFontTexture()

void luna::vulkan::vulkanFont::createFontTexture ( )
private

allocates and creates the atlas texture from wich glyph can be sampled from.

◆ createGlyph()

stbi_uc * luna::vulkan::vulkanFont::createGlyph ( const stbtt_fontinfo *  info,
int  codePoint,
float *  xscale,
float *  yscale,
int *  newXoff,
int *  newYoff 
)
private

creates a font glyph and gurantees the texture height and width to be 300 by 300 pixels.

Parameters
conststbtt_fontinfo* info
intcodePoint (char code to create glyph from)
float*xscale: relative scale to get 1.0f width back. (300 / xscale)
float*yscale: relative scale to get 1.0f height back. (300 / yscale)
int*newXoff: relative xoffset.
newYoffrelative yoffset.
Returns
stbi_uc* pointer to texure data.

◆ getAdvance()

glm::vec2 luna::vulkan::vulkanFont::getAdvance ( char  character)
overridevirtual

Implements luna::renderer::font.

◆ getGlyph()

ref< renderer::texture > luna::vulkan::vulkanFont::getGlyph ( char  character)
overridevirtual

Implements luna::renderer::font.

◆ getScale()

glm::vec2 luna::vulkan::vulkanFont::getScale ( char  character)
overridevirtual

Implements luna::renderer::font.

◆ writeGlyphsIntoBuffer()

void luna::vulkan::vulkanFont::writeGlyphsIntoBuffer ( )
private

Member Data Documentation

◆ buffer

std::vector<VkBuffer> luna::vulkan::vulkanFont::buffer
private

◆ height

const int luna::vulkan::vulkanFont::height = 4800
staticprivate

◆ imageHandle

VkImage luna::vulkan::vulkanFont::imageHandle = VK_NULL_HANDLE
private

◆ imageViewHandle

VkImageView luna::vulkan::vulkanFont::imageViewHandle = VK_NULL_HANDLE
private

◆ testBuffer

VkBuffer luna::vulkan::vulkanFont::testBuffer = VK_NULL_HANDLE
private

◆ width

const int luna::vulkan::vulkanFont::width = 4800
staticprivate

The documentation for this class was generated from the following files: