Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/overlay/overlay_background.cc
- This file was moved from source/blender/draw/engines/overlay/overlay_background.c.
| /* SPDX-License-Identifier: GPL-2.0-or-later | /* SPDX-License-Identifier: GPL-2.0-or-later | ||||
| * Copyright 2020 Blender Foundation. */ | * Copyright 2020 Blender Foundation. */ | ||||
| /** \file | /** \file | ||||
| * \ingroup draw_engine | * \ingroup draw_engine | ||||
| */ | */ | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "draw_manager_text.h" | #include "draw_manager_text.h" | ||||
| #include "overlay_private.h" | #include "overlay_private.hh" | ||||
| void OVERLAY_background_cache_init(OVERLAY_Data *vedata) | void OVERLAY_background_cache_init(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| OVERLAY_PrivateData *pd = vedata->stl->pd; | OVERLAY_PrivateData *pd = vedata->stl->pd; | ||||
| DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene = draw_ctx->scene; | const Scene *scene = draw_ctx->scene; | ||||
| const RegionView3D *rv3d = draw_ctx->rv3d; | const RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| const BoundBox *bb = rv3d ? rv3d->clipbb : NULL; | const BoundBox *bb = rv3d ? rv3d->clipbb : nullptr; | ||||
| const View3D *v3d = draw_ctx->v3d; | const View3D *v3d = draw_ctx->v3d; | ||||
| bool draw_clipping_bounds = (pd->clipping_state != 0); | bool draw_clipping_bounds = (pd->clipping_state != 0); | ||||
| { | { | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_BACKGROUND; | ||||
| float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | float color_override[4] = {0.0f, 0.0f, 0.0f, 0.0f}; | ||||
| int background_type; | int background_type; | ||||
| ▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | bool draw_clipping_bounds = (pd->clipping_state != 0); | ||||
| GPUShader *sh = OVERLAY_shader_background(); | GPUShader *sh = OVERLAY_shader_background(); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->background_ps); | DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->background_ps); | ||||
| DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color); | DRW_shgroup_uniform_texture_ref(grp, "colorBuffer", &dtxl->color); | ||||
| DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override); | DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override); | ||||
| DRW_shgroup_uniform_int_copy(grp, "bgType", background_type); | DRW_shgroup_uniform_int_copy(grp, "bgType", background_type); | ||||
| DRW_shgroup_call_procedural_triangles(grp, NULL, 1); | DRW_shgroup_call_procedural_triangles(grp, nullptr, 1); | ||||
| } | } | ||||
| if (draw_clipping_bounds) { | if (draw_clipping_bounds) { | ||||
| DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK; | DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_BLEND_ALPHA | DRW_STATE_CULL_BACK; | ||||
| DRW_PASS_CREATE(psl->clipping_frustum_ps, state); | DRW_PASS_CREATE(psl->clipping_frustum_ps, state); | ||||
| GPUShader *sh = OVERLAY_shader_clipbound(); | GPUShader *sh = OVERLAY_shader_clipbound(); | ||||
| DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->clipping_frustum_ps); | DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->clipping_frustum_ps); | ||||
| DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_clipping_border); | DRW_shgroup_uniform_vec4_copy(grp, "color", G_draw.block.color_clipping_border); | ||||
| DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8); | DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8); | ||||
| struct GPUBatch *cube = DRW_cache_cube_get(); | struct GPUBatch *cube = DRW_cache_cube_get(); | ||||
| DRW_shgroup_call(grp, cube, NULL); | DRW_shgroup_call(grp, cube, nullptr); | ||||
| } | } | ||||
| else { | else { | ||||
| psl->clipping_frustum_ps = NULL; | psl->clipping_frustum_ps = nullptr; | ||||
| } | } | ||||
| } | } | ||||
| void OVERLAY_background_draw(OVERLAY_Data *vedata) | void OVERLAY_background_draw(OVERLAY_Data *vedata) | ||||
| { | { | ||||
| OVERLAY_PassList *psl = vedata->psl; | OVERLAY_PassList *psl = vedata->psl; | ||||
| if (DRW_state_is_fbo()) { | if (DRW_state_is_fbo()) { | ||||
| if (psl->clipping_frustum_ps) { | if (psl->clipping_frustum_ps) { | ||||
| DRW_draw_pass(psl->clipping_frustum_ps); | DRW_draw_pass(psl->clipping_frustum_ps); | ||||
| } | } | ||||
| DRW_draw_pass(psl->background_ps); | DRW_draw_pass(psl->background_ps); | ||||
| } | } | ||||
| } | } | ||||