Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GPU_matrix.h « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 13648fdc3bde3c11ceae22857d08d94305f8ebd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#ifndef _GPU_MATRIX_H_
#define _GPU_MATRIX_H_

/*
 * ***** BEGIN GPL LICENSE BLOCK *****
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * The Original Code is Copyright (C) 2012 Blender Foundation.
 * All rights reserved.
 *
 * The Original Code is: all of this file.
 *
 * Contributor(s): Alexandr Kuznetsov, Jason Wilkins, Mike Erwin
 *
 * ***** END GPL LICENSE BLOCK *****
 */

/** \file source/blender/gpu/GPU_matrix.h
 *  \ingroup gpu
 */

#include "GPU_glew.h"
#include <stdbool.h>

#ifdef __cplusplus
extern "C" {
#endif

void gpuMatrixInit(void); /* called by system -- make private? */


/* MatrixMode is conceptually different from GL_MATRIX_MODE */

typedef enum {
	MATRIX_MODE_INACTIVE,
	MATRIX_MODE_2D,
	MATRIX_MODE_3D
} MatrixMode;

MatrixMode gpuMatrixMode(void);

void gpuMatrixBegin2D(void);
void gpuMatrixBegin3D(void);
void gpuMatrixEnd(void);
/* TODO: gpuMatrixResume2D & gpuMatrixResume3D to switch modes but not reset stack */


/* ModelView Matrix (2D or 3D) */

void gpuPushMatrix(void); /* TODO: PushCopy vs PushIdentity? */
void gpuPopMatrix(void);

void gpuLoadIdentity(void);

void gpuScaleUniform(float factor);


/* 3D ModelView Matrix */

void gpuLoadMatrix3D(const float m[4][4]);
void gpuMultMatrix3D(const float m[4][4]);
//const float *gpuGetMatrix3D(float m[4][4]);

void gpuTranslate3f(float x, float y, float z);
void gpuTranslate3fv(const float vec[3]);
void gpuScale3f(float x, float y, float z);
void gpuScale3fv(const float vec[3]);
void gpuRotate3fv(float deg, const float axis[3]); /* axis of rotation should be a unit vector */
void gpuRotateAxis(float deg, char axis); /* TODO: enum for axis? */

void gpuLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ);
/* TODO: variant that takes eye[3], center[3], up[3] */


/* 2D ModelView Matrix */

void gpuLoadMatrix2D(const float m[3][3]);
void gpuMultMatrix2D(const float m[3][3]);

void gpuTranslate2f(float x, float y);
void gpuTranslate2fv(const float vec[2]);
void gpuScale2f(float x, float y);
void gpuScale2fv(const float vec[2]);
void gpuRotate2D(float deg);


/* 3D Projection Matrix */

void gpuOrtho(float left, float right, float bottom, float top, float near, float far);
void gpuFrustum(float left, float right, float bottom, float top, float near, float far);
void gpuPerspective(float fovy, float aspect, float near, float far);

/* pass vector through current transform (world --> screen) */
void gpuProject(const float obj[3], const float model[4][4], const float proj[4][4], const GLint view[4], float win[3]);

/* pass vector through inverse transform (world <-- screen) */
bool gpuUnProject(const float win[3], const float model[4][4], const float proj[4][4], const GLint view[4], float obj[3]);


/* 2D Projection Matrix */

void gpuOrtho2D(float left, float right, float bottom, float top);


#ifdef __cplusplus
}
#endif

#endif /* GPU_MATRIX_H */