[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19011] branches/blender2.5/blender/source /blender: Making the things compiled!!

Diego Borghetti bdiego at gmail.com
Tue Feb 17 17:56:31 CET 2009


Revision: 19011
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19011
Author:   bdiego
Date:     2009-02-17 17:56:29 +0100 (Tue, 17 Feb 2009)

Log Message:
-----------
Making the things compiled!!

I change the #if 0 with #if WITH_FREETYPE2, also fix a lot of typos, etc.
This is the basic but now it draw text!!, I am using the "User Preference"
space to test the library, nobody is working on that and the option are
in the outliner now so...

TODO-next: using the 4x4 mat, string size, bounding box, aspect and rotate.

Notes: I update the Makefile, missing some include and other things so
maybe scons, cmake and msvc also need update ?

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
    branches/blender2.5/blender/source/blender/blenfont/intern/Makefile
    branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_dir.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_glyph.c
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal_types.h
    branches/blender2.5/blender/source/blender/blenfont/intern/blf_lang.c
    branches/blender2.5/blender/source/blender/editors/interface/text.c
    branches/blender2.5/blender/source/blender/editors/space_info/Makefile
    branches/blender2.5/blender/source/blender/editors/space_info/space_info.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_files.c
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c

Modified: branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/BLF_api.h	2009-02-17 16:33:08 UTC (rev 19010)
+++ branches/blender2.5/blender/source/blender/blenfont/BLF_api.h	2009-02-17 16:56:29 UTC (rev 19011)
@@ -29,6 +29,18 @@
 #ifndef BLF_API_H
 #define BLF_API_H
 
+int BLF_init(void);
+void BLF_exit(void);
+
+int BLF_load(char *name);
+int BLF_load_mem(char *name, unsigned char *mem, int mem_size);
+
+void BLF_set(int fontid);
+void BLF_aspect(float aspect);
+void BLF_position(float x, float y, float z);
+void BLF_size(int size, int dpi);
+void BLF_draw(char *str);
+
 /* Read the .Blanguages file, return 1 on success or 0 if fails. */
 int BLF_lang_init(void);
 
@@ -49,8 +61,6 @@
 /* Return the code string for the specified language code. */
 char *BLF_lang_find_code(short langid);
 
-#if 0
-
 /* Add a path to the font dir paths. */
 void BLF_dir_add(const char *path);
 
@@ -63,6 +73,4 @@
 /* Free the data return by BLF_dir_get. */
 void BLF_dir_free(char **dirs, int count);
 
-#endif /* zero!! */
-
 #endif /* BLF_API_H */

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/Makefile
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/Makefile	2009-02-17 16:33:08 UTC (rev 19010)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/Makefile	2009-02-17 16:56:29 UTC (rev 19011)
@@ -33,10 +33,46 @@
 
 CFLAGS += $(LEVEL_1_C_WARNINGS)
 
-CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+# OpenGL and Freetype2
+CPPFLAGS += -I$(NAN_GLEW)/include
+CPPFLAGS += $(OGL_CPPFLAGS)
+CPPFLAGS += -I$(NAN_FREETYPE)/include
+
+ifeq ($(OS), windows)
+  CPPFLAGS += -I$(NAN_ICONV)/include
+  ifeq ($(FREE_WINDOWS), true)
+    CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
+    CPPFLAGS += -DUSE_GETTEXT_DLL
+  endif
+else
+  CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2
+endif
+
+ifeq ($(OS),linux)
+    ifeq ($(CPU),alpha)
+	CPPFLAGS += -I$(NAN_MESA)/include
+    endif
+    ifeq ($(CPU),i386)
+	CPPFLAGS += -I$(NAN_MESA)/include
+    endif
+    ifeq ($(CPU),powerpc)
+	CPPFLAGS += -I/usr/src/MesaCVS/include
+    endif
+endif
+
+ifeq ($(WITH_FREETYPE2), true)
+    CPPFLAGS += -DWITH_FREETYPE2
+endif
+
+# Modules
+CPPFLAGS += -I../../editors/include
 CPPFLAGS += -I../../makesdna
 CPPFLAGS += -I../../blenlib
 CPPFLAGS += -I../../blenkernel
 CPPFLAGS += -I../../ftfont
 
+# Memory allocator
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+
+# Our own headers
 CPPFLAGS += -I..

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf.c	2009-02-17 16:33:08 UTC (rev 19010)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf.c	2009-02-17 16:56:29 UTC (rev 19011)
@@ -26,20 +26,23 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#if 0
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WITH_FREETYPE2
+
 #include <ft2build.h>
 
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
+#endif /* WITH_FREETYPE2 */
+
 #include "MEM_guardedalloc.h"
 
 #include "DNA_listBase.h"
+#include "DNA_vec_types.h"
 
 #include "BKE_utildefines.h"
 
@@ -47,10 +50,15 @@
 #include "BLI_linklist.h"	/* linknode */
 #include "BLI_string.h"
 
+#include "BIF_gl.h"
+#include "BIF_glutil.h"
+
 #include "blf_internal_types.h"
 #include "blf_internal.h"
 
 
+#ifdef WITH_FREETYPE2
+
 /* Max number of font in memory.
  * Take care that now every font have a glyph cache per size/dpi,
  * so we don't need load the same font with different size, just
@@ -67,31 +75,55 @@
 /* Current font. */
 int global_font_cur= 0;
 
+#endif /* WITH_FREETYPE2 */
+
 int BLF_init(void)
 {
+#ifdef WITH_FREETYPE2
 	int i;
 
 	for (i= 0; i < BLF_MAX_FONT; i++)
 		global_font[i]= NULL;
 
 	return(blf_font_init());
+#else
+	return(0);
+#endif
 }
 
-int blf_search(char *name)
+void BLF_exit(void)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 	int i;
 
 	for (i= 0; i < global_font_num; i++) {
 		font= global_font[i];
+		blf_font_free(font);
+	}
+
+	blf_font_exit();
+#endif
+}
+
+int blf_search(char *name)
+{
+#ifdef WITH_FREETYPE2
+	FontBLF *font;
+	int i;
+
+	for (i= 0; i < BLF_MAX_FONT; i++) {
+		font= global_font[i];
 		if (font && (!strcmp(font->name, name)))
 			return(i);
 	}
+#endif
 	return(-1);
 }
 
 int BLF_load(char *name)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 	char *filename;
 	int i;
@@ -101,30 +133,44 @@
 
 	/* check if we already load this font. */
 	i= blf_search(name);
-	if (i >= 0)
+	if (i >= 0) {
+		font= global_font[i];
+		font->ref++;
+		printf("Increment reference (%d): %s\n", font->ref, name);
 		return(i);
+	}
 
-	if (global_font_num+1 >= BLF_MAX_FONT)
+	if (global_font_num+1 >= BLF_MAX_FONT) {
+		printf("Too many fonts!!!\n");
 		return(-1);
+	}
 
 	filename= blf_dir_search(name);
-	if (!filename)
+	if (!filename) {
+		printf("Can't found font: %s\n", name);
 		return(-1);
+	}
 
 	font= blf_font_new(name, filename);
 	MEM_freeN(filename);
 
-	if (!font)
+	if (!font) {
+		printf("Can't load font: %s\n", name);
 		return(-1);
+	}
 
 	global_font[global_font_num]= font;
 	i= global_font_num;
 	global_font_num++;
 	return(i);
+#else
+	return(-1);
+#endif /* WITH_FREETYPE2 */
 }
 
 int BLF_load_mem(char *name, unsigned char *mem, int mem_size)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 	int i;
 
@@ -132,39 +178,55 @@
 		return(-1);
 
 	i= blf_search(name);
-	if (i >= 0)
+	if (i >= 0) {
+		font= global_font[i];
+		font->ref++;
+		printf("Increment reference (%d): %s\n", font->ref, name);
 		return(i);
+	}
 
-	if (global_font_num+1 >= BLF_MAX_FONT)
+	if (global_font_num+1 >= BLF_MAX_FONT) {
+		printf("Too many fonts!!!\n");
 		return(-1);
+	}
 
-	font= blf_font_new_from_mem(name, mem, size);
-	if (!font)
+	font= blf_font_new_from_mem(name, mem, mem_size);
+	if (!font) {
+		printf("Can't load font, %s from memory!!\n", name);
 		return(-1);
+	}
 
 	global_font[global_font_num]= font;
 	i= global_font_num;
 	global_font_num++;
 	return(i);
+#else
+	return(-1);
+#endif /* WITH_FREETYPE2 */
 }
 
 void BLF_set(int fontid)
 {
-	if (fontid >= 0 && fontid < global_font_num)
+#ifdef WITH_FREETYPE2
+	if (fontid >= 0 && fontid < BLF_MAX_FONT)
 		global_font_cur= fontid;
+#endif
 }
 
 void BLF_aspect(float aspect)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 
 	font= global_font[global_font_cur];
 	if (font)
 		font->aspect= aspect;
+#endif
 }
 
 void BLF_position(float x, float y, float z)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 
 	font= global_font[global_font_cur];
@@ -173,23 +235,27 @@
 		font->pos[1]= y;
 		font->pos[2]= z;
 	}
+#endif
 }
 
 void BLF_size(int size, int dpi)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 
 	font= global_font[global_font_cur];
 	if (font)
 		blf_font_size(font, size, dpi);
+#endif
 }
 
 void BLF_draw(char *str)
 {
+#ifdef WITH_FREETYPE2
 	FontBLF *font;
 
 	font= global_font[global_font_cur];
-	if (font) {
+	if (font && font->glyph_cache) {
 		glEnable(GL_BLEND);
 		glEnable(GL_TEXTURE_2D);
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -200,9 +266,8 @@
 		blf_font_draw(font, str);
 
 		glPopMatrix();
+		glDisable(GL_BLEND);
 		glDisable(GL_TEXTURE_2D);
-		glDisable(GL_BLEND);
 	}
+#endif /* WITH_FREETYPE2 */
 }
-
-#endif

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_dir.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_dir.c	2009-02-17 16:33:08 UTC (rev 19010)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_dir.c	2009-02-17 16:56:29 UTC (rev 19011)
@@ -29,9 +29,19 @@
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WITH_FREETYPE2
+
+#include <ft2build.h>
+
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+
+#endif /* WITH_FREETYPE2 */
+
 #include "MEM_guardedalloc.h"
 
 #include "DNA_listBase.h"
+#include "DNA_vec_types.h"
 
 #include "BKE_utildefines.h"
 
@@ -39,6 +49,8 @@
 #include "BLI_linklist.h"	/* linknode */
 #include "BLI_string.h"
 
+#include "BIF_gl.h"
+
 #include "blf_internal_types.h"
 
 static ListBase global_font_dir= { NULL, NULL };

Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c	2009-02-17 16:33:08 UTC (rev 19010)
+++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c	2009-02-17 16:56:29 UTC (rev 19011)
@@ -26,31 +26,39 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-#if 0
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef WITH_FREETYPE2
+
 #include <ft2build.h>
 
 #include FT_FREETYPE_H
 #include FT_GLYPH_H
 
+#endif /* WITH_FREETYPE2 */
+
 #include "MEM_guardedalloc.h"
 
 #include "DNA_listBase.h"
+#include "DNA_vec_types.h"
 
 #include "BKE_utildefines.h"
 
 #include "BLI_blenlib.h"
 #include "BLI_linklist.h"	/* linknode */
 #include "BLI_string.h"
+#include "BLI_arithb.h"
 
+#include "BIF_gl.h"
+
 #include "blf_internal_types.h"
 #include "blf_internal.h"
 
 
+#ifdef WITH_FREETYPE2
+
 /* freetype2 handle. */
 FT_Library global_ft_lib;
 
@@ -61,7 +69,7 @@
 
 void blf_font_exit(void)
 {
-	FT_Done_Freetype(global_ft_lib);
+	FT_Done_FreeType(global_ft_lib);
 }
 
 void blf_font_fill(FontBLF *font)
@@ -95,21 +103,20 @@
 	font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
 	err= FT_New_Face(global_ft_lib, filename, 0, &font->face);
 	if (err) {
-		printf("BLF: Can't load font: %s\n", filename);
 		MEM_freeN(font);
 		return(NULL);
 	}
 
 	err= FT_Select_Charmap(font->face, ft_encoding_unicode);
 	if (err) {
-		printf("Warning: FT_Select_Charmap fail!!\n");
+		printf("Can't set the unicode character map!\n");
 		FT_Done_Face(font->face);
 		MEM_freeN(font);
 		return(NULL);
 	}
 
-	font->name= MEM_strdup(name);
-	font->filename= MEM_strdup(filename);
+	font->name= BLI_strdup(name);
+	font->filename= BLI_strdup(filename);
 	blf_font_fill(font);
 	return(font);
 }
@@ -120,22 +127,21 @@
 	FT_Error err;
 
 	font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
-	err= FT_New_Memory_Face(global_ft_lib, mem, size, 0, &font->face);
+	err= FT_New_Memory_Face(global_ft_lib, mem, mem_size, 0, &font->face);
 	if (err) {
-		printf("BLF: Can't load font: %s, from memory!!\n", name);
 		MEM_freeN(font);
 		return(NULL);
 	}
 
 	err= FT_Select_Charmap(font->face, ft_encoding_unicode);
 	if (err) {
-		printf("BLF: FT_Select_Charmap fail!!\n");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list