Blender V5.0
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.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#include "GPU_state.hh"
17
18#include "UI_view2d.hh"
19
20#include "ED_uvedit.hh"
21
22/* ------------------------- */
23
24void ED_image_draw_cursor(ARegion *region, const float cursor[2])
25{
26 float zoom[2], x_fac, y_fac;
27
28 UI_view2d_scale_get_inverse(&region->v2d, &zoom[0], &zoom[1]);
29
30 mul_v2_fl(zoom, 256.0f * UI_SCALE_FAC);
31 x_fac = zoom[0];
32 y_fac = zoom[1];
33
34 GPU_line_width(1.0f);
35
37
38 const uint shdr_pos = GPU_vertformat_attr_add(
39 immVertexFormat(), "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
40
42
43 float viewport_size[4];
44 GPU_viewport_size_get_f(viewport_size);
45 immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
46
47 immUniform1i("colors_len", 2); /* "advanced" mode */
48 immUniform4f("color", 1.0f, 0.0f, 0.0f, 1.0f);
49 immUniform4f("color2", 1.0f, 1.0f, 1.0f, 1.0f);
50 immUniform1f("dash_width", 8.0f);
51 immUniform1f("udash_factor", 0.5f);
52
54
55 immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f);
56 immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac);
57
58 immVertex2f(shdr_pos, 0.0f, 0.05f * y_fac);
59 immVertex2f(shdr_pos, 0.05f * x_fac, 0.0f);
60
61 immVertex2f(shdr_pos, 0.05f * x_fac, 0.0f);
62 immVertex2f(shdr_pos, 0.0f, -0.05f * y_fac);
63
64 immVertex2f(shdr_pos, 0.0f, -0.05f * y_fac);
65 immVertex2f(shdr_pos, -0.05f * x_fac, 0.0f);
66
67 immEnd();
68
69 immUniform4f("color", 1.0f, 1.0f, 1.0f, 1.0f);
70 immUniform4f("color2", 0.0f, 0.0f, 0.0f, 1.0f);
71 immUniform1f("dash_width", 2.0f);
72 immUniform1f("udash_factor", 0.5f);
73
75
76 immVertex2f(shdr_pos, -0.020f * x_fac, 0.0f);
77 immVertex2f(shdr_pos, -0.1f * x_fac, 0.0f);
78
79 immVertex2f(shdr_pos, 0.1f * x_fac, 0.0f);
80 immVertex2f(shdr_pos, 0.020f * x_fac, 0.0f);
81
82 immVertex2f(shdr_pos, 0.0f, -0.020f * y_fac);
83 immVertex2f(shdr_pos, 0.0f, -0.1f * y_fac);
84
85 immVertex2f(shdr_pos, 0.0f, 0.1f * y_fac);
86 immVertex2f(shdr_pos, 0.0f, 0.020f * y_fac);
87
88 immEnd();
89
91
92 GPU_matrix_translate_2f(-cursor[0], -cursor[1]);
93}
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 immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immUniform2f(const char *name, float x, float y)
void immVertex2f(uint attr_id, float x, float y)
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:166
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:273
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1929
void ED_image_draw_cursor(ARegion *region, const float cursor[2])