Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform.c
| Context not available. | |||||
| #include "BLT_translation.h" | #include "BLT_translation.h" | ||||
| #include "transform.h" | #include "transform.h" | ||||
| #include "GPU_immediate.h" | |||||
| /* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */ | /* Disabling, since when you type you know what you are doing, and being able to set it to zero is handy. */ | ||||
| // #define USE_NUM_NO_ZERO | // #define USE_NUM_NO_ZERO | ||||
| Context not available. | |||||
| } ArrowDirection; | } ArrowDirection; | ||||
| static void drawArrow(ArrowDirection d, short offset, short length, short size) | static void drawArrow(ArrowDirection d, short offset, short length, short size) | ||||
| { | { | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
merwin: Since you're using the new immVertex2s function, should be:
```
unsigned pos = add_attrib… | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| switch (d) { | switch (d) { | ||||
| case LEFT: | case LEFT: | ||||
| offset = -offset; | offset = -offset; | ||||
| Context not available. | |||||
| size = -size; | size = -size; | ||||
| /* fall-through */ | /* fall-through */ | ||||
| case RIGHT: | case RIGHT: | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 6); | ||||
| glVertex2s(offset, 0); | immVertex2s(pos, offset, 0); | ||||
| glVertex2s(offset + length, 0); | immVertex2s(pos, offset + length, 0); | ||||
| glVertex2s(offset + length, 0); | immVertex2s(pos, offset + length, 0); | ||||
| glVertex2s(offset + length - size, -size); | immVertex2s(pos, offset + length - size, -size); | ||||
| glVertex2s(offset + length, 0); | immVertex2s(pos, offset + length, 0); | ||||
| glVertex2s(offset + length - size, size); | immVertex2s(pos, offset + length - size, size); | ||||
| glEnd(); | immEnd(); | ||||
| break; | break; | ||||
| case DOWN: | case DOWN: | ||||
| Context not available. | |||||
| size = -size; | size = -size; | ||||
| /* fall-through */ | /* fall-through */ | ||||
| case UP: | case UP: | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 6); | ||||
| glVertex2s(0, offset); | immVertex2s(pos, 0, offset); | ||||
| glVertex2s(0, offset + length); | immVertex2s(pos, 0, offset + length); | ||||
| glVertex2s(0, offset + length); | immVertex2s(pos, 0, offset + length); | ||||
| glVertex2s(-size, offset + length - size); | immVertex2s(pos, -size, offset + length - size); | ||||
| glVertex2s(0, offset + length); | immVertex2s(pos, 0, offset + length); | ||||
| glVertex2s(size, offset + length - size); | immVertex2s(pos, size, offset + length - size); | ||||
| glEnd(); | immEnd(); | ||||
| break; | break; | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| static void drawArrowHead(ArrowDirection d, short size) | static void drawArrowHead(ArrowDirection d, short size) | ||||
| { | { | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
merwinUnsubmitted Done Inline Actionssame here merwin: same here | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| switch (d) { | switch (d) { | ||||
| case LEFT: | case LEFT: | ||||
| size = -size; | size = -size; | ||||
| /* fall-through */ | /* fall-through */ | ||||
| case RIGHT: | case RIGHT: | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 4); | ||||
| glVertex2s(0, 0); | immVertex2s(pos, 0, 0); | ||||
| glVertex2s(-size, -size); | immVertex2s(pos, -size, -size); | ||||
| glVertex2s(0, 0); | immVertex2s(pos, 0, 0); | ||||
| glVertex2s(-size, size); | immVertex2s(pos, -size, size); | ||||
| glEnd(); | immEnd(); | ||||
| break; | break; | ||||
| case DOWN: | case DOWN: | ||||
| size = -size; | size = -size; | ||||
| /* fall-through */ | /* fall-through */ | ||||
| case UP: | case UP: | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 4); | ||||
| glVertex2s(0, 0); | immVertex2s(pos, 0, 0); | ||||
| glVertex2s(-size, -size); | immVertex2s(pos, -size, -size); | ||||
| glVertex2s(0, 0); | immVertex2s(pos, 0, 0); | ||||
| glVertex2s(size, -size); | immVertex2s(pos, size, -size); | ||||
| glEnd(); | immEnd(); | ||||
| break; | break; | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| static void drawArc(float size, float angle_start, float angle_end, int segments) | static void drawArc(float size, float angle_start, float angle_end, int segments) | ||||
| Context not available. | |||||
| float angle; | float angle; | ||||
| int a; | int a; | ||||
| glBegin(GL_LINE_STRIP); | VertexFormat* format = immVertexFormat(); | ||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immBegin(GL_LINE_STRIP, segments + 1); | |||||
| for (angle = angle_start, a = 0; a < segments; angle += delta, a++) { | for (angle = angle_start, a = 0; a < segments; angle += delta, a++) { | ||||
| glVertex2f(cosf(angle) * size, sinf(angle) * size); | immVertex2f(pos, cosf(angle) * size, sinf(angle) * size); | ||||
| } | } | ||||
| glVertex2f(cosf(angle_end) * size, sinf(angle_end) * size); | immVertex2f(pos, cosf(angle_end) * size, sinf(angle_end) * size); | ||||
| immEnd(); | |||||
| glEnd(); | immUnbindProgram(); | ||||
| } | } | ||||
| static int helpline_poll(bContext *C) | static int helpline_poll(bContext *C) | ||||
| Context not available. | |||||
| glPushMatrix(); | glPushMatrix(); | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| switch (t->helpline) { | switch (t->helpline) { | ||||
| case HLP_SPRING: | case HLP_SPRING: | ||||
| UI_ThemeColor(TH_VIEW_OVERLAY); | UI_ThemeColor(TH_VIEW_OVERLAY); | ||||
| setlinestyle(3); | setlinestyle(3); | ||||
| glLineWidth(1); | glLineWidth(1); | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 2); | ||||
| glVertex2iv(t->mval); | immVertex2iv(pos, t->mval); | ||||
| glVertex2fv(cent); | immVertex2fv(pos, cent); | ||||
| glEnd(); | immEnd(); | ||||
| glTranslate2iv(mval); | glTranslate2iv(mval); | ||||
| glRotatef(-RAD2DEGF(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 0, 0, 1); | glRotatef(-RAD2DEGF(atan2f(cent[0] - t->mval[0], cent[1] - t->mval[1])), 0, 0, 1); | ||||
| Context not available. | |||||
| setlinestyle(3); | setlinestyle(3); | ||||
| glLineWidth(1); | glLineWidth(1); | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, 2); | ||||
| glVertex2iv(t->mval); | immVertex2iv(pos, t->mval); | ||||
| glVertex2fv(cent); | immVertex2fv(pos, cent); | ||||
| glEnd(); | immEnd(); | ||||
| glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0); | glTranslatef(cent[0] - t->mval[0] + mval[0], cent[1] - t->mval[1] + mval[1], 0); | ||||
| Context not available. | |||||
| glLineWidth(3.0); | glLineWidth(3.0); | ||||
| UI_make_axis_color(col, col2, 'X'); | UI_make_axis_color(col, col2, 'X'); | ||||
| glColor3ubv((GLubyte *)col2); | immUniformColor3ubv((GLubyte *)col2); | ||||
| drawArrow(RIGHT, 5, 10, 5); | drawArrow(RIGHT, 5, 10, 5); | ||||
| drawArrow(LEFT, 5, 10, 5); | drawArrow(LEFT, 5, 10, 5); | ||||
| UI_make_axis_color(col, col2, 'Y'); | UI_make_axis_color(col, col2, 'Y'); | ||||
| glColor3ubv((GLubyte *)col2); | immUniformColor3ubv((GLubyte *)col2); | ||||
| drawArrow(UP, 5, 10, 5); | drawArrow(UP, 5, 10, 5); | ||||
| drawArrow(DOWN, 5, 10, 5); | drawArrow(DOWN, 5, 10, 5); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| glPopMatrix(); | glPopMatrix(); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| glMultMatrixf(t->obedit->obmat); | glMultMatrixf(t->obedit->obmat); | ||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
merwinUnsubmitted Done Inline ActionsGL_FLOAT (or COMP_F32), 3, KEEP_FLOAT GPU_SHADER_3D_UNIFORM_COLOR Debug build will catch things like this. Would it be better if I enabled more error checking for non-debug builds too? merwin: GL_FLOAT (or COMP_F32), **3**, KEEP_FLOAT
GPU_SHADER_**3D**_UNIFORM_COLOR
Debug build will… | |||||
darwinAuthorUnsubmitted Not Done Inline ActionsMy bad. Still getting used to the APIs. darwin: My bad. Still getting used to the APIs. | |||||
merwinUnsubmitted Not Done Inline ActionsThey're new to everyone, it's expected! Debug and release builds will now catch errors at runtime. merwin: They're new to everyone, it's expected!
Debug and release builds will now catch errors at… | |||||
| if (sld->use_even == true) { | if (sld->use_even == true) { | ||||
| float co_a[3], co_b[3], co_mark[3]; | float co_a[3], co_b[3], co_mark[3]; | ||||
| TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | TransDataEdgeSlideVert *curr_sv = &sld->sv[sld->curr_sv_index]; | ||||
| Context not available. | |||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
| glBegin(GL_LINES); | immBeginAtMost(GL_LINES, 4); | ||||
| if (curr_sv->v_side[0]) { | if (curr_sv->v_side[0]) { | ||||
| glVertex3fv(curr_sv->v_side[0]->co); | immVertex3fv(pos, curr_sv->v_side[0]->co); | ||||
| glVertex3fv(curr_sv->v_co_orig); | immVertex3fv(pos, curr_sv->v_co_orig); | ||||
| } | } | ||||
| if (curr_sv->v_side[1]) { | if (curr_sv->v_side[1]) { | ||||
| glVertex3fv(curr_sv->v_side[1]->co); | immVertex3fv(pos, curr_sv->v_side[1]->co); | ||||
| glVertex3fv(curr_sv->v_co_orig); | immVertex3fv(pos, curr_sv->v_co_orig); | ||||
| } | } | ||||
| glEnd(); | immEnd(); | ||||
| UI_ThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); | UI_ThemeColorShadeAlpha(TH_SELECT, -30, alpha_shade); | ||||
| glPointSize(ctrl_size); | glPointSize(ctrl_size); | ||||
| glBegin(GL_POINTS); | immBegin(GL_POINTS, 1); | ||||
| if (sld->flipped) { | if (sld->flipped) { | ||||
| if (curr_sv->v_side[1]) glVertex3fv(curr_sv->v_side[1]->co); | if (curr_sv->v_side[1]) immVertex3fv(pos, curr_sv->v_side[1]->co); | ||||
| } | } | ||||
| else { | else { | ||||
| if (curr_sv->v_side[0]) glVertex3fv(curr_sv->v_side[0]->co); | if (curr_sv->v_side[0]) immVertex3fv(pos, curr_sv->v_side[0]->co); | ||||
| } | } | ||||
| glEnd(); | immEnd(); | ||||
| UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); | UI_ThemeColorShadeAlpha(TH_SELECT, 255, alpha_shade); | ||||
| glPointSize(guide_size); | glPointSize(guide_size); | ||||
| glBegin(GL_POINTS); | immBeginAtMost(GL_POINTS, 2); | ||||
| #if 0 | #if 0 | ||||
| interp_v3_v3v3(co_mark, co_b, co_a, fac); | interp_v3_v3v3(co_mark, co_b, co_a, fac); | ||||
| glVertex3fv(co_mark); | immVertex3fv(pos, co_mark); | ||||
| #endif | #endif | ||||
| interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); | interp_line_v3_v3v3v3(co_mark, co_b, curr_sv->v_co_orig, co_a, fac); | ||||
| glVertex3fv(co_mark); | immVertex3fv(pos, co_mark); | ||||
| glEnd(); | immEnd(); | ||||
| } | } | ||||
| else { | else { | ||||
| if (is_clamp == false) { | if (is_clamp == false) { | ||||
| Context not available. | |||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES, sld->totsv * 2); | ||||
| sv = sld->sv; | sv = sld->sv; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| Context not available. | |||||
| add_v3_v3(a, sv->v_co_orig); | add_v3_v3(a, sv->v_co_orig); | ||||
| add_v3_v3(b, sv->v_co_orig); | add_v3_v3(b, sv->v_co_orig); | ||||
| glVertex3fv(a); | immVertex3fv(pos, a); | ||||
| glVertex3fv(b); | immVertex3fv(pos, b); | ||||
| } | } | ||||
| glEnd(); | immEnd(); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(0); | BLI_assert(0); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| glPopMatrix(); | glPopMatrix(); | ||||
| glPopAttrib(); | glPopAttrib(); | ||||
| Context not available. | |||||
| glLineWidth(line_size); | glLineWidth(line_size); | ||||
| UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | UI_ThemeColorShadeAlpha(TH_EDGE_SELECT, 80, alpha_shade); | ||||
merwinUnsubmitted Not Done Inline ActionsCall immThemeColorShadeAlpha after immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR). merwin: Call **imm**ThemeColorShadeAlpha after immBindBuiltinProgram(GPU_SHADER_**3D_UNIFORM**_COLOR). | |||||
darwinAuthorUnsubmitted Not Done Inline ActionsI can't find a definition for immThemeColorShadeAlpha(). darwin: I can't find a definition for immThemeColorShadeAlpha(). | |||||
merwinUnsubmitted Done Inline ActionsOops! immUniformThemeColorShadeAlpha merwin: Oops! imm**Uniform**ThemeColorShadeAlpha | |||||
| glBegin(GL_LINES); | |||||
| VertexFormat* format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); | |||||
merwinUnsubmitted Done Inline ActionsSame as above, use 3D versions of these. merwin: Same as above, use 3D versions of these. | |||||
| immBegin(GL_LINES, sld->totsv * 2); | |||||
| if (is_clamp) { | if (is_clamp) { | ||||
| sv = sld->sv; | sv = sld->sv; | ||||
| for (i = 0; i < sld->totsv; i++, sv++) { | for (i = 0; i < sld->totsv; i++, sv++) { | ||||
| glVertex3fv(sv->co_orig_3d); | immVertex3fv(pos, sv->co_orig_3d); | ||||
| glVertex3fv(sv->co_link_orig_3d[sv->co_link_curr]); | immVertex3fv(pos, sv->co_link_orig_3d[sv->co_link_curr]); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| Context not available. | |||||
| add_v3_v3(a, sv->co_orig_3d); | add_v3_v3(a, sv->co_orig_3d); | ||||
| add_v3_v3(b, sv->co_orig_3d); | add_v3_v3(b, sv->co_orig_3d); | ||||
| glVertex3fv(a); | immVertex3fv(pos, a); | ||||
| glVertex3fv(b); | immVertex3fv(pos, b); | ||||
| } | } | ||||
| } | } | ||||
| glEnd(); | immEnd(); | ||||
| glPointSize(ctrl_size); | glPointSize(ctrl_size); | ||||
| glBegin(GL_POINTS); | immBegin(GL_POINTS, 1); | ||||
| glVertex3fv((sld->flipped && sld->use_even) ? | immVertex3fv(pos, (sld->flipped && sld->use_even) ? | ||||
| curr_sv->co_link_orig_3d[curr_sv->co_link_curr] : | curr_sv->co_link_orig_3d[curr_sv->co_link_curr] : | ||||
| curr_sv->co_orig_3d); | curr_sv->co_orig_3d); | ||||
| glEnd(); | immEnd(); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| Context not available. | |||||
| setlinestyle(1); | setlinestyle(1); | ||||
| cpack(0xffffff); | cpack(0xffffff); | ||||
merwinUnsubmitted Done Inline ActionsUse imm_cpack here. merwin: Use imm_cpack here. | |||||
| glBegin(GL_LINES); | |||||
| glVertex3fv(curr_sv->co_orig_3d); | |||||
| glVertex3fv(co_dest_3d); | |||||
| glEnd(); | immBegin(GL_LINES, 2); | ||||
| immVertex3fv(pos, curr_sv->co_orig_3d); | |||||
| immVertex3fv(pos, co_dest_3d); | |||||
| immEnd(); | |||||
| } | } | ||||
| immUnbindProgram(); | |||||
| glPopMatrix(); | glPopMatrix(); | ||||
| glPopAttrib(); | glPopAttrib(); | ||||
| Context not available. | |||||
Since you're using the new immVertex2s function, should be:
or
If you build with "make debug" or "make lite debug" or (on Windows) "make 2015 lite debug" it will catch things like this at runtime.