[Bf-blender-cvs] [4ea6917] blender2.8: OpenGL: box & circle outline functions that work with 3D position (z=0)
Mike Erwin
noreply at git.blender.org
Thu Oct 20 20:50:56 CEST 2016
Commit: 4ea6917468ec82c966a2f67db0b0b6f375d8d9d4
Author: Mike Erwin
Date: Thu Oct 20 14:33:32 2016 -0400
Branches: blender2.8
https://developer.blender.org/rB4ea6917468ec82c966a2f67db0b0b6f375d8d9d4
OpenGL: box & circle outline functions that work with 3D position (z=0)
New immediate mode API is strict about attribute formats. These new functions make existing code easier to port.
Supports T49043
===================================================================
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 30718cc..7045340 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -92,6 +92,9 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment
*/
void imm_draw_lined_circle(unsigned pos, float x, float y, float radius, int nsegments);
+/* use this version when VertexFormat has a vec3 position */
+void imm_draw_lined_circle_3D(unsigned pos, float x, float y, float radius, int nsegments);
+
/**
* Draw a filled circle with the given \a radius.
* The circle is centered at \a x, \a y and drawn in the XY plane.
@@ -115,6 +118,9 @@ void imm_draw_filled_circle(unsigned pos, float x, float y, float radius, int ns
*/
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);
+
/**
* Pack color into 3 bytes
*
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index a7e8c21..b64152b 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -203,6 +203,17 @@ 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_lined_circle_3D(unsigned pos, float x, float y, float rad, int nsegments)
+{
+ immBegin(GL_LINE_LOOP, nsegments);
+ for (int i = 0; i < nsegments; ++i) {
+ float angle = 2 * M_PI * ((float)i / (float)nsegments);
+ immVertex3f(pos, x + rad * cosf(angle),
+ y + rad * sinf(angle), 0.0f);
+ }
+ immEnd();
+}
+
void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
{
immBegin(GL_LINE_LOOP, 4);
@@ -213,6 +224,17 @@ void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
immEnd();
}
+void imm_draw_line_box_3D(unsigned pos, float x1, float y1, float x2, float y2)
+{
+ /* use this version when VertexFormat has a vec3 position */
+ immBegin(GL_LINE_LOOP, 4);
+ immVertex3f(pos, x1, y1, 0.0f);
+ immVertex3f(pos, x1, y2, 0.0f);
+ immVertex3f(pos, x2, y2, 0.0f);
+ immVertex3f(pos, x2, y1, 0.0f);
+ immEnd();
+}
+
void imm_cpack(unsigned int x)
{
immUniformColor3ub(((x)& 0xFF),
More information about the Bf-blender-cvs
mailing list