#include "gluos.h"
#include <math.h>
#include <GL/gl.h>
#include "gluint.h"
Go to the source code of this file.
|
static void | __gluMakeIdentityd (GLdouble m[16]) |
|
static void | __gluMakeIdentityf (GLfloat m[16]) |
|
void GLAPIENTRY | gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top) |
|
void GLAPIENTRY | gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) |
|
static void | normalize (float v[3]) |
|
static void | cross (float v1[3], float v2[3], float result[3]) |
|
void GLAPIENTRY | gluLookAt (GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx, GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy, GLdouble upz) |
|
static void | __gluMultMatrixVecd (const GLdouble matrix[16], const GLdouble in[4], GLdouble out[4]) |
|
static int | __gluInvertMatrixd (const GLdouble m[16], GLdouble invOut[16]) |
|
static void | __gluMultMatricesd (const GLdouble a[16], const GLdouble b[16], GLdouble r[16]) |
|
GLint GLAPIENTRY | gluProject (GLdouble objx, GLdouble objy, GLdouble objz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *winx, GLdouble *winy, GLdouble *winz) |
|
GLint GLAPIENTRY | gluUnProject (GLdouble winx, GLdouble winy, GLdouble winz, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLdouble *objx, GLdouble *objy, GLdouble *objz) |
|
GLint GLAPIENTRY | gluUnProject4 (GLdouble winx, GLdouble winy, GLdouble winz, GLdouble clipw, const GLdouble modelMatrix[16], const GLdouble projMatrix[16], const GLint viewport[4], GLclampd nearVal, GLclampd farVal, GLdouble *objx, GLdouble *objy, GLdouble *objz, GLdouble *objw) |
|
void GLAPIENTRY | gluPickMatrix (GLdouble x, GLdouble y, GLdouble deltax, GLdouble deltay, GLint viewport[4]) |
|
◆ __glPi
#define __glPi 3.14159265358979323846 |
◆ __gluInvertMatrixd()
Definition at line 167 of file project.c.
168{
169 double inv[16], det;
171
172 inv[0] =
m[5]*
m[10]*
m[15] -
m[5]*
m[11]*
m[14] -
m[9]*
m[6]*
m[15]
173 +
m[9]*
m[7]*
m[14] +
m[13]*
m[6]*
m[11] -
m[13]*
m[7]*
m[10];
174 inv[4] = -
m[4]*
m[10]*
m[15] +
m[4]*
m[11]*
m[14] +
m[8]*
m[6]*
m[15]
175 -
m[8]*
m[7]*
m[14] -
m[12]*
m[6]*
m[11] +
m[12]*
m[7]*
m[10];
176 inv[8] =
m[4]*
m[9]*
m[15] -
m[4]*
m[11]*
m[13] -
m[8]*
m[5]*
m[15]
177 +
m[8]*
m[7]*
m[13] +
m[12]*
m[5]*
m[11] -
m[12]*
m[7]*
m[9];
178 inv[12] = -
m[4]*
m[9]*
m[14] +
m[4]*
m[10]*
m[13] +
m[8]*
m[5]*
m[14]
179 -
m[8]*
m[6]*
m[13] -
m[12]*
m[5]*
m[10] +
m[12]*
m[6]*
m[9];
180 inv[1] = -
m[1]*
m[10]*
m[15] +
m[1]*
m[11]*
m[14] +
m[9]*
m[2]*
m[15]
181 -
m[9]*
m[3]*
m[14] -
m[13]*
m[2]*
m[11] +
m[13]*
m[3]*
m[10];
182 inv[5] =
m[0]*
m[10]*
m[15] -
m[0]*
m[11]*
m[14] -
m[8]*
m[2]*
m[15]
183 +
m[8]*
m[3]*
m[14] +
m[12]*
m[2]*
m[11] -
m[12]*
m[3]*
m[10];
184 inv[9] = -
m[0]*
m[9]*
m[15] +
m[0]*
m[11]*
m[13] +
m[8]*
m[1]*
m[15]
185 -
m[8]*
m[3]*
m[13] -
m[12]*
m[1]*
m[11] +
m[12]*
m[3]*
m[9];
186 inv[13] =
m[0]*
m[9]*
m[14] -
m[0]*
m[10]*
m[13] -
m[8]*
m[1]*
m[14]
187 +
m[8]*
m[2]*
m[13] +
m[12]*
m[1]*
m[10] -
m[12]*
m[2]*
m[9];
188 inv[2] =
m[1]*
m[6]*
m[15] -
m[1]*
m[7]*
m[14] -
m[5]*
m[2]*
m[15]
189 +
m[5]*
m[3]*
m[14] +
m[13]*
m[2]*
m[7] -
m[13]*
m[3]*
m[6];
190 inv[6] = -
m[0]*
m[6]*
m[15] +
m[0]*
m[7]*
m[14] +
m[4]*
m[2]*
m[15]
191 -
m[4]*
m[3]*
m[14] -
m[12]*
m[2]*
m[7] +
m[12]*
m[3]*
m[6];
192 inv[10] =
m[0]*
m[5]*
m[15] -
m[0]*
m[7]*
m[13] -
m[4]*
m[1]*
m[15]
193 +
m[4]*
m[3]*
m[13] +
m[12]*
m[1]*
m[7] -
m[12]*
m[3]*
m[5];
194 inv[14] = -
m[0]*
m[5]*
m[14] +
m[0]*
m[6]*
m[13] +
m[4]*
m[1]*
m[14]
195 -
m[4]*
m[2]*
m[13] -
m[12]*
m[1]*
m[6] +
m[12]*
m[2]*
m[5];
196 inv[3] = -
m[1]*
m[6]*
m[11] +
m[1]*
m[7]*
m[10] +
m[5]*
m[2]*
m[11]
197 -
m[5]*
m[3]*
m[10] -
m[9]*
m[2]*
m[7] +
m[9]*
m[3]*
m[6];
198 inv[7] =
m[0]*
m[6]*
m[11] -
m[0]*
m[7]*
m[10] -
m[4]*
m[2]*
m[11]
199 +
m[4]*
m[3]*
m[10] +
m[8]*
m[2]*
m[7] -
m[8]*
m[3]*
m[6];
200 inv[11] = -
m[0]*
m[5]*
m[11] +
m[0]*
m[7]*
m[9] +
m[4]*
m[1]*
m[11]
201 -
m[4]*
m[3]*
m[9] -
m[8]*
m[1]*
m[7] +
m[8]*
m[3]*
m[5];
202 inv[15] =
m[0]*
m[5]*
m[10] -
m[0]*
m[6]*
m[9] -
m[4]*
m[1]*
m[10]
203 +
m[4]*
m[2]*
m[9] +
m[8]*
m[1]*
m[6] -
m[8]*
m[2]*
m[5];
204
205 det =
m[0]*inv[0] +
m[1]*inv[4] +
m[2]*inv[8] +
m[3]*inv[12];
206 if (det == 0)
208
209 det = 1.0 / det;
210
211 for (
i = 0;
i < 16;
i++)
212 invOut[
i] = inv[
i] * det;
213
215}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Referenced by gluUnProject(), and gluUnProject4().
◆ __gluMakeIdentityd()
Definition at line 40 of file project.c.
41{
42 m[0+4*0] = 1;
m[0+4*1] = 0;
m[0+4*2] = 0;
m[0+4*3] = 0;
43 m[1+4*0] = 0;
m[1+4*1] = 1;
m[1+4*2] = 0;
m[1+4*3] = 0;
44 m[2+4*0] = 0;
m[2+4*1] = 0;
m[2+4*2] = 1;
m[2+4*3] = 0;
45 m[3+4*0] = 0;
m[3+4*1] = 0;
m[3+4*2] = 0;
m[3+4*3] = 1;
46}
Referenced by gluPerspective().
◆ __gluMakeIdentityf()
Definition at line 48 of file project.c.
49{
50 m[0+4*0] = 1;
m[0+4*1] = 0;
m[0+4*2] = 0;
m[0+4*3] = 0;
51 m[1+4*0] = 0;
m[1+4*1] = 1;
m[1+4*2] = 0;
m[1+4*3] = 0;
52 m[2+4*0] = 0;
m[2+4*1] = 0;
m[2+4*2] = 1;
m[2+4*3] = 0;
53 m[3+4*0] = 0;
m[3+4*1] = 0;
m[3+4*2] = 0;
m[3+4*3] = 1;
54}
Referenced by gluLookAt().
◆ __gluMultMatricesd()
Definition at line 217 of file project.c.
219{
221
222 for (
i = 0;
i < 4;
i++) {
223 for (
j = 0;
j < 4;
j++) {
229 }
230 }
231}
GLdouble GLdouble GLdouble r
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Referenced by gluUnProject(), and gluUnProject4().
◆ __gluMultMatrixVecd()
◆ cross()
◆ gluLookAt()
Definition at line 108 of file project.c.
111{
112 float forward[3], side[3],
up[3];
114
115 forward[0] = centerx - eyex;
116 forward[1] = centery - eyey;
117 forward[2] = centerz - eyez;
118
122
124
125
128
129
131
136
140
141 m[0][2] = -forward[0];
142 m[1][2] = -forward[1];
143 m[2][2] = -forward[2];
144
147}
GLAPI void GLAPIENTRY glMultMatrixf(const GLfloat *m)
GLAPI void GLAPIENTRY glTranslated(GLdouble x, GLdouble y, GLdouble z)
static void __gluMakeIdentityf(GLfloat m[16])
static void cross(float v1[3], float v2[3], float result[3])
static void normalize(float v[3])
◆ gluOrtho2D()
Definition at line 57 of file project.c.
58{
60}
GLAPI void GLAPIENTRY glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val)
GLdouble GLdouble GLdouble GLdouble top
◆ gluPerspective()
Definition at line 65 of file project.c.
66{
68 double sine, cotangent, deltaZ;
69 double radians = fovy / 2 *
__glPi / 180;
70
73 if ((deltaZ == 0) || (sine == 0) || (aspect == 0)) {
74 return;
75 }
76 cotangent =
COS(radians) / sine;
77
79 m[0][0] = cotangent / aspect;
86}
_STLP_DECLSPEC complex< float > _STLP_CALL sin(const complex< float > &)
GLAPI void GLAPIENTRY glMultMatrixd(const GLdouble *m)
GLdouble GLdouble GLdouble GLdouble GLdouble zNear
static void __gluMakeIdentityd(GLdouble m[16])
◆ gluPickMatrix()
Definition at line 348 of file project.c.
350{
351 if (deltax <= 0 || deltay <= 0) {
352 return;
353 }
354
355
357 (viewport[3] - 2 * (
y - viewport[1])) / deltay, 0);
358 glScalef(viewport[2] / deltax, viewport[3] / deltay, 1.0);
359}
GLAPI void GLAPIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLAPI void GLAPIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
◆ gluProject()
Definition at line 234 of file project.c.
239{
242
253
254 in[0] =
in[0] * 0.5 + 0.5;
255 in[1] =
in[1] * 0.5 + 0.5;
256 in[2] =
in[2] * 0.5 + 0.5;
257
258
259 in[0] =
in[0] * viewport[2] + viewport[0];
260 in[1] =
in[1] * viewport[3] + viewport[1];
261
266}
static void __gluMultMatrixVecd(const GLdouble matrix[16], const GLdouble in[4], GLdouble out[4])
◆ gluUnProject()
Definition at line 269 of file project.c.
274{
275 double finalMatrix[16];
278
281
286
287
288 in[0] = (
in[0] - viewport[0]) / viewport[2];
289 in[1] = (
in[1] - viewport[1]) / viewport[3];
290
291
292 in[0] =
in[0] * 2 - 1;
293 in[1] =
in[1] * 2 - 1;
294 in[2] =
in[2] * 2 - 1;
295
305}
static void __gluMultMatricesd(const GLdouble a[16], const GLdouble b[16], GLdouble r[16])
static int __gluInvertMatrixd(const GLdouble m[16], GLdouble invOut[16])
◆ gluUnProject4()
GLint GLAPIENTRY gluUnProject4 |
( |
GLdouble |
winx, |
|
|
GLdouble |
winy, |
|
|
GLdouble |
winz, |
|
|
GLdouble |
clipw, |
|
|
const GLdouble |
modelMatrix[16], |
|
|
const GLdouble |
projMatrix[16], |
|
|
const GLint |
viewport[4], |
|
|
GLclampd |
nearVal, |
|
|
GLclampd |
farVal, |
|
|
GLdouble * |
objx, |
|
|
GLdouble * |
objy, |
|
|
GLdouble * |
objz, |
|
|
GLdouble * |
objw |
|
) |
| |
Definition at line 308 of file project.c.
315{
316 double finalMatrix[16];
319
322
327
328
329 in[0] = (
in[0] - viewport[0]) / viewport[2];
330 in[1] = (
in[1] - viewport[1]) / viewport[3];
331 in[2] = (
in[2] - nearVal) / (farVal - nearVal);
332
333
334 in[0] =
in[0] * 2 - 1;
335 in[1] =
in[1] * 2 - 1;
336 in[2] =
in[2] * 2 - 1;
337
345}
◆ normalize()
Definition at line 88 of file project.c.
89{
91
94
98}
_STLP_DECLSPEC complex< float > _STLP_CALL sqrt(const complex< float > &)
Referenced by gluLookAt().