Blender
V5.3
source
blender
editors
uvedit
uvedit_draw.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#include "
BLI_math_vector_c.hh
"
10
11
#include "
DNA_screen_types.h
"
12
#include "
DNA_userdef_types.h
"
13
14
#include "
GPU_immediate.hh
"
15
#include "
GPU_matrix.hh
"
16
#include "
GPU_state.hh
"
17
18
#include "
UI_view2d.hh
"
19
20
#include "
ED_uvedit.hh
"
21
22
namespace
blender
{
23
24
/* ------------------------- */
25
26
void
ED_image_draw_cursor
(
ARegion
*region,
const
float
cursor[2])
27
{
28
float
zoom[2], x_fac, y_fac;
29
30
ui::view2d_pixel_size_get
(®ion->
v2d
, &zoom[0], &zoom[1]);
31
32
mul_v2_fl
(zoom, 256.0f *
UI_SCALE_FAC
);
33
x_fac = zoom[0];
34
y_fac = zoom[1];
35
36
GPU_line_width
(1.0f);
37
38
GPU_matrix_translate_2fv
(cursor);
39
40
const
uint
shdr_pos =
GPU_vertformat_attr_add
(
41
immVertexFormat
(),
"pos"
, gpu::VertAttrType::SFLOAT_32_32);
42
43
immBindBuiltinProgram
(
GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
);
44
45
float
viewport_size[4];
46
GPU_viewport_size_get_f
(viewport_size);
47
immUniform2f
(
"viewport_size"
, viewport_size[2] /
UI_SCALE_FAC
, viewport_size[3] /
UI_SCALE_FAC
);
48
49
immUniform1i
(
"colors_len"
, 2);
/* "advanced" mode */
50
immUniform4f
(
"color"
, 1.0f, 0.0f, 0.0f, 1.0f);
51
immUniform4f
(
"color2"
, 1.0f, 1.0f, 1.0f, 1.0f);
52
immUniform1f
(
"dash_width"
, 8.0f);
53
immUniform1f
(
"udash_factor"
, 0.5f);
54
55
immBegin
(
GPU_PRIM_LINES
, 8);
56
57
immVertex2f
(shdr_pos, -0.05f * x_fac, 0.0f);
58
immVertex2f
(shdr_pos, 0.0f, 0.05f * y_fac);
59
60
immVertex2f
(shdr_pos, 0.0f, 0.05f * y_fac);
61
immVertex2f
(shdr_pos, 0.05f * x_fac, 0.0f);
62
63
immVertex2f
(shdr_pos, 0.05f * x_fac, 0.0f);
64
immVertex2f
(shdr_pos, 0.0f, -0.05f * y_fac);
65
66
immVertex2f
(shdr_pos, 0.0f, -0.05f * y_fac);
67
immVertex2f
(shdr_pos, -0.05f * x_fac, 0.0f);
68
69
immEnd
();
70
71
immUniform4f
(
"color"
, 1.0f, 1.0f, 1.0f, 1.0f);
72
immUniform4f
(
"color2"
, 0.0f, 0.0f, 0.0f, 1.0f);
73
immUniform1f
(
"dash_width"
, 2.0f);
74
immUniform1f
(
"udash_factor"
, 0.5f);
75
76
immBegin
(
GPU_PRIM_LINES
, 8);
77
78
immVertex2f
(shdr_pos, -0.020f * x_fac, 0.0f);
79
immVertex2f
(shdr_pos, -0.1f * x_fac, 0.0f);
80
81
immVertex2f
(shdr_pos, 0.1f * x_fac, 0.0f);
82
immVertex2f
(shdr_pos, 0.020f * x_fac, 0.0f);
83
84
immVertex2f
(shdr_pos, 0.0f, -0.020f * y_fac);
85
immVertex2f
(shdr_pos, 0.0f, -0.1f * y_fac);
86
87
immVertex2f
(shdr_pos, 0.0f, 0.1f * y_fac);
88
immVertex2f
(shdr_pos, 0.0f, 0.020f * y_fac);
89
90
immEnd
();
91
92
immUnbindProgram
();
93
94
GPU_matrix_translate_2f
(-cursor[0], -cursor[1]);
95
}
96
97
}
// namespace blender
BLI_math_vector_c.hh
DNA_screen_types.h
UI_SCALE_FAC
#define UI_SCALE_FAC
Definition
DNA_theme_types.h:21
DNA_userdef_types.h
ED_uvedit.hh
GPU_immediate.hh
GPU_matrix.hh
GPU_state.hh
UI_view2d.hh
blender::ui::view2d_pixel_size_get
void view2d_pixel_size_get(const View2D *v2d, float *r_x, float *r_y)
Definition
view2d.cc:1911
blender
BMesh Iterators.
Definition
ANIM_action.hh:30
blender::ED_image_draw_cursor
void ED_image_draw_cursor(ARegion *region, const float cursor[2])
Definition
uvedit_draw.cc:26
blender::immEnd
void immEnd()
Definition
gpu_immediate.cc:252
blender::uint
unsigned int uint
Definition
BKE_text.h:55
blender::mul_v2_fl
MINLINE void mul_v2_fl(float r[2], float f)
Definition
math_vector_inline.cc:402
blender::immUniform2f
void immUniform2f(const char *name, float x, float y)
Definition
gpu_immediate.cc:588
blender::immVertexFormat
GPUVertFormat * immVertexFormat()
Definition
gpu_immediate.cc:41
blender::immBegin
void immBegin(GPUPrimType, uint vertex_len)
Definition
gpu_immediate.cc:202
blender::GPU_PRIM_LINES
@ GPU_PRIM_LINES
Definition
GPU_primitive.hh:20
blender::immUnbindProgram
void immUnbindProgram()
Definition
gpu_immediate.cc:70
blender::GPU_line_width
void GPU_line_width(float width)
Definition
gpu_state.cc:151
blender::immBindBuiltinProgram
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
Definition
gpu_immediate.cc:63
blender::immUniform1f
void immUniform1f(const char *name, float x)
Definition
gpu_immediate.cc:583
blender::immVertex2f
void immVertex2f(uint attr_id, float x, float y)
Definition
gpu_immediate.cc:539
blender::GPU_viewport_size_get_f
void GPU_viewport_size_get_f(float coords[4])
Definition
gpu_state.cc:258
blender::GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
Definition
GPU_shader_builtin.hh:46
blender::GPU_matrix_translate_2f
void GPU_matrix_translate_2f(float x, float y)
Definition
gpu_matrix.cc:175
blender::GPU_vertformat_attr_add
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
Definition
gpu_vertex_format.cc:389
blender::immUniform4f
void immUniform4f(const char *name, float x, float y, float z, float w)
Definition
gpu_immediate.cc:608
blender::GPU_matrix_translate_2fv
void GPU_matrix_translate_2fv(const float vec[2])
Definition
gpu_matrix.cc:184
blender::immUniform1i
void immUniform1i(const char *name, int x)
Definition
gpu_immediate.cc:629
blender::ARegion
Definition
DNA_screen_types.h:811
blender::ARegion::v2d
View2D v2d
Definition
DNA_screen_types.h:815
Generated on
for Blender by
doxygen
1.18.0