Blender V4.3
gpu_matrix.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10#include "gpu_matrix_private.hh"
11
12#define SUPPRESS_GENERIC_MATRIX_API
13#define USE_GPU_PY_MATRIX_API /* only so values are declared */
14#include "GPU_matrix.hh"
15#undef USE_GPU_PY_MATRIX_API
16
17#include "BLI_math_matrix.h"
18#include "BLI_math_rotation.h"
19#include "BLI_math_vector.h"
20
21#include "MEM_guardedalloc.h"
22
23using namespace blender::gpu;
24
25#define MATRIX_STACK_DEPTH 32
26
27using Mat4 = float[4][4];
28using Mat3 = float[3][3];
29
34
38
39 bool dirty;
40
41 /* TODO: cache of derived matrices (Normal, MVP, inverse MVP, etc)
42 * generate as needed for shaders, invalidate when original matrices change
43 *
44 * TODO: separate Model from View transform? Batches/objects have model,
45 * camera/eye has view & projection
46 */
47};
48
49#define ModelViewStack Context::get()->matrix_state->model_view_stack
50#define ModelView ModelViewStack.stack[ModelViewStack.top]
51
52#define ProjectionStack Context::get()->matrix_state->projection_stack
53#define Projection ProjectionStack.stack[ProjectionStack.top]
54
56{
57#define MATRIX_4X4_IDENTITY \
58 { \
59 {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 1.0f, 0.0f}, \
60 { \
61 0.0f, 0.0f, 0.0f, 1.0f \
62 } \
63 }
64
65 GPUMatrixState *state = (GPUMatrixState *)MEM_mallocN(sizeof(*state), __func__);
66 const MatrixStack identity_stack = {{MATRIX_4X4_IDENTITY}, 0};
67
68 state->model_view_stack = state->projection_stack = identity_stack;
69 state->dirty = true;
70
71#undef MATRIX_4X4_IDENTITY
72
73 return state;
74}
75
80
81static void gpu_matrix_state_active_set_dirty(bool value)
82{
84 state->dirty = value;
85}
86
88{
90 state->model_view_stack.top = 0;
91 state->projection_stack.top = 0;
95}
96
97#ifdef WITH_GPU_SAFETY
98
99/* Check if matrix is numerically good */
100static void checkmat(cosnt float *m)
101{
102 const int n = 16;
103 for (int i = 0; i < n; i++) {
104# if _MSC_VER
105 BLI_assert(_finite(m[i]));
106# else
107 BLI_assert(!isinf(m[i]));
108# endif
109 }
110}
111
112# define CHECKMAT(m) checkmat((const float *)m)
113
114#else
115
116# define CHECKMAT(m)
117
118#endif
119
126
133
140
147
148void GPU_matrix_set(const float m[4][4])
149{
151 CHECKMAT(ModelView3D);
153}
154
161
162void GPU_matrix_projection_set(const float m[4][4])
163{
165 CHECKMAT(Projection3D);
167}
168
174
175void GPU_matrix_translate_2f(float x, float y)
176{
177 Mat4 m;
178 unit_m4(m);
179 m[3][0] = x;
180 m[3][1] = y;
182}
183
184void GPU_matrix_translate_2fv(const float vec[2])
185{
186 GPU_matrix_translate_2f(vec[0], vec[1]);
187}
188
189void GPU_matrix_translate_3f(float x, float y, float z)
190{
191#if 1
194#else /* above works well in early testing, below is generic version */
195 Mat4 m;
196 unit_m4(m);
197 m[3][0] = x;
198 m[3][1] = y;
199 m[3][2] = z;
201#endif
203}
204
205void GPU_matrix_translate_3fv(const float vec[3])
206{
207 GPU_matrix_translate_3f(vec[0], vec[1], vec[2]);
208}
209
210void GPU_matrix_scale_1f(float factor)
211{
212 Mat4 m;
213 scale_m4_fl(m, factor);
215}
216
217void GPU_matrix_scale_2f(float x, float y)
218{
219 Mat4 m = {{0.0f}};
220 m[0][0] = x;
221 m[1][1] = y;
222 m[2][2] = 1.0f;
223 m[3][3] = 1.0f;
225}
226
227void GPU_matrix_scale_2fv(const float vec[2])
228{
229 GPU_matrix_scale_2f(vec[0], vec[1]);
230}
231
232void GPU_matrix_scale_3f(float x, float y, float z)
233{
234 Mat4 m = {{0.0f}};
235 m[0][0] = x;
236 m[1][1] = y;
237 m[2][2] = z;
238 m[3][3] = 1.0f;
240}
241
242void GPU_matrix_scale_3fv(const float vec[3])
243{
244 GPU_matrix_scale_3f(vec[0], vec[1], vec[2]);
245}
246
247void GPU_matrix_mul(const float m[4][4])
248{
252}
253
255{
256 /* essentially RotateAxis('Z')
257 * TODO: simpler math for 2D case
258 */
260}
261
262void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
263{
264 const float axis[3] = {x, y, z};
266}
267
268void GPU_matrix_rotate_3fv(float deg, const float axis[3])
269{
270 Mat4 m;
273}
274
275void GPU_matrix_rotate_axis(float deg, char axis)
276{
277 /* rotate_m4 works in place */
281}
282
283static void mat4_ortho_set(
284 float m[4][4], float left, float right, float bottom, float top, float near, float far)
285{
286 m[0][0] = 2.0f / (right - left);
287 m[1][0] = 0.0f;
288 m[2][0] = 0.0f;
289 m[3][0] = -(right + left) / (right - left);
290
291 m[0][1] = 0.0f;
292 m[1][1] = 2.0f / (top - bottom);
293 m[2][1] = 0.0f;
294 m[3][1] = -(top + bottom) / (top - bottom);
295
296 m[0][2] = 0.0f;
297 m[1][2] = 0.0f;
298 m[2][2] = -2.0f / (far - near);
299 m[3][2] = -(far + near) / (far - near);
300
301 m[0][3] = 0.0f;
302 m[1][3] = 0.0f;
303 m[2][3] = 0.0f;
304 m[3][3] = 1.0f;
305
307}
308
310 float m[4][4], float left, float right, float bottom, float top, float near, float far)
311{
312 m[0][0] = 2.0f * near / (right - left);
313 m[1][0] = 0.0f;
314 m[2][0] = (right + left) / (right - left);
315 m[3][0] = 0.0f;
316
317 m[0][1] = 0.0f;
318 m[1][1] = 2.0f * near / (top - bottom);
319 m[2][1] = (top + bottom) / (top - bottom);
320 m[3][1] = 0.0f;
321
322 m[0][2] = 0.0f;
323 m[1][2] = 0.0f;
324 m[2][2] = -(far + near) / (far - near);
325 m[3][2] = -2.0f * far * near / (far - near);
326
327 m[0][3] = 0.0f;
328 m[1][3] = 0.0f;
329 m[2][3] = -1.0f;
330 m[3][3] = 0.0f;
331
333}
334
335static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3])
336{
337 /* This function is loosely based on Mesa implementation.
338 *
339 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
340 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
341 *
342 * Permission is hereby granted, free of charge, to any person obtaining a
343 * copy of this software and associated documentation files (the "Software"),
344 * to deal in the Software without restriction, including without limitation
345 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
346 * and/or sell copies of the Software, and to permit persons to whom the
347 * Software is furnished to do so, subject to the following conditions:
348 *
349 * The above copyright notice including the dates of first publication and
350 * either this permission notice or a reference to
351 * http://oss.sgi.com/projects/FreeB/
352 * shall be included in all copies or substantial portions of the Software.
353 *
354 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
355 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
356 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
357 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
358 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
359 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
360 * SOFTWARE.
361 *
362 * Except as contained in this notice, the name of Silicon Graphics, Inc.
363 * shall not be used in advertising or otherwise to promote the sale, use or
364 * other dealings in this Software without prior written authorization from
365 * Silicon Graphics, Inc.
366 */
367 float side[3];
368
369 normalize_v3(lookdir);
370
371 cross_v3_v3v3(side, lookdir, camup);
372
373 normalize_v3(side);
374
375 cross_v3_v3v3(camup, side, lookdir);
376
377 m[0][0] = side[0];
378 m[1][0] = side[1];
379 m[2][0] = side[2];
380 m[3][0] = 0.0f;
381
382 m[0][1] = camup[0];
383 m[1][1] = camup[1];
384 m[2][1] = camup[2];
385 m[3][1] = 0.0f;
386
387 m[0][2] = -lookdir[0];
388 m[1][2] = -lookdir[1];
389 m[2][2] = -lookdir[2];
390 m[3][2] = 0.0f;
391
392 m[0][3] = 0.0f;
393 m[1][3] = 0.0f;
394 m[2][3] = 0.0f;
395 m[3][3] = 1.0f;
396
398}
399
400void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
401{
402 mat4_ortho_set(Projection, left, right, bottom, top, near, far);
405}
406
407void GPU_matrix_ortho_set_z(float near, float far)
408{
410 Projection[2][2] = -2.0f / (far - near);
411 Projection[3][2] = -(far + near) / (far - near);
413}
414
415void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
416{
417 Mat4 m;
418 mat4_ortho_set(m, left, right, bottom, top, -1.0f, 1.0f);
419 CHECKMAT(Projection2D);
421}
422
424 float left, float right, float bottom, float top, float near, float far)
425{
426 mat4_frustum_set(Projection, left, right, bottom, top, near, far);
429}
430
431void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
432{
433 float half_height = tanf(fovy * float(M_PI / 360.0)) * near;
434 float half_width = half_height * aspect;
435 GPU_matrix_frustum_set(-half_width, +half_width, -half_height, +half_height, near, far);
436}
437
438void GPU_matrix_look_at(float eyeX,
439 float eyeY,
440 float eyeZ,
441 float centerX,
442 float centerY,
443 float centerZ,
444 float upX,
445 float upY,
446 float upZ)
447{
448 Mat4 cm;
449 float lookdir[3];
450 float camup[3] = {upX, upY, upZ};
451
452 lookdir[0] = centerX - eyeX;
453 lookdir[1] = centerY - eyeY;
454 lookdir[2] = centerZ - eyeZ;
455
456 mat4_look_from_origin(cm, lookdir, camup);
457
458 GPU_matrix_mul(cm);
459 GPU_matrix_translate_3f(-eyeX, -eyeY, -eyeZ);
460}
461
462void GPU_matrix_project_3fv(const float world[3],
463 const float model[4][4],
464 const float proj[4][4],
465 const int view[4],
466 float r_win[3])
467{
468 float v[4];
469
470 mul_v4_m4v3(v, model, world);
471 mul_m4_v4(proj, v);
472
473 if (v[3] != 0.0f) {
474 mul_v3_fl(v, 1.0f / v[3]);
475 }
476
477 r_win[0] = view[0] + (view[2] * (v[0] + 1)) * 0.5f;
478 r_win[1] = view[1] + (view[3] * (v[1] + 1)) * 0.5f;
479 r_win[2] = (v[2] + 1) * 0.5f;
480}
481
482void GPU_matrix_project_2fv(const float world[3],
483 const float model[4][4],
484 const float proj[4][4],
485 const int view[4],
486 float r_win[2])
487{
488 float v[4];
489
490 mul_v4_m4v3(v, model, world);
491 mul_m4_v4(proj, v);
492
493 if (v[3] != 0.0f) {
494 mul_v2_fl(v, 1.0f / v[3]);
495 }
496
497 r_win[0] = view[0] + (view[2] * (v[0] + 1)) * 0.5f;
498 r_win[1] = view[1] + (view[3] * (v[1] + 1)) * 0.5f;
499}
500
501bool GPU_matrix_unproject_3fv(const float win[3],
502 const float model_inverted[4][4],
503 const float proj[4][4],
504 const int view[4],
505 float r_world[3])
506{
507 zero_v3(r_world);
508 const float in[3] = {
509 2 * ((win[0] - view[0]) / view[2]) - 1.0f,
510 2 * ((win[1] - view[1]) / view[3]) - 1.0f,
511 2 * win[2] - 1.0f,
512 };
513
527
528 float out[3];
529 const bool is_persp = proj[3][3] == 0.0f;
530 if (is_persp) {
531 out[2] = proj[3][2] / (proj[2][2] + in[2]);
532 if (isinf(out[2])) {
533 out[2] = FLT_MAX;
534 }
535 out[0] = out[2] * ((proj[2][0] + in[0]) / proj[0][0]);
536 out[1] = out[2] * ((proj[2][1] + in[1]) / proj[1][1]);
537 out[2] *= -1;
538 }
539 else {
540 out[0] = (-proj[3][0] + in[0]) / proj[0][0];
541 out[1] = (-proj[3][1] + in[1]) / proj[1][1];
542 out[2] = (-proj[3][2] + in[2]) / proj[2][2];
543 }
544
545 if (!is_finite_v3(out)) {
546 return false;
547 }
548
549 mul_v3_m4v3(r_world, model_inverted, out);
550 return true;
551}
552
553const float (*GPU_matrix_model_view_get(float m[4][4]))[4]
554{
555 if (m) {
557 return m;
558 }
559
560 return ModelView;
561}
562
563const float (*GPU_matrix_projection_get(float m[4][4]))[4]
564{
565 if (m) {
567 return m;
568 }
569
570 return Projection;
571}
572
574{
575 if (m == nullptr) {
576 static Mat4 temp;
577 m = temp;
578 }
579
581 return m;
582}
583
584const float (*GPU_matrix_normal_get(float m[3][3]))[3]
585{
586 if (m == nullptr) {
587 static Mat3 temp3;
588 m = temp3;
589 }
590
591 copy_m3_m4(m, (const float(*)[4])GPU_matrix_model_view_get(nullptr));
592
593 invert_m3(m);
594 transpose_m3(m);
595
596 return m;
597}
598
599const float (*GPU_matrix_normal_inverse_get(float m[3][3]))[3]
600{
601 if (m == nullptr) {
602 static Mat3 temp3;
603 m = temp3;
604 }
605
607 invert_m3(m);
608
609 return m;
610}
611
613{
614 /* set uniform values to matrix stack values
615 * call this before a draw call if desired matrices are dirty
616 * call glUseProgram before this, as glUniform expects program to be bound
617 */
621
625
626 if (MV != -1) {
628 shader, MV, 16, 1, (const float *)GPU_matrix_model_view_get(nullptr));
629 }
630 if (P != -1) {
632 shader, P, 16, 1, (const float *)GPU_matrix_projection_get(nullptr));
633 }
634 if (MVP != -1) {
636 shader, MVP, 16, 1, (const float *)GPU_matrix_model_view_projection_get(nullptr));
637 }
638 if (N != -1) {
639 GPU_shader_uniform_float_ex(shader, N, 9, 1, (const float *)GPU_matrix_normal_get(nullptr));
640 }
641 if (MV_inv != -1) {
642 Mat4 m;
644 invert_m4(m);
645 GPU_shader_uniform_float_ex(shader, MV_inv, 16, 1, (const float *)m);
646 }
647 if (P_inv != -1) {
648 Mat4 m;
650 invert_m4(m);
651 GPU_shader_uniform_float_ex(shader, P_inv, 16, 1, (const float *)m);
652 }
653
655}
656
658{
660 return state->dirty;
661}
662
663/* -------------------------------------------------------------------- */
666
667BLI_STATIC_ASSERT(GPU_PY_MATRIX_STACK_LEN + 1 == MATRIX_STACK_DEPTH, "define mismatch");
668
669/* Return int since caller is may subtract. */
670
672{
674 return int(state->model_view_stack.top);
675}
676
678{
680 return int(state->projection_stack.top);
681}
682
684
685/* -------------------------------------------------------------------- */
691
692float GPU_polygon_offset_calc(const float (*winmat)[4], float viewdist, float dist)
693{
694 /* Seems like we have a factor of 2 more offset than 2.79 for some reason. Correct for this. */
695 dist *= 0.5f;
696
697 if (winmat[3][3] > 0.5f) {
698#if 1
699 return 0.00001f * dist * viewdist; // ortho tweaking
700#else
701 static float depth_fac = 0.0f;
702 if (depth_fac == 0.0f) {
703 /* Hard-code for 24 bit precision. */
704 int depthbits = 24;
705 depth_fac = 1.0f / float((1 << depthbits) - 1);
706 }
707 ofs = (-1.0 / winmat[2][2]) * dist * depth_fac;
708
709 UNUSED_VARS(viewdist);
710#endif
711 }
712
713 /* This adjustment effectively results in reducing the Z value by 0.25%.
714 *
715 * winmat[4][3] actually evaluates to `-2 * far * near / (far - near)`,
716 * is very close to -0.2 with default clip range,
717 * and is used as the coefficient multiplied by `w / z`,
718 * thus controlling the z dependent part of the depth value.
719 */
720 return winmat[3][2] * -0.0025f * dist;
721}
722
723void GPU_polygon_offset(float viewdist, float dist)
724{
725 static float winmat[4][4], offset = 0.0f;
726
727 if (dist != 0.0f) {
728 /* hack below is to mimic polygon offset */
730
731 /* dist is from camera to center point */
732
733 float ofs = GPU_polygon_offset_calc(winmat, viewdist, dist);
734
735 winmat[3][2] -= ofs;
736 offset += ofs;
737 }
738 else {
739 winmat[3][2] += offset;
740 offset = 0.0;
741 }
742
744}
745
#define BLI_STATIC_ASSERT(a, msg)
Definition BLI_assert.h:87
#define BLI_assert(a)
Definition BLI_assert.h:50
#define M_PI
void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void copy_m3_m4(float m1[3][3], const float m2[4][4])
void unit_m4(float m[4][4])
Definition rct.c:1127
void translate_m4(float mat[4][4], float Tx, float Ty, float Tz)
void scale_m4_fl(float R[4][4], float scale)
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void mul_m4_v4(const float mat[4][4], float r[4])
void rotate_m4(float mat[4][4], char axis, float angle)
bool invert_m4(float mat[4][4])
void transpose_m3(float R[3][3])
void mul_m4_m4_post(float R[4][4], const float B[4][4])
bool invert_m3(float mat[3][3])
#define DEG2RADF(_deg)
void axis_angle_to_mat4(float R[4][4], const float axis[3], float angle)
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
bool is_finite_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void zero_v3(float r[3])
MINLINE float normalize_v3(float n[3])
unsigned int uint
#define UNUSED_VARS(...)
static AppView * view
#define GPU_matrix_normal_get(x)
#define GPU_matrix_model_view_get(x)
#define GPU_matrix_set(x)
#define GPU_matrix_mul(x)
#define GPU_matrix_normal_inverse_get(x)
#define GPU_matrix_projection_get(x)
#define GPU_matrix_projection_set(x)
#define GPU_matrix_model_view_projection_get(x)
void GPU_shader_uniform_float_ex(GPUShader *shader, int location, int length, int array_size, const float *value)
@ GPU_UNIFORM_PROJECTION
@ GPU_UNIFORM_MODELVIEW
@ GPU_UNIFORM_PROJECTION_INV
@ GPU_UNIFORM_MODELVIEW_INV
@ GPU_UNIFORM_NORMAL
@ GPU_UNIFORM_MVP
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
Read Guarded memory(de)allocation.
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between world
struct GPUShader GPUShader
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
static Context * get()
GPUMatrixState * matrix_state
#define tanf(x)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
uint top
void GPU_matrix_look_at(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
int GPU_matrix_stack_level_get_projection()
void GPU_matrix_reset()
Definition gpu_matrix.cc:87
GPUMatrixState * GPU_matrix_state_create()
Definition gpu_matrix.cc:55
void GPU_matrix_translate_2fv(const float vec[2])
#define MATRIX_4X4_IDENTITY
void GPU_matrix_rotate_axis(float deg, char axis)
float GPU_polygon_offset_calc(const float(*winmat)[4], float viewdist, float dist)
static void mat4_frustum_set(float m[4][4], float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_identity_projection_set()
void GPU_matrix_project_2fv(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float r_win[2])
void GPU_matrix_ortho_set(float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_identity_set()
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_bind(GPUShader *shader)
#define CHECKMAT(m)
void GPU_matrix_perspective_set(float fovy, float aspect, float near, float far)
void GPU_matrix_scale_2fv(const float vec[2])
void GPU_matrix_frustum_set(float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_ortho_set_z(float near, float far)
void GPU_matrix_ortho_2d_set(float left, float right, float bottom, float top)
void GPU_matrix_push()
#define MATRIX_STACK_DEPTH
Definition gpu_matrix.cc:25
void GPU_matrix_push_projection()
float[3][3] Mat3
Definition gpu_matrix.cc:28
static void mat4_ortho_set(float m[4][4], float left, float right, float bottom, float top, float near, float far)
void GPU_matrix_scale_3fv(const float vec[3])
void GPU_matrix_scale_3f(float x, float y, float z)
int GPU_matrix_stack_level_get_model_view()
static void gpu_matrix_state_active_set_dirty(bool value)
Definition gpu_matrix.cc:81
float[4][4] Mat4
Definition gpu_matrix.cc:27
#define Projection
Definition gpu_matrix.cc:53
#define ModelView
Definition gpu_matrix.cc:50
void GPU_matrix_scale_1f(float factor)
void GPU_matrix_rotate_3fv(float deg, const float axis[3])
void GPU_matrix_rotate_2d(float deg)
void GPU_matrix_pop_projection()
void GPU_matrix_state_discard(GPUMatrixState *state)
Definition gpu_matrix.cc:76
static void mat4_look_from_origin(float m[4][4], float lookdir[3], float camup[3])
bool GPU_matrix_dirty_get()
#define ProjectionStack
Definition gpu_matrix.cc:52
#define ModelViewStack
Definition gpu_matrix.cc:49
bool GPU_matrix_unproject_3fv(const float win[3], const float model_inverted[4][4], const float proj[4][4], const int view[4], float r_world[3])
void GPU_matrix_translate_3fv(const float vec[3])
void GPU_matrix_translate_3f(float x, float y, float z)
void GPU_polygon_offset(float viewdist, float dist)
void GPU_matrix_rotate_3f(float deg, float x, float y, float z)
void GPU_matrix_pop()
void GPU_matrix_project_3fv(const float world[3], const float model[4][4], const float proj[4][4], const int view[4], float r_win[3])
void GPU_matrix_translate_2f(float x, float y)
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
static ulong state[N]
static int left
#define N
#define FLT_MAX
Definition stdcycles.h:14
signed int int32_t
Definition stdint.h:77
MatrixStack model_view_stack
Definition gpu_matrix.cc:36
MatrixStack projection_stack
Definition gpu_matrix.cc:37
Mat4 stack[MATRIX_STACK_DEPTH]
Definition gpu_matrix.cc:31