Ivan Safrin пре 13 година
родитељ
комит
e10455cf98

+ 3 - 0
Core/Contents/Include/PolyLabel.h

@@ -38,6 +38,9 @@ namespace Polycode {
 		public:
 			GlyphData();
 			~GlyphData();
+			
+			void clearData();
+			
 			FT_Glyph *glyphs;
 			FT_Vector *positions;	
 			FT_UInt num_glyphs;

+ 2 - 0
Core/Contents/Source/PolyGLTexture.cpp

@@ -118,11 +118,13 @@ void OpenGLTexture::setGLInfo(GLuint textureID, GLuint frameBufferID) {
 }
 
 void OpenGLTexture::setTextureData(char *data) {
+/*
 	glBindTexture(GL_TEXTURE_2D, textureID);
 	glDrawBuffer(GL_AUX0);
 	glDrawPixels(width, height, glTextureType, pixelType, data);
 	glReadBuffer(GL_AUX0);
 //	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 128, 128, 0);
+*/
 }
 
 OpenGLTexture::~OpenGLTexture() {

+ 16 - 8
Core/Contents/Source/PolyLabel.cpp

@@ -35,8 +35,19 @@ GlyphData::GlyphData() {
 }
 
 GlyphData::~GlyphData() {
-	delete glyphs;
-	delete positions;
+	clearData();
+}
+
+void GlyphData::clearData() {
+	for(int i=0; i < num_glyphs; i++) {
+		FT_Done_Glyph(glyphs[i]);
+	}
+	free(glyphs);
+	free(positions);
+	glyphs = NULL;
+	positions = NULL;
+	num_glyphs = 0;	
+	trailingAdvance = 0;	
 }
 
 
@@ -199,10 +210,7 @@ Color Label::getColorForIndex(unsigned int index) {
 }
 
 void Label::precacheGlyphs(String text, GlyphData *glyphData) {
-	if(glyphData->glyphs)
-		free(glyphData->glyphs);
-	if(glyphData->positions)
-		free(glyphData->positions);
+	glyphData->clearData();
 		
 	int num_chars = text.length();
 		
@@ -372,8 +380,8 @@ void Label::renderGlyphs(GlyphData *glyphData) {
 			drawGlyphBitmap(&bit->bitmap,
 					bit->left - xAdjustOffset,
 					height - bit->top + baseLineOffset, glyphColor);
-
-			FT_Done_Glyph( image );			
+					
+			FT_Done_Glyph( image );
 		}
 	}
 }

+ 1 - 1
Core/Contents/Source/PolyTexture.cpp

@@ -94,7 +94,7 @@ void Texture::setImageData(Image *data) {
 		free(this->textureData);
 	this->textureData = (char*)malloc(width*height*pixelSize);
 	memcpy(this->textureData, data->getPixels(), width*height*pixelSize);
-	setTextureData(data->getPixels());
+//	setTextureData(data->getPixels());
 
 }