[Bf-blender-cvs] [11653f8] blender2.8: Immediate mode: new util functions (imm_cpack and imm_draw_line_box)

Dalai Felinto noreply at git.blender.org
Fri Oct 14 20:59:42 CEST 2016


Commit: 11653f85ff0c1050022f37692640db2f7e4578dc
Author: Dalai Felinto
Date:   Thu Oct 13 23:26:55 2016 +0000
Branches: blender2.8
https://developer.blender.org/rB11653f85ff0c1050022f37692640db2f7e4578dc

Immediate mode: new util functions (imm_cpack and imm_draw_line_box)

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

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 a5a1200..30718cc 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -105,6 +105,24 @@ void imm_draw_lined_circle(unsigned pos, float x, float y, float radius, int nse
 void imm_draw_filled_circle(unsigned pos, float x, float y, float radius, int nsegments);
 
 /**
+* Draw a lined box.
+*
+* \param pos The vertex attribute number for position.
+* \param x1 left.
+* \param y1 bottom.
+* \param x2 right.
+* \param y2 top.
+*/
+void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
+
+/**
+* Pack color into 3 bytes
+*
+* \param x color.
+*/
+void imm_cpack(unsigned int x);
+
+/**
  * Returns a float value as obtained by glGetFloatv.
  * The param must cause only one value to be gotten from GL.
  */
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 3e42587..2d89398 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -68,6 +68,7 @@ void fdrawline(float x1, float y1, float x2, float y2)
 
 void fdrawbox(float x1, float y1, float x2, float y2)
 {
+	/* DEPRECATED: use imm_draw_line_box instead */
 	glBegin(GL_LINE_LOOP);
 	
 	glVertex2f(x1, y1);
@@ -102,6 +103,7 @@ void sdrawline(int x1, int y1, int x2, int y2)
 
 void sdrawbox(int x1, int y1, int x2, int y2)
 {
+	/* DEPRECATED: use imm_draw_line_box instead */
 	glBegin(GL_LINE_LOOP);
 	
 	glVertex2i(x1, y1);
@@ -203,6 +205,23 @@ void imm_draw_filled_circle(unsigned pos, float x, float y, float rad, int nsegm
 	imm_draw_circle(GL_TRIANGLE_FAN, pos, x, y, rad, nsegments);
 }
 
+void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
+{
+	immBegin(GL_LINE_LOOP, 4);
+	immVertex2f(pos, x1, y1);
+	immVertex2f(pos, x1, y2);
+	immVertex2f(pos, x2, y2);
+	immVertex2f(pos, x2, y1);
+	immEnd();
+}
+
+void imm_cpack(unsigned int x)
+{
+	immUniformColor3ub(((x)& 0xFF),
+		(((x) >> 8) & 0xFF),
+		(((x) >> 16) & 0xFF));
+}
+
 float glaGetOneFloat(int param)
 {
 	GLfloat v;
@@ -874,6 +893,7 @@ void glaDrawImBuf_glsl_ctx(const bContext *C, ImBuf *ibuf, float x, float y, int
 
 void cpack(unsigned int x)
 {
+	/* DEPRECATED: use imm_cpack */
 	glColor3ub(( (x)        & 0xFF),
 	           (((x) >>  8) & 0xFF),
 	           (((x) >> 16) & 0xFF));




More information about the Bf-blender-cvs mailing list