Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/blender/draw/intern/draw_armature.c1
-rw-r--r--source/blender/editors/animation/anim_channels_defines.c1
-rw-r--r--source/blender/editors/armature/editarmature_sketch.c2
-rw-r--r--source/blender/editors/curve/editcurve_paint.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_brush.c3
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c1
-rw-r--r--source/blender/editors/include/BIF_glutil.h89
-rw-r--r--source/blender/editors/interface/interface_draw.c1
-rw-r--r--source/blender/editors/interface/interface_widgets.c3
-rw-r--r--source/blender/editors/mesh/editmesh_knife.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/screen/area.c2
-rw-r--r--source/blender/editors/screen/glutil.c245
-rw-r--r--source/blender/editors/screen/screendump.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_hide.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c1
-rw-r--r--source/blender/editors/sculpt_paint/paint_mask.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_uv.c3
-rw-r--r--source/blender/editors/space_clip/clip_draw.c1
-rw-r--r--source/blender/editors/space_clip/clip_graph_draw.c3
-rw-r--r--source/blender/editors/space_file/file_draw.c1
-rw-r--r--source/blender/editors/space_image/image_draw.c1
-rw-r--r--source/blender/editors/space_node/node_draw.c1
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c1
-rw-r--r--source/blender/editors/space_time/space_time.c1
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c1
-rw-r--r--source/blender/editors/space_view3d/drawobject.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_draw_legacy.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c2
-rw-r--r--source/blender/editors/space_view3d/view3d_ruler.c1
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c3
-rw-r--r--source/blender/editors/transform/transform.c1
-rw-r--r--source/blender/editors/uvedit/uvedit_draw.c1
-rw-r--r--source/blender/gpu/CMakeLists.txt2
-rw-r--r--source/blender/gpu/GPU_immediate_util.h59
-rw-r--r--source/blender/gpu/intern/gpu_immediate_util.c338
-rw-r--r--source/blender/windowmanager/intern/wm_gesture.c1
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c3
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c2
41 files changed, 428 insertions, 365 deletions
diff --git a/source/blender/draw/intern/draw_armature.c b/source/blender/draw/intern/draw_armature.c
index 4a700388a7c..1fb2eaffb79 100644
--- a/source/blender/draw/intern/draw_armature.c
+++ b/source/blender/draw/intern/draw_armature.c
@@ -51,7 +51,6 @@
#include "BKE_curve.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "ED_armature.h"
#include "ED_keyframes_draw.h"
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 166889037ef..fa0aeefc53c 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -78,7 +78,6 @@
#include "ED_keyframing.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c
index c5243b29255..cfc8ce81373 100644
--- a/source/blender/editors/armature/editarmature_sketch.c
+++ b/source/blender/editors/armature/editarmature_sketch.c
@@ -41,7 +41,6 @@
#include "ED_screen.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "ED_armature.h"
#include "armature_intern.h"
#include "BIF_retarget.h"
@@ -57,6 +56,7 @@
#include "GPU_matrix.h"
#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
typedef int (*GestureDetectFct)(bContext *, SK_Gesture *, SK_Sketch *);
typedef void (*GestureApplyFct)(bContext *, SK_Gesture *, SK_Sketch *);
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index cf7cfec5130..4c9bbe6e6bb 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -46,10 +46,10 @@
#include "ED_curve.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "curve_intern.h"
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 8bac80d6a3f..bfa5d089fb0 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -75,9 +75,8 @@
#include "ED_screen.h"
#include "ED_view3d.h"
-#include "BIF_glutil.h"
-
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "gpencil_intern.h"
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index ed1ffc13602..3e5d82f002c 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -72,6 +72,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "RNA_access.h"
#include "RNA_define.h"
diff --git a/source/blender/editors/include/BIF_glutil.h b/source/blender/editors/include/BIF_glutil.h
index 7db32eb39a0..0d90dab1f1e 100644
--- a/source/blender/editors/include/BIF_glutil.h
+++ b/source/blender/editors/include/BIF_glutil.h
@@ -48,94 +48,6 @@ struct ColorManagedDisplaySettings;
*/
/**
- * Draw a circle outline with the given \a radius.
- * The circle is centered at \a x, \a y and drawn in the XY plane.
- *
- * \param pos The vertex attribute number for position.
- * \param x Horizontal center.
- * \param y Vertical center.
- * \param radius The circle's radius.
- * \param nsegments The number of segments to use in drawing (more = smoother).
- */
-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_circle_wire_3d(unsigned pos, float x, float y, float radius, int nsegments);
-void imm_draw_circle_fill_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.
- *
- * \param pos The vertex attribute number for position.
- * \param x Horizontal center.
- * \param y Vertical center.
- * \param radius The circle's radius.
- * \param nsegments The number of segments to use in drawing (more = smoother).
- */
-void imm_draw_circle_fill(unsigned pos, float x, float y, float radius, int nsegments);
-
-/**
- * Draw a filled arc with the given inner and outer radius.
- * The circle is centered at \a x, \a y and drawn in the XY plane.
- *
- * \note Arguments are `gluPartialDisk` compatible.
- *
- * \param pos: The vertex attribute number for position.
- * \param x: Horizontal center.
- * \param y: Vertical center.
- * \param radius_inner: The inner circle's radius.
- * \param radius_outer: The outer circle's radius (can be zero).
- * \param nsegments: The number of segments to use in drawing (more = smoother).
- * \param start: Specifies the starting angle, in degrees, of the disk portion.
- * \param sweep: Specifies the sweep angle, in degrees, of the disk portion.
- */
-void imm_draw_disk_partial_fill(
- unsigned pos, float x, float y,
- float radius_inner, float radius_outer, int nsegments, float start, float sweep);
-
-/**
-* 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);
-
-/* 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);
-
-/**
-* Pack color into 3 bytes
-*
-* \param x color.
-*/
-void imm_cpack(unsigned int x);
-
-/**
-* Draw a cylinder. Replacement for gluCylinder.
-* _warning_ : Slow, better use it only if you no other choices.
-*
-* \param pos The vertex attribute number for position.
-* \param nor The vertex attribute number for normal.
-* \param base Specifies the radius of the cylinder at z = 0.
-* \param top Specifies the radius of the cylinder at z = height.
-* \param height Specifies the height of the cylinder.
-* \param slices Specifies the number of subdivisions around the z axis.
-* \param stacks Specifies the number of subdivisions along the z axis.
-*/
-void imm_draw_cylinder_fill_normal_3d(
- unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks);
-void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks);
-void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks);
-
-/**
* Returns a float value as obtained by glGetFloatv.
* The param must cause only one value to be gotten from GL.
*/
@@ -252,4 +164,3 @@ void glaDrawImBuf_glsl_ctx_clipping(const struct bContext *C,
void immDrawBorderCorners(unsigned int pos, const struct rcti *border, float zoomx, float zoomy);
#endif /* __BIF_GLUTIL_H__ */
-
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 6a568567b36..99db2747033 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -56,6 +56,7 @@
#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "UI_interface.h"
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 5924d600ac7..114200676ed 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -47,8 +47,6 @@
#include "RNA_access.h"
-#include "BIF_glutil.h"
-
#include "BLF_api.h"
#include "UI_interface.h"
@@ -58,6 +56,7 @@
#include "GPU_basic_shader.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#ifdef WITH_INPUT_IME
diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index a7fa5eb8138..fb4970b23b2 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -54,8 +54,6 @@
#include "BKE_editmesh_bvh.h"
#include "BKE_report.h"
-#include "BIF_glutil.h" /* for paint cursor */
-
#include "GPU_immediate.h"
#include "GPU_matrix.h"
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 711ee6c8861..6bf9b320e59 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -65,7 +65,6 @@
#include "BKE_pointcache.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "ED_object.h"
#include "ED_physics.h"
@@ -74,6 +73,7 @@
#include "ED_view3d.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 0d3a060b8ee..5c3c47ee376 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -58,10 +58,10 @@
#include "ED_space_api.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "GPU_draw.h"
-#include "BIF_glutil.h"
#include "BLF_api.h"
#include "IMB_imbuf.h"
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index 1852df66df7..57bff45fc6e 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -82,249 +82,6 @@ void set_inverted_drawing(int enable)
GL_TOGGLE(GL_DITHER, !enable);
}
-static void imm_draw_circle(PrimitiveType prim_type, unsigned pos, float x, float y, float rad, int nsegments)
-{
- immBegin(prim_type, nsegments);
- for (int i = 0; i < nsegments; ++i) {
- float angle = 2 * M_PI * ((float)i / (float)nsegments);
- immVertex2f(pos, x + rad * cosf(angle), y + rad * sinf(angle));
- }
- immEnd();
-}
-
-void imm_draw_lined_circle(unsigned pos, float x, float y, float rad, int nsegments)
-{
- imm_draw_circle(PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
-}
-
-void imm_draw_circle_fill(unsigned pos, float x, float y, float rad, int nsegments)
-{
- imm_draw_circle(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
-}
-
-/**
- * \note We could have `imm_draw_lined_disk_partial` but currently there is no need.
- */
-static void imm_draw_disk_partial(
- PrimitiveType prim_type, unsigned pos, float x, float y,
- float rad_inner, float rad_outer, int nsegments, float start, float sweep)
-{
- /* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
- const float angle_start = -(DEG2RADF(start)) + (M_PI / 2);
- const float angle_end = -(DEG2RADF(sweep) - angle_start);
- nsegments += 1;
- immBegin(prim_type, nsegments * 2);
- for (int i = 0; i < nsegments; ++i) {
- const float angle = interpf(angle_start, angle_end, ((float)i / (float)(nsegments - 1)));
- const float angle_sin = sinf(angle);
- const float angle_cos = cosf(angle);
- immVertex2f(pos, x + rad_inner * angle_cos, y + rad_inner * angle_sin);
- immVertex2f(pos, x + rad_outer * angle_cos, y + rad_outer * angle_sin);
- }
- immEnd();
-}
-
-/**
- * Replacement for gluPartialDisk, (without 'loops' argument).
- */
-void imm_draw_disk_partial_fill(
- unsigned pos, float x, float y,
- float rad_inner, float rad_outer, int nsegments, float start, float sweep)
-{
- imm_draw_disk_partial(PRIM_TRIANGLE_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
-}
-
-static void imm_draw_circle_3D(
- PrimitiveType prim_type, unsigned pos, float x, float y,
- float rad, int nsegments)
-{
- immBegin(prim_type, 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_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments)
-{
- imm_draw_circle_3D(PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
-}
-
-void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments)
-{
- imm_draw_circle_3D(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
-}
-
-void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2)
-{
- immBegin(PRIM_LINE_LOOP, 4);
- immVertex2f(pos, x1, y1);
- immVertex2f(pos, x1, y2);
- immVertex2f(pos, x2, y2);
- immVertex2f(pos, x2, y1);
- 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(PRIM_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_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),
- (((x) >> 8) & 0xFF),
- (((x) >> 16) & 0xFF));
-}
-
-void imm_draw_cylinder_fill_normal_3d(
- unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
-{
- immBegin(GL_TRIANGLES, 6 * slices * stacks);
- for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
- const float cos1 = cosf(angle1);
- const float sin1 = sinf(angle1);
- const float cos2 = cosf(angle2);
- const float sin2 = sinf(angle2);
-
- for (int j = 0; j < stacks; ++j) {
- float fac1 = (float)j / (float)stacks;
- float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
- float h1 = height * ((float)j / (float)stacks);
- float h2 = height * ((float)(j + 1) / (float)stacks);
-
- float v1[3] = {r1 *cos2, r1 * sin2, h1};
- float v2[3] = {r2 *cos2, r2 * sin2, h2};
- float v3[3] = {r2 *cos1, r2 * sin1, h2};
- float v4[3] = {r1 *cos1, r1 * sin1, h1};
- float n1[3], n2[3];
-
- /* calc normals */
- sub_v3_v3v3(n1, v2, v1);
- normalize_v3(n1);
- n1[0] = cos1; n1[1] = sin1; n1[2] = 1 - n1[2];
-
- sub_v3_v3v3(n2, v3, v4);
- normalize_v3(n2);
- n2[0] = cos2; n2[1] = sin2; n2[2] = 1 - n2[2];
-
- /* first tri */
- immAttrib3fv(nor, n2);
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- immAttrib3fv(nor, n1);
- immVertex3fv(pos, v3);
-
- /* second tri */
- immVertex3fv(pos, v3);
- immVertex3fv(pos, v4);
- immAttrib3fv(nor, n2);
- immVertex3fv(pos, v1);
- }
- }
- immEnd();
-}
-
-void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
-{
- immBegin(GL_LINES, 6 * slices * stacks);
- for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
- const float cos1 = cosf(angle1);
- const float sin1 = sinf(angle1);
- const float cos2 = cosf(angle2);
- const float sin2 = sinf(angle2);
-
- for (int j = 0; j < stacks; ++j) {
- float fac1 = (float)j / (float)stacks;
- float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
- float h1 = height * ((float)j / (float)stacks);
- float h2 = height * ((float)(j + 1) / (float)stacks);
-
- float v1[3] = {r1 * cos2, r1 * sin2, h1};
- float v2[3] = {r2 * cos2, r2 * sin2, h2};
- float v3[3] = {r2 * cos1, r2 * sin1, h2};
- float v4[3] = {r1 * cos1, r1 * sin1, h1};
-
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
-
- immVertex3fv(pos, v2);
- immVertex3fv(pos, v3);
-
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v4);
- }
- }
- immEnd();
-}
-
-void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
-{
- immBegin(GL_TRIANGLES, 6 * slices * stacks);
- for (int i = 0; i < slices; ++i) {
- const float angle1 = 2 * M_PI * ((float)i / (float)slices);
- const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
- const float cos1 = cosf(angle1);
- const float sin1 = sinf(angle1);
- const float cos2 = cosf(angle2);
- const float sin2 = sinf(angle2);
-
- for (int j = 0; j < stacks; ++j) {
- float fac1 = (float)j / (float)stacks;
- float fac2 = (float)(j + 1) / (float)stacks;
- float r1 = base * (1.f - fac1) + top * fac1;
- float r2 = base * (1.f - fac2) + top * fac2;
- float h1 = height * ((float)j / (float)stacks);
- float h2 = height * ((float)(j + 1) / (float)stacks);
-
- float v1[3] = {r1 * cos2, r1 * sin2, h1};
- float v2[3] = {r2 * cos2, r2 * sin2, h2};
- float v3[3] = {r2 * cos1, r2 * sin1, h2};
- float v4[3] = {r1 * cos1, r1 * sin1, h1};
-
- /* first tri */
- immVertex3fv(pos, v1);
- immVertex3fv(pos, v2);
- immVertex3fv(pos, v3);
-
- /* second tri */
- immVertex3fv(pos, v3);
- immVertex3fv(pos, v4);
- immVertex3fv(pos, v1);
- }
- }
- immEnd();
-}
-
float glaGetOneFloat(int param)
{
GLfloat v;
@@ -927,6 +684,8 @@ void cpack(unsigned int x)
(((x) >> 16) & 0xFF));
}
+/* don't move to GPU_immediate_util.h because this uses user-prefs
+ * and isn't very low level */
void immDrawBorderCorners(unsigned int pos, const rcti *border, float zoomx, float zoomy)
{
float delta_x = 4.0f * UI_DPI_FAC / zoomx;
diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c
index e5fc89fccbc..25255c79390 100644
--- a/source/blender/editors/screen/screendump.c
+++ b/source/blender/editors/screen/screendump.c
@@ -54,9 +54,9 @@
#include "BKE_writeavi.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "RNA_access.h"
#include "RNA_define.h"
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 0e18bddc45f..e97f457494c 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -53,13 +53,12 @@
#include "WM_api.h"
-#include "BIF_glutil.h"
-
#include "IMB_imbuf_types.h"
#include "ED_view3d.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "GPU_basic_shader.h"
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 5b5d91e8566..d7c3b7377da 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -52,8 +52,6 @@
#include "BKE_paint.h"
#include "BKE_subsurf.h"
-#include "BIF_glutil.h"
-
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 7ea1cac045c..234220cacc8 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -81,7 +81,6 @@
#include "GPU_immediate.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "IMB_colormanagement.h"
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index b4938e0f7d8..1ac40b0354e 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -35,8 +35,6 @@
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
-#include "BIF_glutil.h"
-
#include "BLI_bitmap_draw_2d.h"
#include "BLI_math_matrix.h"
#include "BLI_math_geom.h"
diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c
index d7a4ea9c950..578b4f8a234 100644
--- a/source/blender/editors/sculpt_paint/sculpt_uv.c
+++ b/source/blender/editors/sculpt_paint/sculpt_uv.c
@@ -56,6 +56,7 @@
#include "ED_mesh.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -66,8 +67,6 @@
#include "paint_intern.h"
#include "uvedit_intern.h"
-#include "BIF_glutil.h"
-
#include "UI_view2d.h"
#define MARK_BOUNDARY 1
diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c
index a76731da9d5..ef7b88cfcdf 100644
--- a/source/blender/editors/space_clip/clip_draw.c
+++ b/source/blender/editors/space_clip/clip_draw.c
@@ -58,6 +58,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c
index a9d02018f49..b6802d9205b 100644
--- a/source/blender/editors/space_clip/clip_graph_draw.c
+++ b/source/blender/editors/space_clip/clip_graph_draw.c
@@ -42,9 +42,8 @@
#include "ED_screen.h"
#include "ED_clip.h"
-#include "BIF_glutil.h"
-
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index a1bd1f25427..dc67282f8c2 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -71,6 +71,7 @@
#include "WM_types.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "filelist.h"
diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c
index 8d55c38f9e4..f63b0d51e00 100644
--- a/source/blender/editors/space_image/image_draw.c
+++ b/source/blender/editors/space_image/image_draw.c
@@ -63,6 +63,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "BLF_api.h"
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index fa23f8f77b4..962ba7b78ce 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -55,6 +55,7 @@
#include "GPU_draw.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "WM_api.h"
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 1fea1a98e94..44cb1d61f14 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -58,6 +58,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "ED_anim_api.h"
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c
index 17b30fd8bae..22ab9b73b3e 100644
--- a/source/blender/editors/space_time/space_time.c
+++ b/source/blender/editors/space_time/space_time.c
@@ -60,7 +60,6 @@
#include "WM_types.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "UI_resources.h"
#include "UI_view2d.h"
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 2e69cfcc901..3b2791b7a62 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -63,6 +63,7 @@
#include "GPU_basic_shader.h"
#include "GPU_batch.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "UI_resources.h"
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index d6681ac932d..fc28baf5160 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -92,6 +92,7 @@
#include "GPU_basic_shader.h"
#include "GPU_shader.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_batch.h"
#include "GPU_matrix.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 9fac823a84f..a2b59e9021d 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -72,6 +72,7 @@
#include "GPU_matrix.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_material.h"
#include "GPU_viewport.h"
diff --git a/source/blender/editors/space_view3d/view3d_draw_legacy.c b/source/blender/editors/space_view3d/view3d_draw_legacy.c
index edf2273cd35..7070cadb414 100644
--- a/source/blender/editors/space_view3d/view3d_draw_legacy.c
+++ b/source/blender/editors/space_view3d/view3d_draw_legacy.c
@@ -102,6 +102,7 @@
#include "GPU_compositing.h"
#include "GPU_extensions.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_select.h"
#include "GPU_matrix.h"
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index f220d97077b..46592194035 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -60,9 +60,7 @@
#include "BKE_action.h"
#include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */
-
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_view3d/view3d_ruler.c b/source/blender/editors/space_view3d/view3d_ruler.c
index 4a4d008f779..cecda174614 100644
--- a/source/blender/editors/space_view3d/view3d_ruler.c
+++ b/source/blender/editors/space_view3d/view3d_ruler.c
@@ -44,6 +44,7 @@
#include "BIF_gl.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index 76f8db1cec5..e22e89dff12 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -74,9 +74,6 @@
#include "BKE_tracking.h"
#include "BKE_utildefines.h"
-
-#include "BIF_glutil.h"
-
#include "WM_api.h"
#include "WM_types.h"
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index bbf4ebb4eb1..346b02dedcc 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -67,6 +67,7 @@
#include "BIF_glutil.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "ED_image.h"
diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c
index d8654b9d18a..b99e878c790 100644
--- a/source/blender/editors/uvedit/uvedit_draw.c
+++ b/source/blender/editors/uvedit/uvedit_draw.c
@@ -58,6 +58,7 @@
#include "DEG_depsgraph.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "ED_image.h"
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index f0ef87c5f28..00b58baabc9 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -60,6 +60,7 @@ set(SRC
intern/gpu_extensions.c
intern/gpu_framebuffer.c
intern/gpu_immediate.c
+ intern/gpu_immediate_util.c
intern/gpu_init_exit.c
intern/gpu_lamp.c
intern/gpu_material.c
@@ -104,6 +105,7 @@ set(SRC
GPU_framebuffer.h
GPU_glew.h
GPU_immediate.h
+ GPU_immediate_util.h
GPU_init_exit.h
GPU_material.h
GPU_matrix.h
diff --git a/source/blender/gpu/GPU_immediate_util.h b/source/blender/gpu/GPU_immediate_util.h
new file mode 100644
index 00000000000..77c5701480b
--- /dev/null
+++ b/source/blender/gpu/GPU_immediate_util.h
@@ -0,0 +1,59 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file GPU_immediate_util.h
+ * \ingroup gpu
+ *
+ * Utility drawing functions (rough equivalent to OpenGL's GLU)
+ */
+
+#ifndef __GPU_IMMEDIATE_UTIL_H__
+#define __GPU_IMMEDIATE_UTIL_H__
+
+void imm_cpack(unsigned int x);
+
+void imm_draw_lined_circle(unsigned pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_fill(unsigned pos, float x, float y, float radius, int nsegments);
+
+/* use this version when VertexFormat has a vec3 position */
+void imm_draw_circle_wire_3d(unsigned pos, float x, float y, float radius, int nsegments);
+void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float radius, int nsegments);
+
+void imm_draw_disk_partial_fill(
+ unsigned pos, float x, float y,
+ float radius_inner, float radius_outer, int nsegments, float start, float sweep);
+
+void imm_draw_line_box(unsigned pos, float x1, float y1, float x2, float y2);
+
+void imm_draw_line_box_3d(unsigned pos, float x1, float y1, float x2, float y2);
+
+void imm_draw_checker_box(float x1, float y1, float x2, float y2);
+
+void imm_draw_cylinder_fill_normal_3d(
+ unsigned int pos, unsigned int nor, float base, float top, float height,
+ int slices, int stacks);
+void imm_draw_cylinder_wire_3d(
+ unsigned int pos, float base, float top, float height,
+ int slices, int stacks);
+void imm_draw_cylinder_fill_3d(
+ unsigned int pos, float base, float top, float height,
+ int slices, int stacks);
+
+#endif /* __GPU_IMMEDIATE_UTIL_H__ */
diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c
new file mode 100644
index 00000000000..cf23385ac04
--- /dev/null
+++ b/source/blender/gpu/intern/gpu_immediate_util.c
@@ -0,0 +1,338 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file source/blender/gpu/intern/gpu_immediate_util.c
+ * \ingroup gpu
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "BLI_utildefines.h"
+#include "BLI_math.h"
+
+#include "GPU_basic_shader.h"
+#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
+#include "GPU_matrix.h"
+
+/**
+* Pack color into 3 bytes
+*
+* \param x color.
+*/
+void imm_cpack(unsigned int x)
+{
+ immUniformColor3ub(((x) & 0xFF),
+ (((x) >> 8) & 0xFF),
+ (((x) >> 16) & 0xFF));
+}
+
+static void imm_draw_circle(PrimitiveType prim_type, unsigned pos, float x, float y, float rad, int nsegments)
+{
+ immBegin(prim_type, nsegments);
+ for (int i = 0; i < nsegments; ++i) {
+ float angle = 2 * M_PI * ((float)i / (float)nsegments);
+ immVertex2f(pos, x + rad * cosf(angle), y + rad * sinf(angle));
+ }
+ immEnd();
+}
+
+/**
+ * Draw a circle outline with the given \a radius.
+ * The circle is centered at \a x, \a y and drawn in the XY plane.
+ *
+ * \param pos The vertex attribute number for position.
+ * \param x Horizontal center.
+ * \param y Vertical center.
+ * \param radius The circle's radius.
+ * \param nsegments The number of segments to use in drawing (more = smoother).
+ */
+void imm_draw_lined_circle(unsigned pos, float x, float y, float rad, int nsegments)
+{
+ imm_draw_circle(PRIM_LINE_LOOP, pos, x, y, rad, 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.
+ *
+ * \param pos The vertex attribute number for position.
+ * \param x Horizontal center.
+ * \param y Vertical center.
+ * \param radius The circle's radius.
+ * \param nsegments The number of segments to use in drawing (more = smoother).
+ */
+void imm_draw_circle_fill(unsigned pos, float x, float y, float rad, int nsegments)
+{
+ imm_draw_circle(PRIM_TRIANGLE_FAN, pos, x, y, rad, nsegments);
+}
+
+/**
+ * \note We could have `imm_draw_lined_disk_partial` but currently there is no need.
+ */
+static void imm_draw_disk_partial(
+ PrimitiveType prim_type, unsigned pos, float x, float y,
+ float rad_inner, float rad_outer, int nsegments, float start, float sweep)
+{
+ /* shift & reverse angle, increase 'nsegments' to match gluPartialDisk */
+ const float angle_start = -(DEG2RADF(start)) + (M_PI / 2);
+ const float angle_end = -(DEG2RADF(sweep) - angle_start);
+ nsegments += 1;
+ immBegin(prim_type, nsegments * 2);
+ for (int i = 0; i < nsegments; ++i) {
+ const float angle = interpf(angle_start, angle_end, ((float)i / (float)(nsegments - 1)));
+ const float angle_sin = sinf(angle);
+ const float angle_cos = cosf(angle);
+ immVertex2f(pos, x + rad_inner * angle_cos, y + rad_inner * angle_sin);
+ immVertex2f(pos, x + rad_outer * angle_cos, y + rad_outer * angle_sin);
+ }
+ immEnd();
+}
+
+/**
+ * Draw a filled arc with the given inner and outer radius.
+ * The circle is centered at \a x, \a y and drawn in the XY plane.
+ *
+ * \note Arguments are `gluPartialDisk` compatible.
+ *
+ * \param pos: The vertex attribute number for position.
+ * \param x: Horizontal center.
+ * \param y: Vertical center.
+ * \param radius_inner: The inner circle's radius.
+ * \param radius_outer: The outer circle's radius (can be zero).
+ * \param nsegments: The number of segments to use in drawing (more = smoother).
+ * \param start: Specifies the starting angle, in degrees, of the disk portion.
+ * \param sweep: Specifies the sweep angle, in degrees, of the disk portion.
+ */
+void imm_draw_disk_partial_fill(
+ unsigned pos, float x, float y,
+ float rad_inner, float rad_outer, int nsegments, float start, float sweep)
+{
+ imm_draw_disk_partial(PRIM_TRIANGLE_STRIP, pos, x, y, rad_inner, rad_outer, nsegments, start, sweep);
+}
+
+static void imm_draw_circle_3D(
+ PrimitiveType prim_type, unsigned pos, float x, float y,
+ float rad, int nsegments)
+{
+ immBegin(prim_type, 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_circle_wire_3d(unsigned pos, float x, float y, float rad, int nsegments)
+{
+ imm_draw_circle_3D(PRIM_LINE_LOOP, pos, x, y, rad, nsegments);
+}
+
+void imm_draw_circle_fill_3d(unsigned pos, float x, float y, float rad, int nsegments)
+{
+ imm_draw_circle_3D(PRIM_TRIANGLE_FAN, pos, x, y, rad, 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)
+{
+ immBegin(PRIM_LINE_LOOP, 4);
+ immVertex2f(pos, x1, y1);
+ immVertex2f(pos, x1, y2);
+ immVertex2f(pos, x2, y2);
+ immVertex2f(pos, x2, y1);
+ 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(PRIM_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();
+}
+
+/**
+ * Draw a standard checkerboard to indicate transparent backgrounds.
+ */
+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();
+}
+
+/**
+* Draw a cylinder. Replacement for gluCylinder.
+* _warning_ : Slow, better use it only if you no other choices.
+*
+* \param pos The vertex attribute number for position.
+* \param nor The vertex attribute number for normal.
+* \param base Specifies the radius of the cylinder at z = 0.
+* \param top Specifies the radius of the cylinder at z = height.
+* \param height Specifies the height of the cylinder.
+* \param slices Specifies the number of subdivisions around the z axis.
+* \param stacks Specifies the number of subdivisions along the z axis.
+*/
+void imm_draw_cylinder_fill_normal_3d(
+ unsigned int pos, unsigned int nor, float base, float top, float height, int slices, int stacks)
+{
+ immBegin(GL_TRIANGLES, 6 * slices * stacks);
+ for (int i = 0; i < slices; ++i) {
+ const float angle1 = 2 * M_PI * ((float)i / (float)slices);
+ const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float cos1 = cosf(angle1);
+ const float sin1 = sinf(angle1);
+ const float cos2 = cosf(angle2);
+ const float sin2 = sinf(angle2);
+
+ for (int j = 0; j < stacks; ++j) {
+ float fac1 = (float)j / (float)stacks;
+ float fac2 = (float)(j + 1) / (float)stacks;
+ float r1 = base * (1.f - fac1) + top * fac1;
+ float r2 = base * (1.f - fac2) + top * fac2;
+ float h1 = height * ((float)j / (float)stacks);
+ float h2 = height * ((float)(j + 1) / (float)stacks);
+
+ float v1[3] = {r1 *cos2, r1 * sin2, h1};
+ float v2[3] = {r2 *cos2, r2 * sin2, h2};
+ float v3[3] = {r2 *cos1, r2 * sin1, h2};
+ float v4[3] = {r1 *cos1, r1 * sin1, h1};
+ float n1[3], n2[3];
+
+ /* calc normals */
+ sub_v3_v3v3(n1, v2, v1);
+ normalize_v3(n1);
+ n1[0] = cos1; n1[1] = sin1; n1[2] = 1 - n1[2];
+
+ sub_v3_v3v3(n2, v3, v4);
+ normalize_v3(n2);
+ n2[0] = cos2; n2[1] = sin2; n2[2] = 1 - n2[2];
+
+ /* first tri */
+ immAttrib3fv(nor, n2);
+ immVertex3fv(pos, v1);
+ immVertex3fv(pos, v2);
+ immAttrib3fv(nor, n1);
+ immVertex3fv(pos, v3);
+
+ /* second tri */
+ immVertex3fv(pos, v3);
+ immVertex3fv(pos, v4);
+ immAttrib3fv(nor, n2);
+ immVertex3fv(pos, v1);
+ }
+ }
+ immEnd();
+}
+
+void imm_draw_cylinder_wire_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
+{
+ immBegin(GL_LINES, 6 * slices * stacks);
+ for (int i = 0; i < slices; ++i) {
+ const float angle1 = 2 * M_PI * ((float)i / (float)slices);
+ const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float cos1 = cosf(angle1);
+ const float sin1 = sinf(angle1);
+ const float cos2 = cosf(angle2);
+ const float sin2 = sinf(angle2);
+
+ for (int j = 0; j < stacks; ++j) {
+ float fac1 = (float)j / (float)stacks;
+ float fac2 = (float)(j + 1) / (float)stacks;
+ float r1 = base * (1.f - fac1) + top * fac1;
+ float r2 = base * (1.f - fac2) + top * fac2;
+ float h1 = height * ((float)j / (float)stacks);
+ float h2 = height * ((float)(j + 1) / (float)stacks);
+
+ float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ float v4[3] = {r1 * cos1, r1 * sin1, h1};
+
+ immVertex3fv(pos, v1);
+ immVertex3fv(pos, v2);
+
+ immVertex3fv(pos, v2);
+ immVertex3fv(pos, v3);
+
+ immVertex3fv(pos, v1);
+ immVertex3fv(pos, v4);
+ }
+ }
+ immEnd();
+}
+
+void imm_draw_cylinder_fill_3d(unsigned int pos, float base, float top, float height, int slices, int stacks)
+{
+ immBegin(GL_TRIANGLES, 6 * slices * stacks);
+ for (int i = 0; i < slices; ++i) {
+ const float angle1 = 2 * M_PI * ((float)i / (float)slices);
+ const float angle2 = 2 * M_PI * ((float)(i + 1) / (float)slices);
+ const float cos1 = cosf(angle1);
+ const float sin1 = sinf(angle1);
+ const float cos2 = cosf(angle2);
+ const float sin2 = sinf(angle2);
+
+ for (int j = 0; j < stacks; ++j) {
+ float fac1 = (float)j / (float)stacks;
+ float fac2 = (float)(j + 1) / (float)stacks;
+ float r1 = base * (1.f - fac1) + top * fac1;
+ float r2 = base * (1.f - fac2) + top * fac2;
+ float h1 = height * ((float)j / (float)stacks);
+ float h2 = height * ((float)(j + 1) / (float)stacks);
+
+ float v1[3] = {r1 * cos2, r1 * sin2, h1};
+ float v2[3] = {r2 * cos2, r2 * sin2, h2};
+ float v3[3] = {r2 * cos1, r2 * sin1, h2};
+ float v4[3] = {r1 * cos1, r1 * sin1, h1};
+
+ /* first tri */
+ immVertex3fv(pos, v1);
+ immVertex3fv(pos, v2);
+ immVertex3fv(pos, v3);
+
+ /* second tri */
+ immVertex3fv(pos, v3);
+ immVertex3fv(pos, v4);
+ immVertex3fv(pos, v1);
+ }
+ }
+ immEnd();
+}
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index 2febe98ee7e..ace081623a7 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -53,6 +53,7 @@
#include "wm_draw.h"
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "BIF_glutil.h"
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 45b4c60f7f0..495d72a45c3 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -88,9 +88,8 @@
#include "BLF_api.h"
-#include "BIF_glutil.h" /* for paint cursor */
-
#include "GPU_immediate.h"
+#include "GPU_immediate_util.h"
#include "GPU_matrix.h"
#include "IMB_imbuf_types.h"
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 46c7599ec56..afe46f6c336 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -62,9 +62,9 @@
#include "BKE_image.h"
#include "BIF_gl.h"
-#include "BIF_glutil.h"
#include "GPU_matrix.h"
+#include "GPU_immediate_util.h"
#include "DNA_scene_types.h"
#include "ED_datafiles.h" /* for fonts */