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:
authorKhanh Ha <khanhhh89@gmail.com>2017-03-08 06:12:39 +0300
committerMike Erwin <significant.bit@gmail.com>2017-03-08 06:14:27 +0300
commit1345d298068fb8ee988211a2b0063ab6685a77c8 (patch)
treeb5e4c717009994fc6d621baa637e166e2df6296e /source/blender/editors/screen/glutil.c
parent696bb47c6eba9a6237e44e000803ffb505fb5a38 (diff)
OpenGL: convert editarmarture_sketch to new imm mode
Part of T49043, T49042 Reviewers: fclem, merwin Tags: #bf_blender_2.8 Differential Revision: https://developer.blender.org/D2548
Diffstat (limited to 'source/blender/editors/screen/glutil.c')
-rw-r--r--source/blender/editors/screen/glutil.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c
index ed8ac261c4a..f1ad04c0982 100644
--- a/source/blender/editors/screen/glutil.c
+++ b/source/blender/editors/screen/glutil.c
@@ -252,6 +252,44 @@ void imm_cylinder_wire(unsigned int pos, float base, float top, float height, in
immEnd();
}
+void imm_cylinder(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;