[Bf-blender-cvs] [5559abf31dc] blender2.8: GWN: IMM: Add util function to batch several immRecti/immRectf

Clément Foucault noreply at git.blender.org
Tue Apr 17 19:37:10 CEST 2018


Commit: 5559abf31dc725043af0c0d4ff53beda2fcfd591
Author: Clément Foucault
Date:   Tue Apr 17 19:35:56 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB5559abf31dc725043af0c0d4ff53beda2fcfd591

GWN: IMM: Add util function to batch several immRecti/immRectf

===================================================================

M	intern/gawain/gawain/gwn_imm_util.h
M	intern/gawain/src/gwn_imm_util.c

===================================================================

diff --git a/intern/gawain/gawain/gwn_imm_util.h b/intern/gawain/gawain/gwn_imm_util.h
index 730bd7c1a3c..5d17ec50669 100644
--- a/intern/gawain/gawain/gwn_imm_util.h
+++ b/intern/gawain/gawain/gwn_imm_util.h
@@ -16,3 +16,7 @@
 // caller is reponsible for vertex format & shader
 void immRectf(unsigned pos, float x1, float y1, float x2, float y2);
 void immRecti(unsigned pos, int x1, int y1, int x2, int y2);
+
+// Same as immRectf/immRecti but does not call immBegin/immEnd. To use with GWN_PRIM_TRIS.
+void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4]);
+void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4]);
diff --git a/intern/gawain/src/gwn_imm_util.c b/intern/gawain/src/gwn_imm_util.c
index 45d8a7036e8..a8d2b05c8a3 100644
--- a/intern/gawain/src/gwn_imm_util.c
+++ b/intern/gawain/src/gwn_imm_util.c
@@ -33,6 +33,40 @@ void immRecti(unsigned pos, int x1, int y1, int x2, int y2)
 	immEnd();
 	}
 
+void immRectf_fast_with_color(unsigned pos, unsigned col, float x1, float y1, float x2, float y2, const float color[4])
+	{
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x1, y1);
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x2, y1);
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x2, y2);
+
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x1, y1);
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x2, y2);
+	immAttrib4fv(col, color);
+	immVertex2f(pos, x1, y2);
+	}
+
+void immRecti_fast_with_color(unsigned pos, unsigned col, int x1, int y1, int x2, int y2, const float color[4])
+	{
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x1, y1);
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x2, y1);
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x2, y2);
+
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x1, y1);
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x2, y2);
+	immAttrib4fv(col, color);
+	immVertex2i(pos, x1, y2);
+	}
+
 #if 0 // more complete version in case we want that
 void immRecti_complete(int x1, int y1, int x2, int y2, const float color[4])
 	{



More information about the Bf-blender-cvs mailing list