Blender  V3.3
wm_xr_draw.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
11 #include <string.h>
12 
13 #include "BKE_context.h"
14 
15 #include "BLI_listbase.h"
16 #include "BLI_math.h"
17 
18 #include "ED_view3d_offscreen.h"
19 
20 #include "GHOST_C-api.h"
21 #include "GPU_batch_presets.h"
22 #include "GPU_immediate.h"
23 #include "GPU_matrix.h"
24 
25 #include "GPU_viewport.h"
26 
27 #include "WM_api.h"
28 
29 #include "wm_surface.h"
30 #include "wm_xr_intern.h"
31 
32 void wm_xr_pose_to_mat(const GHOST_XrPose *pose, float r_mat[4][4])
33 {
34  quat_to_mat4(r_mat, pose->orientation_quat);
35  copy_v3_v3(r_mat[3], pose->position);
36 }
37 
38 void wm_xr_pose_scale_to_mat(const GHOST_XrPose *pose, float scale, float r_mat[4][4])
39 {
40  wm_xr_pose_to_mat(pose, r_mat);
41 
42  BLI_assert(scale > 0.0f);
43  mul_v3_fl(r_mat[0], scale);
44  mul_v3_fl(r_mat[1], scale);
45  mul_v3_fl(r_mat[2], scale);
46 }
47 
48 void wm_xr_pose_to_imat(const GHOST_XrPose *pose, float r_imat[4][4])
49 {
50  float iquat[4];
51  invert_qt_qt_normalized(iquat, pose->orientation_quat);
52  quat_to_mat4(r_imat, iquat);
53  translate_m4(r_imat, -pose->position[0], -pose->position[1], -pose->position[2]);
54 }
55 
56 void wm_xr_pose_scale_to_imat(const GHOST_XrPose *pose, float scale, float r_imat[4][4])
57 {
58  float iquat[4];
59  invert_qt_qt_normalized(iquat, pose->orientation_quat);
60  quat_to_mat4(r_imat, iquat);
61 
62  BLI_assert(scale > 0.0f);
63  scale = 1.0f / scale;
64  mul_v3_fl(r_imat[0], scale);
65  mul_v3_fl(r_imat[1], scale);
66  mul_v3_fl(r_imat[2], scale);
67 
68  translate_m4(r_imat, -pose->position[0], -pose->position[1], -pose->position[2]);
69 }
70 
71 static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data,
72  const GHOST_XrDrawViewInfo *draw_view,
73  const XrSessionSettings *session_settings,
74  const wmXrSessionState *session_state,
75  float r_viewmat[4][4],
76  float r_projmat[4][4])
77 {
78  GHOST_XrPose eye_pose;
79  float eye_inv[4][4], base_inv[4][4], nav_inv[4][4], m[4][4];
80 
81  /* Calculate inverse eye matrix. */
82  copy_qt_qt(eye_pose.orientation_quat, draw_view->eye_pose.orientation_quat);
83  copy_v3_v3(eye_pose.position, draw_view->eye_pose.position);
84  if ((session_settings->flag & XR_SESSION_USE_POSITION_TRACKING) == 0) {
85  sub_v3_v3(eye_pose.position, draw_view->local_pose.position);
86  }
87  if ((session_settings->flag & XR_SESSION_USE_ABSOLUTE_TRACKING) == 0) {
88  sub_v3_v3(eye_pose.position, draw_data->eye_position_ofs);
89  }
90 
91  wm_xr_pose_to_imat(&eye_pose, eye_inv);
92 
93  /* Apply base pose and navigation. */
94  wm_xr_pose_scale_to_imat(&draw_data->base_pose, draw_data->base_scale, base_inv);
95  wm_xr_pose_scale_to_imat(&session_state->nav_pose_prev, session_state->nav_scale_prev, nav_inv);
96  mul_m4_m4m4(m, eye_inv, base_inv);
97  mul_m4_m4m4(r_viewmat, m, nav_inv);
98 
99  perspective_m4_fov(r_projmat,
100  draw_view->fov.angle_left,
101  draw_view->fov.angle_right,
102  draw_view->fov.angle_up,
103  draw_view->fov.angle_down,
104  session_settings->clip_start,
105  session_settings->clip_end);
106 }
107 
109  const wmXrRuntimeData *runtime_data,
110  const wmXrSurfaceData *surface_data,
111  const GHOST_XrDrawViewInfo *draw_view)
112 {
113  const wmXrViewportPair *vp = BLI_findlink(&surface_data->viewports, draw_view->view_idx);
114  BLI_assert(vp && vp->viewport);
115 
116  const bool is_upside_down = GHOST_XrSessionNeedsUpsideDownDrawing(runtime_data->context);
117  rcti rect = {.xmin = 0, .ymin = 0, .xmax = draw_view->width - 1, .ymax = draw_view->height - 1};
118 
119  wmViewport(&rect);
120 
121  /* For upside down contexts, draw with inverted y-values. */
122  if (is_upside_down) {
123  SWAP(int, rect.ymin, rect.ymax);
124  }
125  GPU_viewport_draw_to_screen_ex(vp->viewport, 0, &rect, draw_view->expects_srgb_buffer, true);
126 }
127 
128 void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
129 {
130  wmXrDrawData *draw_data = customdata;
131  wmXrData *xr_data = draw_data->xr_data;
132  wmXrSurfaceData *surface_data = draw_data->surface_data;
133  wmXrSessionState *session_state = &xr_data->runtime->session_state;
134  XrSessionSettings *settings = &xr_data->session_settings;
135 
136  const int display_flags = V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS | settings->draw_flags;
137 
138  float viewmat[4][4], winmat[4][4];
139 
141 
142  wm_xr_session_draw_data_update(session_state, settings, draw_view, draw_data);
143  wm_xr_draw_matrices_create(draw_data, draw_view, settings, session_state, viewmat, winmat);
144  wm_xr_session_state_update(settings, draw_data, draw_view, session_state);
145 
146  if (!wm_xr_session_surface_offscreen_ensure(surface_data, draw_view)) {
147  return;
148  }
149 
150  const wmXrViewportPair *vp = BLI_findlink(&surface_data->viewports, draw_view->view_idx);
151  BLI_assert(vp && vp->offscreen && vp->viewport);
152 
153  /* In case a framebuffer is still bound from drawing the last eye. */
155  /* Some systems have drawing glitches without this. */
156  GPU_clear_depth(1.0f);
157 
158  /* Draws the view into the surface_data->viewport's frame-buffers. */
160  draw_data->scene,
161  &settings->shading,
162  (eDrawType)settings->shading.type,
164  settings->object_type_exclude_select,
165  draw_view->width,
166  draw_view->height,
167  display_flags,
168  viewmat,
169  winmat,
170  settings->clip_start,
171  settings->clip_end,
172  true,
173  false,
174  true,
175  NULL,
176  false,
177  vp->offscreen,
178  vp->viewport);
179 
180  /* The draw-manager uses both GPUOffscreen and GPUViewport to manage frame and texture buffers. A
181  * call to GPU_viewport_draw_to_screen() is still needed to get the final result from the
182  * viewport buffers composited together and potentially color managed for display on screen.
183  * It needs a bound frame-buffer to draw into, for which we simply reuse the GPUOffscreen one.
184  *
185  * In a next step, Ghost-XR will use the currently bound frame-buffer to retrieve the image
186  * to be submitted to the OpenXR swap-chain. So do not un-bind the off-screen yet! */
187 
188  GPU_offscreen_bind(vp->offscreen, false);
189 
190  wm_xr_draw_viewport_buffers_to_active_framebuffer(xr_data->runtime, surface_data, draw_view);
191 }
192 
193 static GPUBatch *wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_context,
194  const char *subaction_path)
195 {
196  GHOST_XrControllerModelData model_data;
197 
198  if (!GHOST_XrGetControllerModelData(xr_context, subaction_path, &model_data) ||
199  model_data.count_vertices < 1) {
200  return NULL;
201  }
202 
203  GPUVertFormat format = {0};
206 
208  GPU_vertbuf_data_alloc(vbo, model_data.count_vertices);
209  void *vbo_data = GPU_vertbuf_get_data(vbo);
210  memcpy(
211  vbo_data, model_data.vertices, model_data.count_vertices * sizeof(model_data.vertices[0]));
212 
213  GPUIndexBuf *ibo = NULL;
214  if (model_data.count_indices > 0 && ((model_data.count_indices % 3) == 0)) {
215  GPUIndexBufBuilder ibo_builder;
216  const unsigned int prim_len = model_data.count_indices / 3;
217  GPU_indexbuf_init(&ibo_builder, GPU_PRIM_TRIS, prim_len, model_data.count_vertices);
218  for (unsigned int i = 0; i < prim_len; ++i) {
219  const uint32_t *idx = &model_data.indices[i * 3];
220  GPU_indexbuf_add_tri_verts(&ibo_builder, idx[0], idx[1], idx[2]);
221  }
222  ibo = GPU_indexbuf_build(&ibo_builder);
223  }
224 
226 }
227 
228 static void wm_xr_controller_model_draw(const XrSessionSettings *settings,
229  GHOST_XrContextHandle xr_context,
231 {
232  GHOST_XrControllerModelData model_data;
233 
234  float color[4];
235  switch (settings->controller_draw_style) {
238  color[0] = color[1] = color[2] = 0.0f, color[3] = 0.4f;
239  break;
242  color[0] = 0.422f, color[1] = 0.438f, color[2] = 0.446f, color[3] = 0.4f;
243  break;
244  }
245 
248 
249  LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
250  GPUBatch *model = controller->model;
251  if (!model) {
252  model = controller->model = wm_xr_controller_model_batch_create(xr_context,
253  controller->subaction_path);
254  }
255 
256  if (model &&
257  GHOST_XrGetControllerModelData(xr_context, controller->subaction_path, &model_data) &&
258  model_data.count_components > 0) {
260  GPU_batch_uniform_4fv(model, "color", color);
261 
262  GPU_matrix_push();
263  GPU_matrix_mul(controller->grip_mat);
264  for (unsigned int component_idx = 0; component_idx < model_data.count_components;
265  ++component_idx) {
266  const GHOST_XrControllerModelComponent *component = &model_data.components[component_idx];
267  GPU_matrix_push();
268  GPU_matrix_mul(component->transform);
269  GPU_batch_draw_range(model,
270  model->elem ? component->index_offset : component->vertex_offset,
271  model->elem ? component->index_count : component->vertex_count);
272  GPU_matrix_pop();
273  }
274  GPU_matrix_pop();
275  }
276  else {
277  /* Fallback. */
278  const float scale = 0.05f;
279  GPUBatch *sphere = GPU_batch_preset_sphere(2);
281  GPU_batch_uniform_4fv(sphere, "color", color);
282 
283  GPU_matrix_push();
284  GPU_matrix_mul(controller->grip_mat);
285  GPU_matrix_scale_1f(scale);
286  GPU_batch_draw(sphere);
287  GPU_matrix_pop();
288  }
289  }
290 }
291 
293 {
294  bool draw_ray;
295  switch (settings->controller_draw_style) {
298  draw_ray = false;
299  break;
302  draw_ray = true;
303  break;
304  }
305 
310 
311  float viewport[4];
312  GPU_viewport_size_get_f(viewport);
313  immUniform2fv("viewportSize", &viewport[2]);
314 
315  immUniform1f("lineWidth", 3.0f * U.pixelsize);
316 
317  if (draw_ray) {
318  const uchar color[4] = {89, 89, 255, 127};
319  const float scale = settings->clip_end;
320  float ray[3];
321 
324 
325  immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(&state->controllers) * 2);
326 
327  LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
328  const float(*mat)[4] = controller->aim_mat;
329  madd_v3_v3v3fl(ray, mat[3], mat[2], -scale);
330 
331  immAttrSkip(col);
332  immVertex3fv(pos, mat[3]);
334  immVertex3fv(pos, ray);
335  }
336 
337  immEnd();
338  }
339  else {
340  const uchar r[4] = {255, 51, 82, 255};
341  const uchar g[4] = {139, 220, 0, 255};
342  const uchar b[4] = {40, 144, 255, 255};
343  const float scale = 0.01f;
344  float x_axis[3], y_axis[3], z_axis[3];
345 
348 
349  immBegin(GPU_PRIM_LINES, (uint)BLI_listbase_count(&state->controllers) * 6);
350 
351  LISTBASE_FOREACH (wmXrController *, controller, &state->controllers) {
352  const float(*mat)[4] = controller->aim_mat;
353  madd_v3_v3v3fl(x_axis, mat[3], mat[0], scale);
354  madd_v3_v3v3fl(y_axis, mat[3], mat[1], scale);
355  madd_v3_v3v3fl(z_axis, mat[3], mat[2], scale);
356 
357  immAttrSkip(col);
358  immVertex3fv(pos, mat[3]);
359  immAttr4ubv(col, r);
360  immVertex3fv(pos, x_axis);
361 
362  immAttrSkip(col);
363  immVertex3fv(pos, mat[3]);
364  immAttr4ubv(col, g);
365  immVertex3fv(pos, y_axis);
366 
367  immAttrSkip(col);
368  immVertex3fv(pos, mat[3]);
369  immAttr4ubv(col, b);
370  immVertex3fv(pos, z_axis);
371  }
372 
373  immEnd();
374  }
375 
377 }
378 
379 void wm_xr_draw_controllers(const bContext *UNUSED(C), ARegion *UNUSED(region), void *customdata)
380 {
381  wmXrData *xr = customdata;
382  const XrSessionSettings *settings = &xr->session_settings;
383  GHOST_XrContextHandle xr_context = xr->runtime->context;
385 
386  wm_xr_controller_model_draw(settings, xr_context, state);
387  wm_xr_controller_aim_draw(settings, state);
388 }
typedef float(TangentPoint)[2]
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void perspective_m4_fov(float mat[4][4], float angle_left, float angle_right, float angle_up, float angle_down, float nearClip, float farClip)
Definition: math_geom.c:4568
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
Definition: math_matrix.c:259
void translate_m4(float mat[4][4], float tx, float ty, float tz)
Definition: math_matrix.c:2318
void invert_qt_qt_normalized(float q1[4], const float q2[4])
void copy_qt_qt(float q[4], const float a[4])
Definition: math_rotation.c:33
void quat_to_mat4(float mat[4][4], const float q[4])
MINLINE void sub_v3_v3(float r[3], const float a[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
unsigned char uchar
Definition: BLI_sys_types.h:70
unsigned int uint
Definition: BLI_sys_types.h:67
#define SWAP(type, a, b)
#define UNUSED(x)
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:108
eDrawType
@ V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS
@ XR_SESSION_USE_ABSOLUTE_TRACKING
Definition: DNA_xr_types.h:47
@ XR_SESSION_USE_POSITION_TRACKING
Definition: DNA_xr_types.h:46
@ XR_CONTROLLER_DRAW_LIGHT_RAY
Definition: DNA_xr_types.h:60
@ XR_CONTROLLER_DRAW_LIGHT
Definition: DNA_xr_types.h:58
@ XR_CONTROLLER_DRAW_DARK_RAY
Definition: DNA_xr_types.h:59
@ XR_CONTROLLER_DRAW_DARK
Definition: DNA_xr_types.h:57
void ED_view3d_draw_offscreen_simple(struct Depsgraph *depsgraph, struct Scene *scene, struct View3DShading *shading_override, eDrawType drawtype, int object_type_exclude_viewport_override, int object_type_exclude_select_override, int winx, int winy, unsigned int draw_flags, const float viewmat[4][4], const float winmat[4][4], float clip_start, float clip_end, bool is_xr_surface, bool is_image_render, bool draw_background, const char *viewname, bool do_color_management, struct GPUOffScreen *ofs, struct GPUViewport *viewport)
Definition: view3d_draw.c:1723
static Controller * controller
GHOST C-API function and type declarations.
GPUBatch
Definition: GPU_batch.h:78
void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count)
Definition: gpu_batch.cc:229
void GPU_batch_program_set_builtin(GPUBatch *batch, eGPUBuiltinShader shader_id)
Definition: gpu_batch.cc:287
GPUBatch * GPU_batch_create_ex(GPUPrimType prim, GPUVertBuf *vert, GPUIndexBuf *elem, eGPUBatchFlag owns_flag)
Definition: gpu_batch.cc:43
void GPU_batch_draw(GPUBatch *batch)
Definition: gpu_batch.cc:223
#define GPU_batch_uniform_4fv(batch, name, val)
Definition: GPU_batch.h:152
@ GPU_BATCH_OWNS_INDEX
Definition: GPU_batch.h:39
@ GPU_BATCH_OWNS_VBO
Definition: GPU_batch.h:30
struct GPUBatch * GPU_batch_preset_sphere(int lod) ATTR_WARN_UNUSED_RESULT
void GPU_framebuffer_restore(void)
void immUniform2fv(const char *name, const float data[2])
void immAttrSkip(uint attr_id)
void immAttr4ubv(uint attr_id, const unsigned char data[4])
void immUnbindProgram(void)
void immBindBuiltinProgram(eGPUBuiltinShader shader_id)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat(void)
void immVertex3fv(uint attr_id, const float data[3])
void immBegin(GPUPrimType, uint vertex_len)
void immEnd(void)
struct GPUIndexBuf GPUIndexBuf
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
GPUIndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
void GPU_matrix_pop(void)
Definition: gpu_matrix.cc:126
#define GPU_matrix_mul(x)
Definition: GPU_matrix.h:224
void GPU_matrix_push(void)
Definition: gpu_matrix.cc:119
void GPU_matrix_scale_1f(float factor)
Definition: gpu_matrix.cc:209
@ GPU_PRIM_LINES
Definition: GPU_primitive.h:20
@ GPU_PRIM_TRIS
Definition: GPU_primitive.h:21
@ GPU_SHADER_3D_UNIFORM_COLOR
Definition: GPU_shader.h:230
@ GPU_SHADER_3D_POLYLINE_FLAT_COLOR
Definition: GPU_shader.h:262
@ GPU_BLEND_NONE
Definition: GPU_state.h:60
@ GPU_BLEND_ALPHA
Definition: GPU_state.h:62
void GPU_blend(eGPUBlend blend)
Definition: gpu_state.cc:39
@ GPU_DEPTH_LESS_EQUAL
Definition: GPU_state.h:86
@ GPU_DEPTH_NONE
Definition: GPU_state.h:83
void GPU_depth_test(eGPUDepthTest test)
Definition: gpu_state.cc:65
void GPU_viewport_size_get_f(float coords[4])
Definition: gpu_state.cc:259
#define GPU_vertbuf_create_with_format(format)
struct GPUVertBuf GPUVertBuf
void GPU_vertbuf_data_alloc(GPUVertBuf *, uint v_len)
void * GPU_vertbuf_get_data(const GPUVertBuf *verts)
@ GPU_FETCH_FLOAT
@ GPU_FETCH_INT_TO_FLOAT_UNIT
uint GPU_vertformat_attr_add(GPUVertFormat *, const char *name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
@ GPU_COMP_F32
@ GPU_COMP_U8
void GPU_viewport_draw_to_screen_ex(GPUViewport *viewport, int view, const rcti *rect, bool display_colorspace, bool do_overlay_merge)
Definition: gpu_viewport.c:451
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define C
Definition: RandGen.cpp:25
unsigned int U
Definition: btGjkEpa3.h:78
uint pos
uint col
void GPU_clear_depth(float depth)
void GPU_offscreen_bind(GPUOffScreen *ofs, bool save)
const int state
format
Definition: logImageCore.h:38
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
unsigned int uint32_t
Definition: stdint.h:80
int object_type_exclude_select
Definition: DNA_xr_types.h:42
int object_type_exclude_viewport
Definition: DNA_xr_types.h:41
char controller_draw_style
Definition: DNA_xr_types.h:32
struct View3DShading shading
Definition: DNA_xr_types.h:19
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
XrSessionSettings session_settings
struct wmXrRuntimeData * runtime
wmXrData * xr_data
Definition: wm_xr_intern.h:103
float base_scale
Definition: wm_xr_intern.h:111
float eye_position_ofs[3]
Definition: wm_xr_intern.h:114
struct Depsgraph * depsgraph
Definition: wm_xr_intern.h:101
GHOST_XrPose base_pose
Definition: wm_xr_intern.h:109
wmXrSurfaceData * surface_data
Definition: wm_xr_intern.h:104
struct Scene * scene
Definition: wm_xr_intern.h:100
GHOST_XrContextHandle context
Definition: wm_xr_intern.h:65
wmXrSessionState session_state
Definition: wm_xr_intern.h:75
GHOST_XrPose nav_pose_prev
Definition: wm_xr_intern.h:49
ListBase viewports
Definition: wm_xr_intern.h:91
struct GPUViewport * viewport
Definition: wm_xr_intern.h:86
struct GPUOffScreen * offscreen
Definition: wm_xr_intern.h:85
void wmViewport(const rcti *winrct)
Definition: wm_subwindow.c:21
void wm_xr_pose_to_mat(const GHOST_XrPose *pose, float r_mat[4][4])
Definition: wm_xr_draw.c:32
static void wm_xr_draw_viewport_buffers_to_active_framebuffer(const wmXrRuntimeData *runtime_data, const wmXrSurfaceData *surface_data, const GHOST_XrDrawViewInfo *draw_view)
Definition: wm_xr_draw.c:108
static void wm_xr_controller_model_draw(const XrSessionSettings *settings, GHOST_XrContextHandle xr_context, wmXrSessionState *state)
Definition: wm_xr_draw.c:228
static void wm_xr_controller_aim_draw(const XrSessionSettings *settings, wmXrSessionState *state)
Definition: wm_xr_draw.c:292
void wm_xr_pose_scale_to_mat(const GHOST_XrPose *pose, float scale, float r_mat[4][4])
Definition: wm_xr_draw.c:38
static void wm_xr_draw_matrices_create(const wmXrDrawData *draw_data, const GHOST_XrDrawViewInfo *draw_view, const XrSessionSettings *session_settings, const wmXrSessionState *session_state, float r_viewmat[4][4], float r_projmat[4][4])
Definition: wm_xr_draw.c:71
void wm_xr_draw_controllers(const bContext *UNUSED(C), ARegion *UNUSED(region), void *customdata)
Definition: wm_xr_draw.c:379
static GPUBatch * wm_xr_controller_model_batch_create(GHOST_XrContextHandle xr_context, const char *subaction_path)
Definition: wm_xr_draw.c:193
void wm_xr_pose_scale_to_imat(const GHOST_XrPose *pose, float scale, float r_imat[4][4])
Definition: wm_xr_draw.c:56
void wm_xr_draw_view(const GHOST_XrDrawViewInfo *draw_view, void *customdata)
Draw a viewport for a single eye.
Definition: wm_xr_draw.c:128
void wm_xr_pose_to_imat(const GHOST_XrPose *pose, float r_imat[4][4])
Definition: wm_xr_draw.c:48
void wm_xr_session_draw_data_update(wmXrSessionState *state, const XrSessionSettings *settings, const GHOST_XrDrawViewInfo *draw_view, wmXrDrawData *draw_data)
void wm_xr_session_state_update(const XrSessionSettings *settings, const wmXrDrawData *draw_data, const GHOST_XrDrawViewInfo *draw_view, wmXrSessionState *state)
bool wm_xr_session_surface_offscreen_ensure(wmXrSurfaceData *surface_data, const GHOST_XrDrawViewInfo *draw_view)
bool WM_xr_session_is_ready(const wmXrData *xr)