From 804e90b42d728ecb1073af8d0bae15a91b13a469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 11 Feb 2020 15:18:55 +0100 Subject: DRW: Color Management improvement Reviewed By: brecht sergey jbakker Differential Revision: http://developer.blender.org/D6729 --- source/blender/draw/intern/draw_view.c | 89 ---------------------------------- 1 file changed, 89 deletions(-) (limited to 'source/blender/draw/intern/draw_view.c') diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 58643eb12a8..80a7760a571 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -57,95 +57,6 @@ void DRW_draw_region_info(void) view3d_draw_region_info(draw_ctx->evil_C, ar); } -/* ************************* Background ************************** */ -void DRW_clear_background() -{ - GPU_clear_color(0.0, 0.0, 0.0, 0.0); - GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT | GPU_STENCIL_BIT); -} - -void DRW_draw_background(bool do_alpha_checker) -{ - drw_state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA_UNDER_PREMUL); - if (do_alpha_checker) { - /* Transparent render, do alpha checker. */ - GPU_matrix_push(); - GPU_matrix_identity_set(); - GPU_matrix_identity_projection_set(); - - imm_draw_box_checker_2d(-1.0f, -1.0f, 1.0f, 1.0f); - - GPU_matrix_pop(); - } - else { - float m[4][4]; - unit_m4(m); - - GPUVertFormat *format = immVertexFormat(); - uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - uint color = GPU_vertformat_attr_add( - format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - uchar col_hi[3], col_lo[3]; - - GPU_matrix_push(); - GPU_matrix_identity_set(); - GPU_matrix_projection_set(m); - - immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR_DITHER); - - UI_GetThemeColor3ubv(TH_BACK, col_hi); - UI_GetThemeColor3ubv(UI_GetThemeValue(TH_SHOW_BACK_GRAD) ? TH_BACK_GRAD : TH_BACK, col_lo); - - immBegin(GPU_PRIM_TRI_FAN, 4); - immAttr3ubv(color, col_lo); - immVertex2f(pos, -1.0f, -1.0f); - immVertex2f(pos, 1.0f, -1.0f); - - immAttr3ubv(color, col_hi); - immVertex2f(pos, 1.0f, 1.0f); - immVertex2f(pos, -1.0f, 1.0f); - immEnd(); - - immUnbindProgram(); - - GPU_matrix_pop(); - } -} - -GPUBatch *DRW_draw_background_clipping_batch_from_rv3d(const RegionView3D *rv3d) -{ - const BoundBox *bb = rv3d->clipbb; - const uint clipping_index[6][4] = { - {0, 1, 2, 3}, - {0, 4, 5, 1}, - {4, 7, 6, 5}, - {7, 3, 2, 6}, - {1, 5, 6, 2}, - {7, 4, 0, 3}, - }; - GPUVertBuf *vbo; - GPUIndexBuf *el; - GPUIndexBufBuilder elb = {0}; - - /* Elements */ - GPU_indexbuf_init(&elb, GPU_PRIM_TRIS, ARRAY_SIZE(clipping_index) * 2, ARRAY_SIZE(bb->vec)); - for (int i = 0; i < ARRAY_SIZE(clipping_index); i++) { - const uint *idx = clipping_index[i]; - GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[1], idx[2]); - GPU_indexbuf_add_tri_verts(&elb, idx[0], idx[2], idx[3]); - } - el = GPU_indexbuf_build(&elb); - - GPUVertFormat format = {0}; - uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - - vbo = GPU_vertbuf_create_with_format(&format); - GPU_vertbuf_data_alloc(vbo, ARRAY_SIZE(bb->vec)); - GPU_vertbuf_attr_fill(vbo, pos_id, bb->vec); - - return GPU_batch_create_ex(GPU_PRIM_TRIS, vbo, el, GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); -} - /* **************************** 3D Cursor ******************************** */ static bool is_cursor_visible(const DRWContextState *draw_ctx, Scene *scene, ViewLayer *view_layer) -- cgit v1.2.3