Blender V4.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
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
23void 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(&region->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
36
37 const uint shdr_pos = GPU_vertformat_attr_add(
39
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
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
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
90
91 GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
92}
MINLINE void mul_v2_fl(float r[2], float f)
unsigned int uint
#define UI_SCALE_FAC
void immUniform4f(const char *name, float x, float y, float z, float w)
void immEnd()
void immUnbindProgram()
void immUniform2f(const char *name, float x, float y)
void immVertex2f(uint attr_id, float x, float y)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1i(const char *name, int x)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_translate_2fv(const float vec[2])
void GPU_matrix_translate_2f(float x, float y)
@ GPU_PRIM_LINES
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void GPU_line_width(float width)
Definition gpu_state.cc:161
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:262
@ GPU_FETCH_FLOAT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1924
void ED_image_draw_cursor(ARegion *region, const float cursor[2])