Blender V5.3
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
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
22namespace blender {
23
24/* ------------------------- */
25
26void 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(&region->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
39
40 const uint shdr_pos = GPU_vertformat_attr_add(
41 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
42
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
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
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
93
94 GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
95}
96
97} // namespace blender
#define UI_SCALE_FAC
void view2d_pixel_size_get(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1911
BMesh Iterators.
void ED_image_draw_cursor(ARegion *region, const float cursor[2])
void immEnd()
unsigned int uint
Definition BKE_text.h:55
MINLINE void mul_v2_fl(float r[2], float f)
void immUniform2f(const char *name, float x, float y)
GPUVertFormat * immVertexFormat()
void immBegin(GPUPrimType, uint vertex_len)
void immUnbindProgram()
void GPU_line_width(float width)
Definition gpu_state.cc:151
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void GPU_matrix_translate_2f(float x, float y)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void immUniform4f(const char *name, float x, float y, float z, float w)
void GPU_matrix_translate_2fv(const float vec[2])
void immUniform1i(const char *name, int x)