cleanup use of GPU matrix API
Take advantage of 2D functions, rotation about the X Y or Z axis, uniform scale factors. We no longer need to call gpuMatrixBegin_legacy() before using the new API locally in functions. related to T49450
This commit is contained in:
parent
c2366009c0
commit
09ad684249
|
@ -552,7 +552,7 @@ static void blf_draw_gl__start(FontBLF *font)
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
if (font->flags & BLF_MATRIX)
|
||||
gpuMultMatrix3D(font->m);
|
||||
|
@ -563,7 +563,7 @@ static void blf_draw_gl__start(FontBLF *font)
|
|||
gpuScale3fv(font->aspect);
|
||||
|
||||
if (font->flags & BLF_ROTATION) /* radians -> degrees */
|
||||
gpuRotateAxis(RAD2DEG(font->angle), 'Z');
|
||||
gpuRotateAxis(RAD2DEG(font->angle), 'Z'); /* TODO: use gpuRotate2D here? */
|
||||
|
||||
#ifndef BLF_STANDALONE
|
||||
VertexFormat *format = immVertexFormat();
|
||||
|
@ -584,7 +584,7 @@ static void blf_draw_gl__start(FontBLF *font)
|
|||
|
||||
static void blf_draw_gl__end(void)
|
||||
{
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
|
||||
#ifndef BLF_STANDALONE
|
||||
immUnbindProgram();
|
||||
|
|
|
@ -1988,8 +1988,6 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
|
|||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
if (with_names) {
|
||||
int id;
|
||||
for (id = 1, stk = sketch->strokes.first; stk; id++, stk = stk->next) {
|
||||
|
@ -2058,8 +2056,6 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch,
|
|||
float gesture_rgb[3] = { 0, 0.5, 1 };
|
||||
sk_drawStroke(sketch->gesture, -1, gesture_rgb, -1, -1);
|
||||
}
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static int sk_finish_stroke(bContext *C, SK_Sketch *sketch)
|
||||
|
|
|
@ -475,7 +475,6 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
|||
Batch_Uniform3fv(sphere, "color", color);
|
||||
|
||||
/* scale to edit-mode space */
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix3D(obedit->obmat);
|
||||
|
||||
|
@ -489,15 +488,15 @@ static void curve_draw_stroke_3d(const struct bContext *UNUSED(C), ARegion *UNUS
|
|||
|
||||
const float radius = stroke_elem_radius(cdd, selem);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuScaleUniform(radius);
|
||||
Batch_draw(sphere);
|
||||
gpuScaleUniform(1.0f / radius);
|
||||
gpuPopMatrix();
|
||||
|
||||
location_prev = selem->location_local;
|
||||
}
|
||||
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
if (stroke_len > 1) {
|
||||
|
|
|
@ -930,7 +930,6 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
}
|
||||
|
||||
if (scopes->ok && scopes->waveform_1 != NULL) {
|
||||
gpuMatrixBegin3D_legacy();
|
||||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glPointSize(1.0);
|
||||
|
||||
|
@ -939,8 +938,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
float col[3] = {alpha, alpha, alpha};
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(rect.xmin, yofs, 0.0f);
|
||||
gpuScale3f(w, h, 0.0f);
|
||||
gpuTranslate2f(rect.xmin, yofs);
|
||||
gpuScale2f(w, h);
|
||||
|
||||
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col);
|
||||
|
||||
|
@ -961,8 +960,8 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
/* RGB (3 channel) */
|
||||
else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) {
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(rect.xmin, yofs, 0.0f);
|
||||
gpuScale3f(w, h, 0.0f);
|
||||
gpuTranslate2f(rect.xmin, yofs);
|
||||
gpuScale2f(w, h);
|
||||
|
||||
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]);
|
||||
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]);
|
||||
|
@ -981,15 +980,15 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(rect.xmin, yofs, 0.0f);
|
||||
gpuScale3f(w3, h, 0.0f);
|
||||
gpuTranslate2f(rect.xmin, yofs);
|
||||
gpuScale2f(w3, h);
|
||||
|
||||
waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]);
|
||||
|
||||
gpuTranslate3f(1.0f, 0.0f, 0.0f);
|
||||
gpuTranslate2f(1.0f, 0.0f);
|
||||
waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]);
|
||||
|
||||
gpuTranslate3f(1.0f, 0.0f, 0.0f);
|
||||
gpuTranslate2f(1.0f, 0.0f);
|
||||
waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]);
|
||||
|
||||
gpuPopMatrix();
|
||||
|
@ -1013,7 +1012,6 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol),
|
|||
immEnd();
|
||||
}
|
||||
}
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
@ -1174,15 +1172,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco
|
|||
glBlendFunc(GL_ONE, GL_ONE);
|
||||
glPointSize(1.0);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(centerx, centery, 0.0f);
|
||||
gpuScale3f(diam, diam, 0.0f);
|
||||
gpuTranslate2f(centerx, centery);
|
||||
gpuScaleUniform(diam);
|
||||
|
||||
waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col);
|
||||
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
immUnbindProgram();
|
||||
|
@ -1454,7 +1450,6 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
|||
ui_but_v3_get(but, light);
|
||||
|
||||
/* transform to button */
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect))
|
||||
|
@ -1462,8 +1457,8 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
|||
else
|
||||
size = 0.5f * BLI_rcti_size_y(rect);
|
||||
|
||||
gpuTranslate3f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect), 0.0f);
|
||||
gpuScale3f(size, size, size);
|
||||
gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect));
|
||||
gpuScaleUniform(size);
|
||||
|
||||
Batch *sphere = Batch_get_sphere(2);
|
||||
Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
|
||||
|
@ -1488,7 +1483,6 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect)
|
|||
|
||||
/* matrix after circle */
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
@ -1801,7 +1795,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
}
|
||||
|
||||
if (!ok && scopes->track_preview) {
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
/* draw content of pattern area */
|
||||
|
@ -1821,7 +1814,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
immDrawPixelsTex(rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL);
|
||||
|
||||
/* draw cross for pixel position */
|
||||
gpuTranslate3f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1], 0.0f);
|
||||
gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]);
|
||||
glScissor(ar->winrct.xmin + rect.xmin,
|
||||
ar->winrct.ymin + rect.ymin,
|
||||
BLI_rctf_size_x(&rect),
|
||||
|
@ -1860,7 +1853,6 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
|||
}
|
||||
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
|
||||
ok = true;
|
||||
}
|
||||
|
|
|
@ -765,11 +765,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
|||
|
||||
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
for (j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
gpuTranslate3f(jit[j][0], jit[j][1], 0.0f);
|
||||
gpuTranslate2fv(jit[j]);
|
||||
|
||||
/* outline */
|
||||
immUniformColor4ubv(tcol);
|
||||
|
@ -784,11 +782,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
|||
}
|
||||
}
|
||||
|
||||
gpuTranslate3f(-jit[j][0], -jit[j][1], 0.0f);
|
||||
gpuTranslate2f(-jit[j][0], -jit[j][1]);
|
||||
}
|
||||
immUnbindProgram();
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
/* decoration */
|
||||
|
@ -802,11 +798,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
|||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformColor4ubv(tcol);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
/* for each AA step */
|
||||
for (j = 0; j < WIDGET_AA_JITTER; j++) {
|
||||
gpuTranslate3f(jit[j][0], jit[j][1], 0.0f);
|
||||
gpuTranslate2fv(jit[j]);
|
||||
|
||||
if (wtb->tria1.tot)
|
||||
widget_trias_draw(&wtb->tria1, pos);
|
||||
|
@ -814,11 +808,9 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol)
|
|||
if (wtb->tria2.tot)
|
||||
widget_trias_draw(&wtb->tria2, pos);
|
||||
|
||||
gpuTranslate3f(-jit[j][0], -jit[j][1], 0.0f);
|
||||
gpuTranslate2f(-jit[j][0], -jit[j][1]);
|
||||
}
|
||||
|
||||
gpuMatrixEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
@ -4151,9 +4143,8 @@ void ui_draw_pie_center(uiBlock *block)
|
|||
float angle = atan2f(pie_dir[1], pie_dir[0]);
|
||||
float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4;
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(cx, cy, 0.0f);
|
||||
gpuTranslate2f(cx, cy);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
if (btheme->tui.wcol_pie_menu.shaded) {
|
||||
|
@ -4200,7 +4191,6 @@ void ui_draw_pie_center(uiBlock *block)
|
|||
|
||||
glDisable(GL_BLEND);
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
|||
if (v3d && v3d->zbuf)
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix3D(lcd->ob->obmat);
|
||||
|
||||
unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
|
||||
|
@ -138,7 +138,7 @@ static void ringsel_draw(const bContext *C, ARegion *UNUSED(ar), void *arg)
|
|||
|
||||
immUnbindProgram();
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
|
||||
if (v3d && v3d->zbuf)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -127,7 +127,6 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
|
|||
|
||||
BKE_ptcache_ids_from_object(&pidlist, ob, scene, 0);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 2, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
|
||||
|
@ -162,8 +161,8 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
|
|||
continue;
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0);
|
||||
gpuScale3f(1.0, cache_draw_height, 0.0);
|
||||
gpuTranslate2f(0.0, (float)V2D_SCROLL_HEIGHT + yoffs);
|
||||
gpuScale2f(1.0, cache_draw_height);
|
||||
|
||||
switch (pid->type) {
|
||||
case PTCACHE_TYPE_SOFTBODY:
|
||||
|
@ -240,7 +239,6 @@ static void time_draw_cache(SpaceTime *stime, Object *ob, Scene *scene)
|
|||
}
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
|
||||
BLI_freelistN(&pidlist);
|
||||
}
|
||||
|
|
|
@ -403,7 +403,7 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize)
|
|||
Batch_init(&batch, GL_TRIANGLES, &vbo, NULL);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy(); /* TODO: replace Begin/End with Push/Pop */
|
||||
gpuPushMatrix();
|
||||
gpuScale3f(xsize, ysize, zsize);
|
||||
|
||||
if (flat_color) {
|
||||
|
@ -417,7 +417,7 @@ static void drawsolidcube_size(float xsize, float ysize, float zsize)
|
|||
Batch_Uniform4fv(&batch, "color", fcolor);
|
||||
Batch_draw(&batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
static void drawcube_size(float xsize, float ysize, float zsize)
|
||||
|
@ -450,14 +450,14 @@ static void drawcube_size(float xsize, float ysize, float zsize)
|
|||
Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy(); /* TODO: replace Begin/End with Push/Pop */
|
||||
gpuPushMatrix();
|
||||
gpuScale3f(xsize, ysize, zsize);
|
||||
|
||||
Batch_use_program(&batch);
|
||||
Batch_Uniform4fv(&batch, "color", fcolor);
|
||||
Batch_draw(&batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
|
@ -506,13 +506,9 @@ static void draw_bonevert(void)
|
|||
Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
Batch_use_program(&batch);
|
||||
Batch_Uniform4fv(&batch, "color", fcolor);
|
||||
Batch_draw(&batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static void draw_bonevert_solid(void)
|
||||
|
@ -520,9 +516,8 @@ static void draw_bonevert_solid(void)
|
|||
Batch *batch = Batch_get_sphere(0);
|
||||
const float light_vec[3] = {0.0f, 0.0f, 1.0f};
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
gpuScale3f(0.05, 0.05, 0.05);
|
||||
gpuPushMatrix();
|
||||
gpuScaleUniform(0.05);
|
||||
|
||||
if (flat_color) {
|
||||
Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
@ -535,7 +530,7 @@ static void draw_bonevert_solid(void)
|
|||
Batch_Uniform4fv(batch, "color", fcolor);
|
||||
Batch_draw(batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
static const float bone_octahedral_verts[6][3] = {
|
||||
|
@ -607,14 +602,10 @@ static void draw_bone_octahedral(void)
|
|||
Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
Batch_use_program(&batch);
|
||||
Batch_Uniform4fv(&batch, "color", fcolor);
|
||||
Batch_draw(&batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
}
|
||||
|
||||
static void draw_bone_solid_octahedral(void)
|
||||
{
|
||||
|
@ -644,8 +635,6 @@ static void draw_bone_solid_octahedral(void)
|
|||
Batch_init(&batch, GL_TRIANGLES, &vbo, NULL);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
if (flat_color) {
|
||||
Batch_set_builtin_program(&batch, GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
}
|
||||
|
@ -656,9 +645,7 @@ static void draw_bone_solid_octahedral(void)
|
|||
}
|
||||
Batch_Uniform4fv(&batch, "color", fcolor);
|
||||
Batch_draw(&batch);
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/* *************** Armature drawing, bones ******************* */
|
||||
|
||||
|
@ -1011,7 +998,6 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
Batch_set_builtin_program(sphere, GPU_SHADER_SIMPLE_LIGHTING);
|
||||
Batch_Uniform3fv(sphere, "light", light_vec);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
/* figure out the sizes of spheres */
|
||||
|
@ -1033,7 +1019,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
}
|
||||
|
||||
/* move to z-axis space */
|
||||
gpuRotate3f(-90.0f, 1.0f, 0.0f, 0.0f);
|
||||
gpuRotateAxis(-90.0f, 'X');
|
||||
|
||||
/* sphere root color */
|
||||
if (armflag & ARM_EDITMODE) {
|
||||
|
@ -1052,7 +1038,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
if (id != -1)
|
||||
GPU_select_load_id(id | BONESEL_ROOT);
|
||||
gpuPushMatrix();
|
||||
gpuScale3f(head, head, head);
|
||||
gpuScaleUniform(head);
|
||||
Batch_Uniform4fv(sphere, "color", fcolor);
|
||||
Batch_draw(sphere);
|
||||
gpuPopMatrix();
|
||||
|
@ -1070,7 +1056,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
gpuTranslate3f(0.0f, 0.0f, length);
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuScale3f(tail, tail, tail);
|
||||
gpuScaleUniform(tail);
|
||||
Batch_use_program(sphere); /* hack to make the following uniforms stick */
|
||||
Batch_Uniform4fv(sphere, "color", fcolor);
|
||||
Batch_draw(sphere);
|
||||
|
@ -1104,14 +1090,14 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
/* draw sphere on extrema */
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(0.0f, 0.0f, length - tail);
|
||||
gpuScale3f(size1, size1, size1);
|
||||
gpuScaleUniform(size1);
|
||||
|
||||
Batch_draw(sphere);
|
||||
gpuPopMatrix();
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3f(0.0f, 0.0f, head);
|
||||
gpuScale3f(size2, size2, size2);
|
||||
gpuScaleUniform(size2);
|
||||
|
||||
Batch_draw(sphere);
|
||||
gpuPopMatrix();
|
||||
|
@ -1141,12 +1127,11 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
|
|||
/* 1 sphere in center */
|
||||
gpuTranslate3f(0.0f, 0.0f, (head + length - tail) / 2.0f);
|
||||
|
||||
gpuScale3f(size1, size1, size1);
|
||||
gpuScaleUniform(size1);
|
||||
Batch_draw(sphere);
|
||||
}
|
||||
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id,
|
||||
|
@ -1162,9 +1147,8 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
|
|||
VertexFormat *format = immVertexFormat();
|
||||
unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuScale3f(length, length, length);
|
||||
gpuScaleUniform(length);
|
||||
|
||||
/* this chunk not in object mode */
|
||||
if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
|
||||
|
@ -1273,7 +1257,6 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
|
|||
immUnbindProgram();
|
||||
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
/* A partial copy of b_bone_spline_setup(), with just the parts for previewing editmode curve settings
|
||||
|
@ -1473,8 +1456,6 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len
|
|||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
immUniformColor4fv(fcolor);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
if ((segments > 1) && (pchan)) {
|
||||
float dlen = length / (float)segments;
|
||||
Mat4 *bbone = bbones;
|
||||
|
@ -1503,8 +1484,6 @@ static void draw_wire_bone_segments(bPoseChannel *pchan, Mat4 *bbones, float len
|
|||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
gpuMatrixEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
@ -1815,7 +1794,6 @@ static void draw_pose_dofs(Object *ob)
|
|||
unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
|
||||
bone = pchan->bone;
|
||||
|
@ -1845,7 +1823,7 @@ static void draw_pose_dofs(Object *ob)
|
|||
gpuMultMatrix3D(mat);
|
||||
|
||||
scale = bone->length * pchan->size[1];
|
||||
gpuScale3f(scale, scale, scale);
|
||||
gpuScaleUniform(scale);
|
||||
|
||||
if (((pchan->ikflag & BONE_IK_XLIMIT) != 0) &&
|
||||
((pchan->ikflag & BONE_IK_ZLIMIT) != 0))
|
||||
|
@ -1867,14 +1845,15 @@ static void draw_pose_dofs(Object *ob)
|
|||
draw_dof_ellipse(pos, amax[0], amin[2]);
|
||||
if ((amax[0] != 0.0f) && (amax[2] != 0.0f))
|
||||
draw_dof_ellipse(pos, amax[0], amax[2]);
|
||||
gpuScale3f(1.0f, -1.0f, 1.0f);
|
||||
gpuScale3f(1.0f, -1.0f, 1.0f); /* XXX same as above, is this intentional? */
|
||||
}
|
||||
|
||||
/* arcs */
|
||||
if (pchan->ikflag & BONE_IK_ZLIMIT) {
|
||||
/* OpenGL requires rotations in degrees; so we're taking the average angle here */
|
||||
theta = RAD2DEGF(0.5f * (pchan->limitmin[2] + pchan->limitmax[2]));
|
||||
gpuRotate3f(theta, 0.0f, 0.0f, 1.0f);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(theta, 'Z');
|
||||
|
||||
immUniformColor3ub(50, 50, 255); /* blue, Z axis limit */
|
||||
immBegin(GL_LINE_STRIP, 33);
|
||||
|
@ -1892,13 +1871,14 @@ static void draw_pose_dofs(Object *ob)
|
|||
}
|
||||
immEnd();
|
||||
|
||||
gpuRotate3f(-theta, 0.0f, 0.0f, 1.0f);
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
if (pchan->ikflag & BONE_IK_XLIMIT) {
|
||||
/* OpenGL requires rotations in degrees; so we're taking the average angle here */
|
||||
theta = RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0]));
|
||||
gpuRotate3f(theta, 1.0f, 0.0f, 0.0f);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(theta, 'X');
|
||||
|
||||
immUniformColor3ub(255, 50, 50); /* Red, X axis limit */
|
||||
immBegin(GL_LINE_STRIP, 33);
|
||||
|
@ -1915,7 +1895,7 @@ static void draw_pose_dofs(Object *ob)
|
|||
}
|
||||
immEnd();
|
||||
|
||||
gpuRotate3f(-theta, 1.0f, 0.0f, 0.0f);
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
/* out of cone, out of bone */
|
||||
|
@ -1926,7 +1906,7 @@ static void draw_pose_dofs(Object *ob)
|
|||
}
|
||||
}
|
||||
}
|
||||
gpuMatrixEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
|
|
@ -1255,7 +1255,6 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
|
|||
}
|
||||
|
||||
/* we first draw only the screen aligned & fixed scale stuff */
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuLoadMatrix3D(rv3d->viewmat);
|
||||
|
||||
|
@ -1610,7 +1609,7 @@ void drawlamp(View3D *v3d, RegionView3D *rv3d, Base *base,
|
|||
glDisable(GL_BLEND);
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
||||
static void draw_limit_line(float sta, float end, const short dflag, const unsigned char col[3], unsigned pos)
|
||||
|
@ -2171,8 +2170,6 @@ void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|||
BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale,
|
||||
asp, shift, &drawsize, vec);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
unsigned pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
if (ob_wire_col) {
|
||||
|
@ -2202,7 +2199,6 @@ void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|||
|
||||
if (is_view) {
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2277,7 +2273,6 @@ void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
|
|||
}
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
/* flag similar to draw_object() */
|
||||
|
@ -8038,7 +8033,6 @@ static void imm_draw_bb(BoundBox *bb, char type, bool around_origin, const unsig
|
|||
BKE_boundbox_calc_center_aabb(bb, cent);
|
||||
}
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
unsigned int pos = add_attrib(immVertexFormat(), "pos", GL_FLOAT, 3, KEEP_FLOAT);
|
||||
|
@ -8078,9 +8072,8 @@ static void imm_draw_bb(BoundBox *bb, char type, bool around_origin, const unsig
|
|||
gpuTranslate3f(0.0f, length / radius, 0.0f);
|
||||
Batch_draw(sphere);
|
||||
}
|
||||
gpuPopMatrix();
|
||||
gpuMatrixEnd();
|
||||
|
||||
gpuPopMatrix();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
|
|
@ -812,7 +812,7 @@ static bool view3d_draw_render_draw(const bContext *C, Scene *scene,
|
|||
|
||||
static void view3d_draw_background_gradient(void)
|
||||
{
|
||||
gpuMatrixBegin3D(); /* TODO: finish 2D API */
|
||||
/* TODO: finish 2D API & draw background with that */
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
|
@ -837,8 +837,6 @@ static void view3d_draw_background_gradient(void)
|
|||
immEnd();
|
||||
|
||||
immUnbindProgram();
|
||||
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static void view3d_draw_background_none(void)
|
||||
|
|
|
@ -1717,7 +1717,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
|
||||
projectFloatViewEx(t, vecrot, cent, V3D_PROJ_TEST_CLIP_ZERO);
|
||||
|
||||
gpuMatrixBegin3D_legacy(); /* TODO(merwin): finish the 2D matrix API & use here */
|
||||
gpuPushMatrix();
|
||||
|
||||
unsigned pos = add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
UNUSED_VARS(pos); /* silence warning */
|
||||
|
@ -1825,7 +1825,7 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata)
|
|||
}
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6873,8 +6873,7 @@ static void drawEdgeSlide(TransInfo *t)
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix3D(t->obedit->obmat);
|
||||
|
||||
unsigned pos = add_attrib(immVertexFormat(), "pos", COMP_F32, 3, KEEP_FLOAT);
|
||||
|
@ -6962,7 +6961,7 @@ static void drawEdgeSlide(TransInfo *t)
|
|||
|
||||
immUnbindProgram();
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
|
@ -7486,8 +7485,7 @@ static void drawVertSlide(TransInfo *t)
|
|||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
|
||||
gpuPushMatrix();
|
||||
gpuMultMatrix3D(t->obedit->obmat);
|
||||
|
||||
glLineWidth(line_size);
|
||||
|
@ -7566,7 +7564,7 @@ static void drawVertSlide(TransInfo *t)
|
|||
|
||||
immUnbindProgram();
|
||||
|
||||
gpuMatrixEnd();
|
||||
gpuPopMatrix();
|
||||
|
||||
if (v3d && v3d->zbuf)
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -988,7 +988,6 @@ static void draw_manipulator_rotate(
|
|||
|
||||
/* prepare for screen aligned draw */
|
||||
size = len_v3(rv3d->twmat[0]);
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
gpuTranslate3fv(rv3d->twmat[3]);
|
||||
|
||||
|
@ -1114,9 +1113,10 @@ static void draw_manipulator_rotate(
|
|||
preOrthoFront(ortho, matt, 0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_X);
|
||||
else manipulator_setcolor(v3d, 'X', colcode, 255);
|
||||
gpuRotate3f(90.0, 0.0, 1.0, 0.0);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(90.0, 'Y');
|
||||
imm_drawcircball(unitmat[3], 1.0, unitmat, pos);
|
||||
gpuRotate3f(-90.0, 0.0, 1.0, 0.0);
|
||||
gpuPopMatrix();
|
||||
postOrtho(ortho);
|
||||
}
|
||||
/* Y circle */
|
||||
|
@ -1124,9 +1124,10 @@ static void draw_manipulator_rotate(
|
|||
preOrthoFront(ortho, matt, 1);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
|
||||
else manipulator_setcolor(v3d, 'Y', colcode, 255);
|
||||
gpuRotate3f(-90.0, 1.0, 0.0, 0.0);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(-90.0, 'X');
|
||||
imm_drawcircball(unitmat[3], 1.0, unitmat, pos);
|
||||
gpuRotate3f(90.0, 1.0, 0.0, 0.0);
|
||||
gpuPopMatrix();
|
||||
postOrtho(ortho);
|
||||
}
|
||||
}
|
||||
|
@ -1147,9 +1148,10 @@ static void draw_manipulator_rotate(
|
|||
preOrthoFront(ortho, rv3d->twmat, 0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_X);
|
||||
else manipulator_setcolor(v3d, 'X', colcode, 255);
|
||||
gpuRotate3f(90.0, 0.0, 1.0, 0.0);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(90.0, 'Y');
|
||||
partial_doughnut(pos, cusize / 4.0f, 1.0f, 0, 48, 8, 48);
|
||||
gpuRotate3f(-90.0, 0.0, 1.0, 0.0);
|
||||
gpuPopMatrix();
|
||||
postOrtho(ortho);
|
||||
}
|
||||
/* Y circle */
|
||||
|
@ -1157,9 +1159,10 @@ static void draw_manipulator_rotate(
|
|||
preOrthoFront(ortho, rv3d->twmat, 1);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
|
||||
else manipulator_setcolor(v3d, 'Y', colcode, 255);
|
||||
gpuRotate3f(-90.0, 1.0, 0.0, 0.0);
|
||||
gpuPushMatrix();
|
||||
gpuRotateAxis(-90.0, 'X');
|
||||
partial_doughnut(pos, cusize / 4.0f, 1.0f, 0, 48, 8, 48);
|
||||
gpuRotate3f(90.0, 1.0, 0.0, 0.0);
|
||||
gpuPopMatrix();
|
||||
postOrtho(ortho);
|
||||
}
|
||||
|
||||
|
@ -1188,8 +1191,8 @@ static void draw_manipulator_rotate(
|
|||
if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
|
||||
else manipulator_setcolor(v3d, 'Y', colcode, 255);
|
||||
|
||||
gpuRotate3f(90.0, 1.0, 0.0, 0.0);
|
||||
gpuRotate3f(90.0, 0.0, 0.0, 1.0);
|
||||
gpuRotateAxis(90.0, 'X');
|
||||
gpuRotateAxis(90.0, 'Z');
|
||||
partial_doughnut(pos, 0.7f * cusize, 1.0f, 31, 33, 8, 64);
|
||||
|
||||
gpuPopMatrix();
|
||||
|
@ -1203,8 +1206,8 @@ static void draw_manipulator_rotate(
|
|||
if (is_picksel) GPU_select_load_id(MAN_ROT_X);
|
||||
else manipulator_setcolor(v3d, 'X', colcode, 255);
|
||||
|
||||
gpuRotate3f(-90.0, 0.0, 1.0, 0.0);
|
||||
gpuRotate3f(90.0, 0.0, 0.0, 1.0);
|
||||
gpuRotateAxis(-90.0, 'Y');
|
||||
gpuRotateAxis(90.0, 'Z');
|
||||
partial_doughnut(pos, 0.7f * cusize, 1.0f, 31, 33, 8, 64);
|
||||
|
||||
gpuPopMatrix();
|
||||
|
@ -1218,7 +1221,6 @@ static void draw_manipulator_rotate(
|
|||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static void drawsolidcube(unsigned int pos, float size)
|
||||
|
@ -1276,7 +1278,6 @@ static void draw_manipulator_scale(
|
|||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
/* not in combo mode */
|
||||
|
@ -1375,7 +1376,6 @@ static void draw_manipulator_scale(
|
|||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
glFrontFace(GL_CCW);
|
||||
|
||||
gpuMatrixEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
@ -1468,7 +1468,6 @@ static void draw_manipulator_translate(
|
|||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
/* center circle, do not add to selection when shift is pressed (planar constraint) */
|
||||
|
@ -1517,7 +1516,7 @@ static void draw_manipulator_translate(
|
|||
gpuTranslate3f(dz, 0.0, 0.0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_TRANS_X);
|
||||
else manipulator_setcolor(v3d, 'X', colcode, axisBlendAngle(rv3d->tw_idot[0]));
|
||||
gpuRotate3f(90.0, 0.0, 1.0, 0.0);
|
||||
gpuRotateAxis(90.0, 'Y');
|
||||
draw_cone(pos, cylen, cywid);
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
@ -1528,7 +1527,7 @@ static void draw_manipulator_translate(
|
|||
gpuTranslate3f(0.0, dz, 0.0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_TRANS_Y);
|
||||
else manipulator_setcolor(v3d, 'Y', colcode, axisBlendAngle(rv3d->tw_idot[1]));
|
||||
gpuRotate3f(-90.0, 1.0, 0.0, 0.0);
|
||||
gpuRotateAxis(-90.0, 'X');
|
||||
draw_cone(pos, cylen, cywid);
|
||||
gpuPopMatrix();
|
||||
}
|
||||
|
@ -1541,7 +1540,6 @@ static void draw_manipulator_translate(
|
|||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
immUnbindProgram();
|
||||
gpuMatrixEnd();
|
||||
}
|
||||
|
||||
static void draw_manipulator_rotate_cyl(
|
||||
|
@ -1563,7 +1561,6 @@ static void draw_manipulator_rotate_cyl(
|
|||
|
||||
immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
|
||||
|
||||
gpuMatrixBegin3D_legacy();
|
||||
gpuPushMatrix();
|
||||
|
||||
/* prepare for screen aligned draw */
|
||||
|
@ -1629,7 +1626,7 @@ static void draw_manipulator_rotate_cyl(
|
|||
gpuPushMatrix();
|
||||
gpuTranslate3f(1.0, 0.0, 0.0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_X);
|
||||
gpuRotate3f(90.0, 0.0, 1.0, 0.0);
|
||||
gpuRotateAxis(90.0, 'Y');
|
||||
manipulator_setcolor(v3d, 'X', colcode, 255);
|
||||
draw_cylinder(pos, cylen, cywid);
|
||||
gpuPopMatrix();
|
||||
|
@ -1640,7 +1637,7 @@ static void draw_manipulator_rotate_cyl(
|
|||
gpuPushMatrix();
|
||||
gpuTranslate3f(0.0, 1.0, 0.0);
|
||||
if (is_picksel) GPU_select_load_id(MAN_ROT_Y);
|
||||
gpuRotate3f(-90.0, 1.0, 0.0, 0.0);
|
||||
gpuRotateAxis(-90.0, 'X');
|
||||
manipulator_setcolor(v3d, 'Y', colcode, 255);
|
||||
draw_cylinder(pos, cylen, cywid);
|
||||
gpuPopMatrix();
|
||||
|
@ -1664,7 +1661,6 @@ static void draw_manipulator_rotate_cyl(
|
|||
|
||||
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
|
||||
|
||||
gpuMatrixEnd();
|
||||
immUnbindProgram();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue