mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 11:00:06 +00:00 
			
		
		
		
	Scalable fonts using freetype-gl
This commit is contained in:
		
							parent
							
								
									ec8e2643ff
								
							
						
					
					
						commit
						289ed430c7
					
				
					 8 changed files with 400 additions and 181 deletions
				
			
		|  | @ -5,6 +5,7 @@ | |||
| #include <memory> | ||||
| #include <string> | ||||
| 
 | ||||
| #include <boost/gil.hpp> | ||||
| #include <glm/glm.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
|  | @ -14,13 +15,7 @@ namespace qt | |||
| namespace util | ||||
| { | ||||
| 
 | ||||
| struct Glyph | ||||
| { | ||||
|    GLuint     textureId; | ||||
|    glm::ivec2 size;    // pixels
 | ||||
|    glm::ivec2 bearing; // pixels
 | ||||
|    GLint      advance; // 1/64 pixels
 | ||||
| }; | ||||
| class FontBuffer; | ||||
| 
 | ||||
| class FontImpl; | ||||
| 
 | ||||
|  | @ -36,12 +31,24 @@ public: | |||
|    Font(Font&&)  = delete; | ||||
|    Font& operator=(Font&&) = delete; | ||||
| 
 | ||||
|    void GenerateGlyphs(OpenGLFunctions&                 gl, | ||||
|                        std::unordered_map<char, Glyph>& glyphs, | ||||
|                        unsigned int                     height); | ||||
|    float BufferText(std::shared_ptr<FontBuffer> buffer, | ||||
|                     const std::string&          text, | ||||
|                     float                       x, | ||||
|                     float                       y, | ||||
|                     float                       scale, | ||||
|                     boost::gil::rgba8_pixel_t   color) const; | ||||
|    float Kerning(char c1, char c2) const; | ||||
|    float TextLength(const std::string& text, float scale) const; | ||||
| 
 | ||||
|    GLuint GenerateTexture(OpenGLFunctions& gl); | ||||
| 
 | ||||
|    static std::shared_ptr<Font> Create(const std::string& resource); | ||||
| 
 | ||||
|    static std::shared_ptr<FontBuffer> CreateBuffer(); | ||||
|    static void ClearBuffer(std::shared_ptr<FontBuffer> buffer); | ||||
|    static void RenderBuffer(OpenGLFunctions&            gl, | ||||
|                             std::shared_ptr<FontBuffer> buffer); | ||||
| 
 | ||||
| private: | ||||
|    std::unique_ptr<FontImpl> p; | ||||
| }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat