[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47524] branches/soc-2012-swiss_cheese/ source/blender/blenfont: Created a BLF_draw_default_lock/ BLF_draw_default_unlock that are to BLF_draw_default what BLF_draw_lock/ BLF_draw_unlock are to BLF_draw.

Jason Wilkins Jason.A.Wilkins at gmail.com
Wed Jun 6 18:44:58 CEST 2012


Revision: 47524
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47524
Author:   jwilkins
Date:     2012-06-06 16:44:47 +0000 (Wed, 06 Jun 2012)
Log Message:
-----------
Created a BLF_draw_default_lock/BLF_draw_default_unlock that are to BLF_draw_default what BLF_draw_lock/BLF_draw_unlock are to BLF_draw.

Modified Paths:
--------------
    branches/soc-2012-swiss_cheese/source/blender/blenfont/BLF_api.h
    branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c

Modified: branches/soc-2012-swiss_cheese/source/blender/blenfont/BLF_api.h
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenfont/BLF_api.h	2012-06-06 16:32:54 UTC (rev 47523)
+++ branches/soc-2012-swiss_cheese/source/blender/blenfont/BLF_api.h	2012-06-06 16:44:47 UTC (rev 47524)
@@ -69,6 +69,8 @@
 void BLF_matrix(int fontid, const double m[16]);
 
 /* Draw the string using the default font, size and dpi. */
+void BLF_draw_default_lock(void);
+void BLF_draw_default_unlock(void);
 void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
 void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
 

Modified: branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c
===================================================================
--- branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c	2012-06-06 16:32:54 UTC (rev 47523)
+++ branches/soc-2012-swiss_cheese/source/blender/blenfont/intern/blf.c	2012-06-06 16:44:47 UTC (rev 47524)
@@ -435,41 +435,54 @@
 	}
 }
 
-void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
+static int get_default(void)
 {
-	if (!str)
-		return;
-
-	if (global_font_default == -1)
+	if (global_font_default == -1) {
 		global_font_default = blf_search("default");
 
-	if (global_font_default == -1) {
-		printf("Warning: Can't found default font!!\n");
-		return;
+		if (global_font_default == -1) {
+			printf("Warning: Can't found default font!!\n");
+			return FALSE;
+		}
 	}
 
-	BLF_size(global_font_default, global_font_points, global_font_dpi);
-	BLF_position(global_font_default, x, y, z);
-	BLF_draw(global_font_default, str, len);
+	return TRUE;
 }
 
-/* same as above but call 'BLF_draw_ascii' */
-void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
+void BLF_draw_default_lock(void)
 {
-	if (!str)
-		return;
+	if (get_default()) {
+		BLF_size(global_font_default, global_font_points, global_font_dpi);
+		BLF_draw_lock(global_font_default);
+	}
+}
 
-	if (global_font_default == -1)
-		global_font_default = blf_search("default");
+void BLF_draw_default_unlock(void)
+{
+	if (get_default()) {
+		BLF_draw_unlock();
+	}
+}
 
-	if (global_font_default == -1) {
-		printf("Warning: Can't found default font!!\n");
-		return;
+void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
+{
+	if (str && get_default()) {
+		BLF_draw_default_lock();
+		BLF_position(global_font_default, x, y, z);
+		BLF_draw(global_font_default, str, len);
+		BLF_draw_default_unlock();
 	}
+}
 
-	BLF_size(global_font_default, global_font_points, global_font_dpi);
-	BLF_position(global_font_default, x, y, z);
-	BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
+/* same as above but call 'BLF_draw_ascii' */
+void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
+{
+	if (str && get_default()) {
+		BLF_draw_default_lock();
+		BLF_position(global_font_default, x, y, z);
+		BLF_draw(global_font_default, str, len);  /* XXX, use real length */
+		BLF_draw_default_unlock();
+	}
 }
 
 void BLF_rotation_default(float angle)
@@ -483,30 +496,20 @@
 
 static void draw_lock(FontBLF *font)
 {
+	/* one time GL setup */
 	if (gpuImmediateLockCount() == 0) {
-		GLint texCoordSizes[1] = { 2 };
-		GLint texUnitMap[1]    = { GL_TEXTURE0 };
-
-		if (font->shadow || font->blur) {
-			gpuImmediateElementSizes(2, 0, 4); //-V112
-		}
-		else {
-			gpuImmediateElementSizes(2, 0, 0);
-		}
-
-		gpuImmediateTextureUnitCount(1);
-		gpuImmediateTexCoordSizes(texCoordSizes);
-		gpuImmediateTextureUnitMap(texUnitMap);
-
-		/* one time GL setup */
-
 		glEnable(GL_TEXTURE_2D);
 
 		glEnable(GL_BLEND);
 		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 	}
 
-	gpuImmediateLock();
+	if (font->shadow || font->blur) {
+		gpuImmediateFormat_T2_C4_V2(); // DOODLE: blurred and/or shadowed text
+	}
+	else {
+		gpuImmediateFormat_T2_V2(); // DOODLE: normal text
+	}
 }
 
 void BLF_draw_lock(int fontid)
@@ -520,7 +523,7 @@
 
 void BLF_draw_unlock(void)
 {
-	gpuImmediateUnlock();
+	gpuImmediateUnformat();
 
 	if (gpuImmediateLockCount() == 0) {
 		glDisable(GL_BLEND);
@@ -592,7 +595,7 @@
 
 void BLF_draw(int fontid, const char *str, size_t len)
 {
-	if (len > 0) {
+	if (len > 0 && str[0]) {
 		FontBLF *font = BLF_get(fontid);
 		GLint mode, param;
 
@@ -606,7 +609,7 @@
 
 void BLF_draw_ascii(int fontid, const char *str, size_t len)
 {
-	if (len > 0) {
+	if (len > 0 && str[0]) {
 		FontBLF *font = BLF_get(fontid);
 		GLint mode, param;
 




More information about the Bf-blender-cvs mailing list