Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 2,249 Lines • ▼ Show 20 Lines | void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), | ||||
| } | } | ||||
| /* outline */ | /* outline */ | ||||
| draw_scope_end(&rect, scissor); | draw_scope_end(&rect, scissor); | ||||
| GPU_blend(false); | GPU_blend(false); | ||||
| } | } | ||||
| void ui_draw_but_NODESOCKET(ARegion *ar, | |||||
| uiBut *but, | |||||
| const uiWidgetColors *UNUSED(wcol), | |||||
| const rcti *recti) | |||||
| { | |||||
| static const float size = 5.0f; | |||||
| /* 16 values of sin function */ | |||||
| const float si[16] = { | |||||
| 0.00000000f, | |||||
| 0.39435585f, | |||||
| 0.72479278f, | |||||
| 0.93775213f, | |||||
| 0.99871650f, | |||||
| 0.89780453f, | |||||
| 0.65137248f, | |||||
| 0.29936312f, | |||||
| -0.10116832f, | |||||
| -0.48530196f, | |||||
| -0.79077573f, | |||||
| -0.96807711f, | |||||
| -0.98846832f, | |||||
| -0.84864425f, | |||||
| -0.57126821f, | |||||
| -0.20129852f, | |||||
| }; | |||||
| /* 16 values of cos function */ | |||||
| const float co[16] = { | |||||
| 1.00000000f, | |||||
| 0.91895781f, | |||||
| 0.68896691f, | |||||
| 0.34730525f, | |||||
| -0.05064916f, | |||||
| -0.44039415f, | |||||
| -0.75875812f, | |||||
| -0.95413925f, | |||||
| -0.99486932f, | |||||
| -0.87434661f, | |||||
| -0.61210598f, | |||||
| -0.25065253f, | |||||
| 0.15142777f, | |||||
| 0.52896401f, | |||||
| 0.82076344f, | |||||
| 0.97952994f, | |||||
| }; | |||||
| int scissor[4]; | |||||
| /* need scissor test, can draw outside of boundary */ | |||||
| GPU_scissor_get_i(scissor); | |||||
| rcti scissor_new = { | |||||
| .xmin = recti->xmin, | |||||
| .ymin = recti->ymin, | |||||
| .xmax = recti->xmax, | |||||
| .ymax = recti->ymax, | |||||
| }; | |||||
| rcti scissor_region = {0, ar->winx, 0, ar->winy}; | |||||
| BLI_rcti_isect(&scissor_new, &scissor_region, &scissor_new); | |||||
| GPU_scissor(scissor_new.xmin, | |||||
| scissor_new.ymin, | |||||
| BLI_rcti_size_x(&scissor_new), | |||||
| BLI_rcti_size_y(&scissor_new)); | |||||
| float x = 0.5f * (recti->xmin + recti->xmax); | |||||
| float y = 0.5f * (recti->ymin + recti->ymax); | |||||
| GPUVertFormat *format = immVertexFormat(); | |||||
| uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformColor4ubv(but->col); | |||||
| GPU_blend(true); | |||||
| immBegin(GPU_PRIM_TRI_FAN, 16); | |||||
| for (int a = 0; a < 16; a++) { | |||||
| immVertex2f(pos, x + size * si[a], y + size * co[a]); | |||||
| } | |||||
| immEnd(); | |||||
| immUniformColor4ub(0, 0, 0, 150); | |||||
| GPU_line_width(1); | |||||
| GPU_line_smooth(true); | |||||
| immBegin(GPU_PRIM_LINE_LOOP, 16); | |||||
| for (int a = 0; a < 16; a++) { | |||||
| immVertex2f(pos, x + size * si[a], y + size * co[a]); | |||||
| } | |||||
| immEnd(); | |||||
| GPU_line_smooth(false); | |||||
| GPU_blend(false); | |||||
| immUnbindProgram(); | |||||
| /* restore scissortest */ | |||||
| GPU_scissor(scissor[0], scissor[1], scissor[2], scissor[3]); | |||||
| } | |||||
| /* ****************************************************** */ | /* ****************************************************** */ | ||||
| /* TODO: high quality UI drop shadows using GLSL shader and single draw call | /* TODO: high quality UI drop shadows using GLSL shader and single draw call | ||||
| * would replace / modify the following 3 functions - merwin | * would replace / modify the following 3 functions - merwin | ||||
| */ | */ | ||||
| static void ui_shadowbox(uint pos, | static void ui_shadowbox(uint pos, | ||||
| uint color, | uint color, | ||||
| ▲ Show 20 Lines • Show All 171 Lines • Show Last 20 Lines | |||||