Преглед изворни кода

add size method to FontResource

mikymod пре 12 година
родитељ
комит
d0b98df216
2 измењених фајлова са 9 додато и 0 уклоњено
  1. 2 0
      engine/resource/FontResource.cpp
  2. 7 0
      engine/resource/FontResource.h

+ 2 - 0
engine/resource/FontResource.cpp

@@ -76,6 +76,7 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 
 	JSONElement mat = root.key("material");
 	JSONElement count = root.key("count");
+	JSONElement size = root.key("size");
 	JSONElement glyphs = root.key("glyphs");
 
 	DynamicString material_name;
@@ -96,6 +97,7 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 
 	h.material.id = hash::murmur2_64(material_name.c_str(), string::strlen(material_name.c_str()), 0);
 	h.num_glyphs = m_glyphs.size();
+	h.size = size.to_int();
 
 	out_file->write((char*) &h, sizeof(FontHeader));
 

+ 7 - 0
engine/resource/FontResource.h

@@ -72,6 +72,7 @@ struct FontHeader
 {
 	ResourceId material;
 	uint32_t num_glyphs;
+	uint32_t size;			// Font texture size -- pow of 2
 };
 
 //-----------------------------------------------------------------------------
@@ -138,6 +139,12 @@ public:
 		return ((FontHeader*)this)->num_glyphs;
 	}
 
+	//-----------------------------------------------------------------------------
+	uint32_t size() const
+	{
+		return ((FontHeader*)this)->size;
+	}
+
 	//-----------------------------------------------------------------------------
 	FontGlyphData get_glyph(const uint8_t index) const
 	{