[Bf-blender-cvs] [b5cae50376] blender2.8: Add imm_draw_checker_box function

Luca Rood noreply at git.blender.org
Thu Feb 16 21:52:58 CET 2017


Commit: b5cae50376ba32694a48e23dabf5d35c8e6d5d8b
Author: Luca Rood
Date:   Thu Feb 16 18:22:28 2017 -0200
Branches: blender2.8
https://developer.blender.org/rBb5cae50376ba32694a48e23dabf5d35c8e6d5d8b

Add imm_draw_checker_box function

This replaces `fdrawcheckerboard` in drawing a standard gray
checkerboard for alpha backgrounds.

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

M	source/blender/editors/include/BIF_glutil.h
M	source/blender/editors/screen/glutil.c

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

diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 35e9f35b4e..30c810154b 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -128,6 +128,9 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
 /* use this version when VertexFormat has a vec3 position */
 void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2);
 
+/* Draw a standard checkerboard to indicate transparent backgrounds */
+void imm_draw_checker_box(float x1, float y1, float x2, float y2);
+
 void imm_draw_line(unsigned pos, float x1, float y1, float x2, float y2);
 /**
 * Pack color into 3 bytes
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 4baf3cd78b..7f8454ac49 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -75,8 +75,9 @@ void fdrawbox(float x1, float y1, float x2, float y2)
 	glEnd();
 }
 
-void fdrawcheckerboard(float x1, float y1, float x2, float y2) /* DEPRECATED */
+void fdrawcheckerboard(float x1, float y1, float x2, float y2)
 {
+	/* DEPRECATED: use imm_draw_checker_box instead */
 	unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50};
 
 	glColor3ubv(col1);
@@ -232,6 +233,20 @@ void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2)
 	immEnd();
 }
 
+void imm_draw_checker_box(float x1, float y1, float x2, float y2)
+{
+	unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
+	immBindBuiltinProgram(GPU_SHADER_2D_CHECKER);
+
+	immUniform4f("color1", 0.15f, 0.15f, 0.15f, 1.0f);
+	immUniform4f("color2", 0.2f, 0.2f, 0.2f, 1.0f);
+	immUniform1i("size", 8);
+
+	immRectf(pos, x1, y1, x2, y2);
+
+	immUnbindProgram();
+}
+
 void imm_cpack(unsigned int x)
 {
 	immUniformColor3ub(((x)& 0xFF),




More information about the Bf-blender-cvs mailing list