Blender
V4.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
9
#include "
BLI_utildefines.h
"
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
17
#include "
UI_view2d.hh
"
18
19
#include "
ED_uvedit.hh
"
20
21
/* ------------------------- */
22
23
void
ED_image_draw_cursor
(
ARegion
*region,
const
float
cursor[2])
24
{
25
float
zoom[2], x_fac, y_fac;
26
27
UI_view2d_scale_get_inverse
(®ion->v2d, &zoom[0], &zoom[1]);
28
29
mul_v2_fl
(zoom, 256.0f *
UI_SCALE_FAC
);
30
x_fac = zoom[0];
31
y_fac = zoom[1];
32
33
GPU_line_width
(1.0f);
34
35
GPU_matrix_translate_2fv
(cursor);
36
37
const
uint
shdr_pos =
GPU_vertformat_attr_add
(
38
immVertexFormat
(),
"pos"
,
GPU_COMP_F32
, 2,
GPU_FETCH_FLOAT
);
39
40
immBindBuiltinProgram
(
GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
);
41
42
float
viewport_size[4];
43
GPU_viewport_size_get_f
(viewport_size);
44
immUniform2f
(
"viewport_size"
, viewport_size[2] /
UI_SCALE_FAC
, viewport_size[3] /
UI_SCALE_FAC
);
45
46
immUniform1i
(
"colors_len"
, 2);
/* "advanced" mode */
47
immUniform4f
(
"color"
, 1.0f, 0.0f, 0.0f, 1.0f);
48
immUniform4f
(
"color2"
, 1.0f, 1.0f, 1.0f, 1.0f);
49
immUniform1f
(
"dash_width"
, 8.0f);
50
immUniform1f
(
"udash_factor"
, 0.5f);
51
52
immBegin
(
GPU_PRIM_LINES
, 8);
53
54
immVertex2f
(shdr_pos, -0.05f * x_fac, 0.0f);
55
immVertex2f
(shdr_pos, 0.0f, 0.05f * y_fac);
56
57
immVertex2f
(shdr_pos, 0.0f, 0.05f * y_fac);
58
immVertex2f
(shdr_pos, 0.05f * x_fac, 0.0f);
59
60
immVertex2f
(shdr_pos, 0.05f * x_fac, 0.0f);
61
immVertex2f
(shdr_pos, 0.0f, -0.05f * y_fac);
62
63
immVertex2f
(shdr_pos, 0.0f, -0.05f * y_fac);
64
immVertex2f
(shdr_pos, -0.05f * x_fac, 0.0f);
65
66
immEnd
();
67
68
immUniform4f
(
"color"
, 1.0f, 1.0f, 1.0f, 1.0f);
69
immUniform4f
(
"color2"
, 0.0f, 0.0f, 0.0f, 1.0f);
70
immUniform1f
(
"dash_width"
, 2.0f);
71
immUniform1f
(
"udash_factor"
, 0.5f);
72
73
immBegin
(
GPU_PRIM_LINES
, 8);
74
75
immVertex2f
(shdr_pos, -0.020f * x_fac, 0.0f);
76
immVertex2f
(shdr_pos, -0.1f * x_fac, 0.0f);
77
78
immVertex2f
(shdr_pos, 0.1f * x_fac, 0.0f);
79
immVertex2f
(shdr_pos, 0.020f * x_fac, 0.0f);
80
81
immVertex2f
(shdr_pos, 0.0f, -0.020f * y_fac);
82
immVertex2f
(shdr_pos, 0.0f, -0.1f * y_fac);
83
84
immVertex2f
(shdr_pos, 0.0f, 0.1f * y_fac);
85
immVertex2f
(shdr_pos, 0.0f, 0.020f * y_fac);
86
87
immEnd
();
88
89
immUnbindProgram
();
90
91
GPU_matrix_translate_2f
(-cursor[0], -cursor[1]);
92
}
mul_v2_fl
MINLINE void mul_v2_fl(float r[2], float f)
Definition
math_vector_inline.c:534
uint
unsigned int uint
Definition
BLI_sys_types.h:68
BLI_utildefines.h
DNA_screen_types.h
DNA_userdef_types.h
UI_SCALE_FAC
#define UI_SCALE_FAC
Definition
DNA_userdef_types.h:21
ED_uvedit.hh
GPU_immediate.hh
immUniform4f
void immUniform4f(const char *name, float x, float y, float z, float w)
Definition
gpu_immediate.cc:580
immEnd
void immEnd()
Definition
gpu_immediate.cc:245
immUnbindProgram
void immUnbindProgram()
Definition
gpu_immediate.cc:68
immUniform2f
void immUniform2f(const char *name, float x, float y)
Definition
gpu_immediate.cc:560
immVertex2f
void immVertex2f(uint attr_id, float x, float y)
Definition
gpu_immediate.cc:505
immBindBuiltinProgram
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
Definition
gpu_immediate.cc:61
immUniform1i
void immUniform1i(const char *name, int x)
Definition
gpu_immediate.cc:600
immUniform1f
void immUniform1f(const char *name, float x)
Definition
gpu_immediate.cc:555
immVertexFormat
GPUVertFormat * immVertexFormat()
Definition
gpu_immediate.cc:38
immBegin
void immBegin(GPUPrimType, uint vertex_len)
Definition
gpu_immediate.cc:195
GPU_matrix.hh
GPU_matrix_translate_2fv
void GPU_matrix_translate_2fv(const float vec[2])
Definition
gpu_matrix.cc:184
GPU_matrix_translate_2f
void GPU_matrix_translate_2f(float x, float y)
Definition
gpu_matrix.cc:175
GPU_PRIM_LINES
@ GPU_PRIM_LINES
Definition
GPU_primitive.hh:18
GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
Definition
GPU_shader_builtin.hh:45
GPU_line_width
void GPU_line_width(float width)
Definition
gpu_state.cc:161
GPU_viewport_size_get_f
void GPU_viewport_size_get_f(float coords[4])
Definition
gpu_state.cc:262
GPU_FETCH_FLOAT
@ GPU_FETCH_FLOAT
Definition
GPU_vertex_format.hh:44
GPU_vertformat_attr_add
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
Definition
gpu_vertex_format.cc:124
GPU_COMP_F32
@ GPU_COMP_F32
Definition
GPU_vertex_format.hh:35
UI_view2d.hh
UI_view2d_scale_get_inverse
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
Definition
view2d.cc:1924
ARegion
Definition
DNA_screen_types.h:474
ED_image_draw_cursor
void ED_image_draw_cursor(ARegion *region, const float cursor[2])
Definition
uvedit_draw.cc:23
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0