Blender V4.3
overlay_next_speaker.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
12
13#include "DNA_speaker_types.h"
14
15namespace blender::draw::overlay {
16
17class Speakers {
19
20 private:
21 const SelectionType selection_type_;
22
23 PassSimple ps_ = {"Speakers"};
24
25 SpeakerInstanceBuf speaker_buf_ = {selection_type_, "speaker_data_buf"};
26
27 public:
28 Speakers(const SelectionType selection_type) : selection_type_(selection_type){};
29
31 {
32 speaker_buf_.clear();
33 }
34
35 void object_sync(const ObjectRef &ob_ref, Resources &res, const State &state)
36 {
37 const float4 color = res.object_wire_color(ob_ref, state);
38 const select::ID select_id = res.select_id(ob_ref);
39
40 speaker_buf_.append({ob_ref.object->object_to_world(), color, 1.0f}, select_id);
41 }
42
43 void end_sync(Resources &res, ShapeCache &shapes, const State &state)
44 {
45 ps_.init();
47 state.clipping_plane_count);
48 ps_.shader_set(res.shaders.extra_shape.get());
49 ps_.bind_ubo("globalsBlock", &res.globals_buf);
50 res.select_bind(ps_);
51
52 speaker_buf_.end_sync(ps_, shapes.speaker.get());
53 }
54
55 void draw(Framebuffer &framebuffer, Manager &manager, View &view)
56 {
57 GPU_framebuffer_bind(framebuffer);
58 manager.submit(ps_, view);
59 }
60};
61
62} // namespace blender::draw::overlay
void GPU_framebuffer_bind(GPUFrameBuffer *framebuffer)
void submit(PassSimple &pass, View &view)
void state_set(DRWState state, int clip_plane_count=0)
Definition draw_pass.hh:954
void bind_ubo(const char *name, GPUUniformBuf *buffer)
void shader_set(GPUShader *shader)
Definition draw_pass.hh:971
void object_sync(const ObjectRef &ob_ref, Resources &res, const State &state)
void end_sync(Resources &res, ShapeCache &shapes, const State &state)
Speakers(const SelectionType selection_type)
void draw(Framebuffer &framebuffer, Manager &manager, View &view)
@ DRW_STATE_WRITE_DEPTH
Definition draw_state.hh:29
@ DRW_STATE_WRITE_COLOR
Definition draw_state.hh:30
@ DRW_STATE_DEPTH_LESS_EQUAL
Definition draw_state.hh:38
static ulong state[N]
const float4 & object_wire_color(const ObjectRef &ob_ref, ThemeColorID theme_id) const
void end_sync(PassSimple::Sub &pass, gpu::Batch *shape)
void append(const InstanceDataT &data, select::ID select_id)
void select_bind(PassSimple &pass)
const ID select_id(const ObjectRef &ob_ref, uint sub_object_id=0)