Browse Source

Fonts now handle resolution changes properly

Bill Meltsner 15 years ago
parent
commit
2cc3fb4715
2 changed files with 24 additions and 1 deletions
  1. 19 0
      src/modules/graphics/opengl/Font.cpp
  2. 5 1
      src/modules/graphics/opengl/Font.h

+ 19 - 0
src/modules/graphics/opengl/Font.cpp

@@ -171,6 +171,25 @@ namespace opengl
 	{
 		return mSpacing;
 	}
+	
+	bool Font::loadVolatile()
+	{
+		// reload all glyphs
+		for(unsigned int i = 0; i < MAX_CHARS; i++)
+		{
+			glyphs[i]->load(); 
+			glNewList(list + i, GL_COMPILE);
+			glyphs[i]->draw(0, 0, 0, 1, 1, 0, 0);
+			glEndList();
+		}
+		return true;
+	}
+	
+	void Font::unloadVolatile()
+	{
+		// delete the glyphs
+		glDeleteLists(list, MAX_CHARS);
+	}
 
 } // opengl
 } // graphics

+ 5 - 1
src/modules/graphics/opengl/Font.h

@@ -35,7 +35,7 @@ namespace graphics
 {
 namespace opengl
 {
-	class Font : public Object
+	class Font : public Object, public Volatile
 	{
 	private:
 
@@ -148,6 +148,10 @@ namespace opengl
 		* Returns the spacing modifier.
 		**/
 		float getSpacing() const;
+		
+		// Implements Volatile.
+		bool loadVolatile();
+		void unloadVolatile();	
 
 	}; // Font