fix use of uninitialized variable
[blender.git] / source / blender / windowmanager / manipulators / intern / manipulator_library / primitive_manipulator.c
index 5a0700359d851ac667a4f74b113faa385405630b..9755d090e8b05a4dc21e7103ee6f1de241aab1d5 100644 (file)
@@ -38,6 +38,8 @@
 #include "DNA_view3d_types.h"
 #include "DNA_manipulator_types.h"
 
+#include "GPU_immediate.h"
+#include "GPU_matrix.h"
 #include "GPU_select.h"
 
 #include "MEM_guardedalloc.h"
@@ -82,20 +84,20 @@ static void manipulator_primitive_draw_geom(
         const float col_inner[4], const float col_outer[4], const int style)
 {
        float (*verts)[3];
-       float vert_count;
+       unsigned int vert_count = 0;
 
        if (style == MANIPULATOR_PRIMITIVE_STYLE_PLANE) {
                verts = verts_plane;
                vert_count = ARRAY_SIZE(verts_plane);
        }
 
-       glEnableClientState(GL_VERTEX_ARRAY);
-       glVertexPointer(3, GL_FLOAT, 0, verts);
-       glColor4fv(col_inner);
-       glDrawArrays(GL_QUADS, 0, vert_count);
-       glColor4fv(col_outer);
-       glDrawArrays(GL_LINE_LOOP, 0, vert_count);
-       glDisableClientState(GL_VERTEX_ARRAY);
+       if (vert_count > 0) {
+               unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
+               immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+               wm_manipulator_vec_draw(col_inner, verts, vert_count, pos, PRIM_TRIANGLE_FAN);
+               wm_manipulator_vec_draw(col_outer, verts, vert_count, pos, PRIM_LINE_LOOP);
+               immUnbindProgram();
+       }
 }
 
 static void manipulator_primitive_draw_intern(
@@ -120,19 +122,19 @@ static void manipulator_primitive_draw_intern(
        copy_v3_v3(mat[3], prim->manipulator.origin);
        mul_mat3_m4_fl(mat, prim->manipulator.scale);
 
-       glPushMatrix();
-       glMultMatrixf(mat);
+       gpuPushMatrix();
+       gpuMultMatrix3D(mat);
 
        manipulator_color_get(&prim->manipulator, highlight, col_outer);
        copy_v4_v4(col_inner, col_outer);
        col_inner[3] *= 0.5f;
 
        glEnable(GL_BLEND);
-       glTranslatef(UNPACK3(prim->manipulator.offset));
+       gpuTranslate3fv(prim->manipulator.offset);
        manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
        glDisable(GL_BLEND);
 
-       glPopMatrix();
+       gpuPopMatrix();
 
        if (prim->manipulator.interaction_data) {
                ManipulatorInteraction *inter = prim->manipulator.interaction_data;
@@ -145,15 +147,15 @@ static void manipulator_primitive_draw_intern(
                copy_v3_v3(mat[3], inter->init_origin);
                mul_mat3_m4_fl(mat, inter->init_scale);
 
-               glPushMatrix();
-               glMultMatrixf(mat);
+               gpuPushMatrix();
+               gpuMultMatrix3D(mat);
 
                glEnable(GL_BLEND);
-               glTranslatef(UNPACK3(prim->manipulator.offset));
+               gpuTranslate3fv(prim->manipulator.offset);
                manipulator_primitive_draw_geom(col_inner, col_outer, prim->style);
                glDisable(GL_BLEND);
 
-               glPopMatrix();
+               gpuPopMatrix();
        }
 }