Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | |||||
| void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]) | void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const float color[4]) | ||||
| { | { | ||||
| const int ofs_y = 4 * U.pixelsize; | const int ofs_y = 4 * U.pixelsize; | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(color); | immUniformColor4fv(color); | ||||
| immRecti(pos, pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * U.pixelsize)); | immRecti(pos, pos_x, pos_y - ofs_y, pos_x + len, pos_y - ofs_y + (height * U.pixelsize)); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| /* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */ | /* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */ | ||||
| ▲ Show 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region), | ||||
| GPU_scissor((rect.xmin - 1), | GPU_scissor((rect.xmin - 1), | ||||
| (rect.ymin - 1), | (rect.ymin - 1), | ||||
| (rect.xmax + 1) - (rect.xmin - 1), | (rect.xmax + 1) - (rect.xmin - 1), | ||||
| (rect.ymax + 1) - (rect.ymin - 1)); | (rect.ymax + 1) - (rect.ymin - 1)); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | ||||
| /* draw grid lines here */ | /* draw grid lines here */ | ||||
| for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) { | for (int i = 1; i <= HISTOGRAM_TOT_GRID_LINES; i++) { | ||||
| const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES; | const float fac = (float)i / (float)HISTOGRAM_TOT_GRID_LINES; | ||||
| /* so we can tell the 1.0 color point */ | /* so we can tell the 1.0 color point */ | ||||
| if (i == HISTOGRAM_TOT_GRID_LINES) { | if (i == HISTOGRAM_TOT_GRID_LINES) { | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | static void waveform_draw_one(float *waveform, int waveform_num, const float col[3]) | ||||
| GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); | GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); | ||||
| GPU_vertbuf_data_alloc(vbo, waveform_num); | GPU_vertbuf_data_alloc(vbo, waveform_num); | ||||
| GPU_vertbuf_attr_fill(vbo, pos_id, waveform); | GPU_vertbuf_attr_fill(vbo, pos_id, waveform); | ||||
| /* TODO: store the #GPUBatch inside the scope. */ | /* TODO: store the #GPUBatch inside the scope. */ | ||||
| GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); | GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); | ||||
| GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); | GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); | GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); | ||||
| GPU_batch_draw(batch); | GPU_batch_draw(batch); | ||||
| GPU_batch_discard(batch); | GPU_batch_discard(batch); | ||||
| } | } | ||||
| void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), | void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), | ||||
| uiBut *but, | uiBut *but, | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), | ||||
| /* Flush text cache before drawing things on top. */ | /* Flush text cache before drawing things on top. */ | ||||
| BLF_batch_draw_flush(); | BLF_batch_draw_flush(); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | ||||
| /* draw grid lines here */ | /* draw grid lines here */ | ||||
| immBegin(GPU_PRIM_LINES, 12); | immBegin(GPU_PRIM_LINES, 12); | ||||
| for (int i = 0; i < 6; i++) { | for (int i = 0; i < 6; i++) { | ||||
| immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h); | immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h); | ||||
| ▲ Show 20 Lines • Show All 307 Lines • ▼ Show 20 Lines | void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region), | ||||
| GPU_scissor((rect.xmin - 1), | GPU_scissor((rect.xmin - 1), | ||||
| (rect.ymin - 1), | (rect.ymin - 1), | ||||
| (rect.xmax + 1) - (rect.xmin - 1), | (rect.xmax + 1) - (rect.xmin - 1), | ||||
| (rect.ymax + 1) - (rect.ymin - 1)); | (rect.ymax + 1) - (rect.ymin - 1)); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); | ||||
| /* draw grid elements */ | /* draw grid elements */ | ||||
| /* cross */ | /* cross */ | ||||
| immBegin(GPU_PRIM_LINES, 4); | immBegin(GPU_PRIM_LINES, 4); | ||||
| immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); | immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); | ||||
| immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery); | immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery); | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | if (active || half_width < min_width) { | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex2f(shdr_pos, x, y1); | immVertex2f(shdr_pos, x, y1); | ||||
| immVertex2f(shdr_pos, x, y2); | immVertex2f(shdr_pos, x, y2); | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* hide handles when zoomed out too far */ | /* hide handles when zoomed out too far */ | ||||
| if (half_width < min_width) { | if (half_width < min_width) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| /* shift handle down */ | /* shift handle down */ | ||||
| ▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const rcti *rect) | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| /* New format */ | /* New format */ | ||||
| format = immVertexFormat(); | format = immVertexFormat(); | ||||
| pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* layer: box outline */ | /* layer: box outline */ | ||||
| immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f); | immUniformColor4f(0.0f, 0.0f, 0.0f, 1.0f); | ||||
| imm_draw_box_wire_2d(pos_id, x1, y1, x1 + sizex, rect->ymax); | imm_draw_box_wire_2d(pos_id, x1, y1, x1 + sizex, rect->ymax); | ||||
| /* layer: box outline */ | /* layer: box outline */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); | immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | void ui_draw_but_UNITVEC(uiBut *but, | ||||
| GPU_uniformbuf_free(ubo); | GPU_uniformbuf_free(ubo); | ||||
| /* Restore. */ | /* Restore. */ | ||||
| GPU_face_culling(GPU_CULL_NONE); | GPU_face_culling(GPU_CULL_NONE); | ||||
| /* AA circle */ | /* AA circle */ | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3ubv(wcol->inner); | immUniformColor3ubv(wcol->inner); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32); | imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, 1.0f, 32); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| GPU_line_smooth(false); | GPU_line_smooth(false); | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | if (but_cumap->gradient_type == UI_GRAD_H) { | ||||
| ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); | ui_draw_gradient(&grid, col, UI_GRAD_H, 1.0f); | ||||
| } | } | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* backdrop */ | /* backdrop */ | ||||
| float color_backdrop[4] = {0, 0, 0, 1}; | float color_backdrop[4] = {0, 0, 0, 1}; | ||||
| if (but_cumap->gradient_type == UI_GRAD_H) { | if (but_cumap->gradient_type == UI_GRAD_H) { | ||||
| /* grid, hsv uses different grid */ | /* grid, hsv uses different grid */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| ARRAY_SET_ITEMS(color_backdrop, 0, 0, 0, 48.0 / 255.0); | ARRAY_SET_ITEMS(color_backdrop, 0, 0, 0, 48.0 / 255.0); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | if ((cumap->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { | ||||
| line_range.xmax = rect->xmax; | line_range.xmax = rect->xmax; | ||||
| line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy); | line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy); | ||||
| } | } | ||||
| else { | else { | ||||
| line_range.xmax = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]); | line_range.xmax = rect->xmin + zoomx * (cmp[CM_TABLE].x - offsx - cuma->ext_out[0]); | ||||
| line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]); | line_range.ymax = rect->ymin + zoomy * (cmp[CM_TABLE].y - offsy - cuma->ext_out[1]); | ||||
| } | } | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* Curve filled. */ | /* Curve filled. */ | ||||
| immUniformColor3ubvAlpha(wcol->item, 128); | immUniformColor3ubvAlpha(wcol->item, 128); | ||||
| immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4); | immBegin(GPU_PRIM_TRI_STRIP, (CM_TABLE * 2 + 2) + 4); | ||||
| immVertex2f(pos, line_range.xmin, rect->ymin); | immVertex2f(pos, line_range.xmin, rect->ymin); | ||||
| immVertex2f(pos, line_range.xmin, line_range.ymin); | immVertex2f(pos, line_range.xmin, line_range.ymin); | ||||
| for (int a = 0; a <= CM_TABLE; a++) { | for (int a = 0; a <= CM_TABLE; a++) { | ||||
| ▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | #endif | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* Restore scissor-test. */ | /* Restore scissor-test. */ | ||||
| GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | ||||
| /* outline */ | /* outline */ | ||||
| format = immVertexFormat(); | format = immVertexFormat(); | ||||
| pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3ubv(wcol->outline); | immUniformColor3ubv(wcol->outline); | ||||
| imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| /** | /** | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | GPU_scissor(scissor_new.xmin, | ||||
| scissor_new.ymin, | scissor_new.ymin, | ||||
| BLI_rcti_size_x(&scissor_new), | BLI_rcti_size_x(&scissor_new), | ||||
| BLI_rcti_size_y(&scissor_new)); | BLI_rcti_size_y(&scissor_new)); | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* Draw the backdrop. */ | /* Draw the backdrop. */ | ||||
| float color_backdrop[4] = {0, 0, 0, 1}; | float color_backdrop[4] = {0, 0, 0, 1}; | ||||
| if (profile->flag & PROF_USE_CLIP) { | if (profile->flag & PROF_USE_CLIP) { | ||||
| gl_shaded_color_get_fl((uchar *)wcol->inner, -20, color_backdrop); | gl_shaded_color_get_fl((uchar *)wcol->inner, -20, color_backdrop); | ||||
| immUniformColor3fv(color_backdrop); | immUniformColor3fv(color_backdrop); | ||||
| immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | immRectf(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | ||||
| immUniformColor3ubv((uchar *)wcol->inner); | immUniformColor3ubv((uchar *)wcol->inner); | ||||
| ▲ Show 20 Lines • Show All 218 Lines • ▼ Show 20 Lines | void ui_draw_but_CURVEPROFILE(ARegion *region, | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* Restore scissor-test. */ | /* Restore scissor-test. */ | ||||
| GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | ||||
| /* Outline */ | /* Outline */ | ||||
| format = immVertexFormat(); | format = immVertexFormat(); | ||||
| pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3ubv((const uchar *)wcol->outline); | immUniformColor3ubv((const uchar *)wcol->outline); | ||||
| imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), | void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), | ||||
| uiBut *but, | uiBut *but, | ||||
| ▲ Show 20 Lines • Show All 324 Lines • Show Last 20 Lines | |||||