Line data Source code
1 0 : /*
2 :
3 : OOOpenGLMatrixManager.m
4 :
5 : Manages OpenGL Model, View, etc. matrices.
6 :
7 : Oolite
8 : Copyright (C) 2004-2014 Giles C Williams and contributors
9 :
10 : This program is free software; you can redistribute it and/or
11 : modify it under the terms of the GNU General Public License
12 : as published by the Free Software Foundation; either version 2
13 : of the License, or (at your option) any later version.
14 :
15 : This program is distributed in the hope that it will be useful,
16 : but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : GNU General Public License for more details.
19 :
20 : You should have received a copy of the GNU General Public License
21 : along with this program; if not, write to the Free Software
22 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 : MA 02110-1301, USA.
24 :
25 : */
26 :
27 : #import "OOOpenGLExtensionManager.h"
28 : #import "OOOpenGLMatrixManager.h"
29 : #import "MyOpenGLView.h"
30 : #import "Universe.h"
31 : #import "OOMacroOpenGL.h"
32 :
33 0 : const char* ooliteStandardMatrixUniforms[] =
34 : {
35 : "ooliteModelView",
36 : "ooliteProjection",
37 : "ooliteModelViewProjection",
38 : "ooliteNormalMatrix",
39 : "ooliteModelViewInverse",
40 : "ooliteProjectionInverse",
41 : "ooliteModelViewProjectionInverse",
42 : "ooliteModelViewTranspose",
43 : "ooliteProjectionTranspose",
44 : "ooliteModelViewProjectionTranspose",
45 : "ooliteModelViewInverseTranspose",
46 : "ooliteProjectionInverseTranspose",
47 : "ooliteModelViewProjectionInverseTranspose"
48 : };
49 :
50 : @implementation OOOpenGLMatrixStack
51 :
52 : - (id) init
53 : {
54 : if ((self = [super init]))
55 : {
56 : stack = [[NSMutableArray alloc] init];
57 : }
58 : return self;
59 : }
60 :
61 : - (void) dealloc
62 : {
63 : [stack release];
64 : [super dealloc];
65 : }
66 :
67 : - (void) push: (OOMatrix) matrix
68 : {
69 : [stack addObject: [NSValue valueWithBytes: &matrix objCType: @encode(OOMatrix)]];
70 : }
71 :
72 : - (OOMatrix) pop
73 : {
74 : if ([stack count] == 0)
75 : {
76 : return kIdentityMatrix;
77 : }
78 : OOMatrix matrix;
79 : [[stack lastObject] getValue: &matrix];
80 : [stack removeLastObject];
81 : return matrix;
82 : }
83 :
84 : - (NSUInteger) stackCount
85 : {
86 : return [stack count];
87 : }
88 :
89 :
90 : @end
91 :
92 : @interface OOOpenGLMatrixManager(Private)
93 :
94 0 : - (void) updateModelView;
95 0 : - (void) updateProjection;
96 :
97 : @end
98 :
99 : @implementation OOOpenGLMatrixManager(Private)
100 :
101 : - (void) updateModelView
102 : {
103 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION] = NO;
104 : valid[OOLITE_GL_MATRIX_NORMAL] = NO;
105 : valid[OOLITE_GL_MATRIX_MODELVIEW_INVERSE] = NO;
106 : valid[OOLITE_GL_MATRIX_PROJECTION_INVERSE] = NO;
107 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE] = NO;
108 : valid[OOLITE_GL_MATRIX_MODELVIEW_TRANSPOSE] = NO;
109 : valid[OOLITE_GL_MATRIX_PROJECTION_TRANSPOSE] = NO;
110 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_TRANSPOSE] = NO;
111 : valid[OOLITE_GL_MATRIX_MODELVIEW_INVERSE_TRANSPOSE] = NO;
112 : valid[OOLITE_GL_MATRIX_PROJECTION_INVERSE_TRANSPOSE] = NO;
113 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE_TRANSPOSE] = NO;
114 : }
115 :
116 : - (void) updateProjection
117 : {
118 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION] = NO;
119 : valid[OOLITE_GL_MATRIX_PROJECTION_INVERSE] = NO;
120 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE] = NO;
121 : valid[OOLITE_GL_MATRIX_PROJECTION_TRANSPOSE] = NO;
122 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_TRANSPOSE] = NO;
123 : valid[OOLITE_GL_MATRIX_PROJECTION_INVERSE_TRANSPOSE] = NO;
124 : valid[OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE_TRANSPOSE] = NO;
125 : }
126 :
127 : @end
128 :
129 : @implementation OOOpenGLMatrixManager
130 :
131 : - (id) init
132 : {
133 : if ((self = [super init]))
134 : {
135 : int i;
136 : for (i = 0; i < OOLITE_GL_MATRIX_END; i++)
137 : {
138 : switch(i)
139 : {
140 : case OOLITE_GL_MATRIX_MODELVIEW:
141 : case OOLITE_GL_MATRIX_PROJECTION:
142 : matrices[i] = kIdentityMatrix;
143 : valid[i] = YES;
144 : break;
145 :
146 : default:
147 : valid[i] = NO;
148 : break;
149 : }
150 : }
151 : modelViewStack = [[OOOpenGLMatrixStack alloc] init];
152 : projectionStack = [[OOOpenGLMatrixStack alloc] init];
153 : }
154 : return self;
155 : }
156 :
157 : - (void) dealloc
158 : {
159 : [modelViewStack release];
160 : [projectionStack release];
161 : [super dealloc];
162 : }
163 :
164 : - (void) loadModelView: (OOMatrix) matrix
165 : {
166 : matrices[OOLITE_GL_MATRIX_MODELVIEW] = matrix;
167 : [self updateModelView];
168 : return;
169 : }
170 :
171 : - (void) resetModelView
172 : {
173 : matrices[OOLITE_GL_MATRIX_MODELVIEW] = kIdentityMatrix;
174 : [self updateModelView];
175 : }
176 :
177 : - (void) multModelView: (OOMatrix) matrix
178 : {
179 : matrices[OOLITE_GL_MATRIX_MODELVIEW] = OOMatrixMultiply(matrix, matrices[OOLITE_GL_MATRIX_MODELVIEW]);
180 : [self updateModelView];
181 : }
182 :
183 : - (void) translateModelView: (Vector) vector
184 : {
185 : OOMatrix matrix = kIdentityMatrix;
186 : matrix.m[3][0] = vector.x;
187 : matrix.m[3][1] = vector.y;
188 : matrix.m[3][2] = vector.z;
189 : [self multModelView: matrix];
190 : }
191 :
192 : - (void) rotateModelView: (GLfloat) angle axis: (Vector) axis
193 : {
194 : [self multModelView: OOMatrixForRotation(axis, angle)];
195 : }
196 :
197 : - (void) scaleModelView: (Vector) scale
198 : {
199 : [self multModelView: OOMatrixForScale(scale.x, scale.y, scale.z)];
200 : }
201 :
202 : - (void) lookAtWithEye: (Vector) eye center: (Vector) center up: (Vector) up
203 : {
204 : Vector k = vector_normal(vector_subtract(eye, center));
205 : Vector i = cross_product(up, k);
206 : Vector j = cross_product(k, i);
207 : OOMatrix m1 = OOMatrixConstruct
208 : (
209 : i.x, j.x, k.x, 0.0,
210 : i.y, j.y, k.y, 0.0,
211 : i.z, j.z, k.z, 0.0,
212 : -eye.x, -eye.y, -eye.z, 1.0
213 : );
214 : [self multModelView: m1];
215 : return;
216 : }
217 :
218 :
219 : - (void) pushModelView
220 : {
221 : [modelViewStack push: matrices[OOLITE_GL_MATRIX_MODELVIEW]];
222 : }
223 :
224 : - (OOMatrix) popModelView
225 : {
226 : matrices[OOLITE_GL_MATRIX_MODELVIEW] = [modelViewStack pop];
227 : [self updateModelView];
228 : return matrices[OOLITE_GL_MATRIX_MODELVIEW];
229 : }
230 :
231 : - (OOMatrix) getModelView
232 : {
233 : return matrices[OOLITE_GL_MATRIX_MODELVIEW];
234 : }
235 :
236 : - (NSUInteger) countModelView
237 : {
238 : return [modelViewStack stackCount];
239 : }
240 :
241 : - (void) syncModelView
242 : {
243 : OO_ENTER_OPENGL();
244 : OOGL(glMatrixMode(GL_MODELVIEW));
245 : GLLoadOOMatrix([self getModelView]);
246 : return;
247 : }
248 :
249 : - (void) loadProjection: (OOMatrix) matrix
250 : {
251 : matrices[OOLITE_GL_MATRIX_PROJECTION] = matrix;
252 : [self updateProjection];
253 : return;
254 : }
255 :
256 : - (void) multProjection: (OOMatrix) matrix
257 : {
258 : matrices[OOLITE_GL_MATRIX_PROJECTION] = OOMatrixMultiply(matrix, matrices[OOLITE_GL_MATRIX_PROJECTION]);
259 : [self updateProjection];
260 : }
261 :
262 : - (void) translateProjection: (Vector) vector
263 : {
264 : OOMatrix matrix = kIdentityMatrix;
265 : matrix.m[0][3] = vector.x;
266 : matrix.m[1][3] = vector.y;
267 : matrix.m[2][3] = vector.z;
268 : [self multProjection: matrix];
269 : }
270 :
271 : - (void) rotateProjection: (GLfloat) angle axis: (Vector) axis
272 : {
273 : [self multProjection: OOMatrixForRotation(axis, angle)];
274 : }
275 :
276 : - (void) scaleProjection: (Vector) scale
277 : {
278 : [self multProjection: OOMatrixForScale(scale.x, scale.y, scale.z)];
279 : }
280 :
281 : - (void) frustumLeft: (double) l right: (double) r bottom: (double) b top: (double) t near: (double) n far: (double) f
282 : {
283 : if (l == r || t == b || n == f || n <= 0 || f <= 0) return;
284 : [self multProjection: OOMatrixConstruct
285 : (
286 : 2*n/(r-l), 0.0, 0.0, 0.0,
287 : 0.0, 2*n/(t-b), 0.0, 0.0,
288 : (r+l)/(r-l), (t+b)/(t-b), -(f+n)/(f-n), -1.0,
289 : 0.0, 0.0, -2*f*n/(f-n), 0.0
290 : )];
291 : }
292 :
293 : - (void) orthoLeft: (double) l right: (double) r bottom: (double) b top: (double) t near: (double) n far: (double) f
294 : {
295 : if (l == r || t == b || n == f) return;
296 : [self multProjection: OOMatrixConstruct
297 : (
298 : 2/(r-l), 0.0, 0.0, 0.0,
299 : 0.0, 2/(t-b), 0.0, 0.0,
300 : 0.0, 0.0, 2/(n-f), 0.0,
301 : (l+r)/(l-r), (b+t)/(b-t), (n+f)/(n-f), 1.0
302 : )];
303 : }
304 :
305 : - (void) perspectiveFovy: (double) fovy aspect: (double) aspect zNear: (double) zNear zFar: (double) zFar
306 : {
307 : if (aspect == 0.0 || zNear == zFar) return;
308 : double f = 1.0/tan(M_PI * fovy / 360);
309 : [self multProjection: OOMatrixConstruct
310 : (
311 : f/aspect, 0.0, 0.0, 0.0,
312 : 0.0, f, 0.0, 0.0,
313 : 0.0, 0.0, (zFar + zNear)/(zNear - zFar), -1.0,
314 : 0.0, 0.0, 2*zFar*zNear/(zNear - zFar), 0.0
315 : )];
316 : }
317 :
318 : - (void) resetProjection
319 : {
320 : matrices[OOLITE_GL_MATRIX_PROJECTION] = kIdentityMatrix;
321 : [self updateProjection];
322 : }
323 :
324 : - (void) pushProjection
325 : {
326 : [projectionStack push: matrices[OOLITE_GL_MATRIX_PROJECTION]];
327 : }
328 :
329 : - (OOMatrix) popProjection
330 : {
331 : matrices[OOLITE_GL_MATRIX_PROJECTION] = [projectionStack pop];
332 : [self updateProjection];
333 : return matrices[OOLITE_GL_MATRIX_PROJECTION];
334 : }
335 :
336 : - (OOMatrix) getProjection
337 : {
338 : return matrices[OOLITE_GL_MATRIX_PROJECTION];
339 : }
340 :
341 : - (void) syncProjection
342 : {
343 : OO_ENTER_OPENGL();
344 : OOGL(glMatrixMode(GL_PROJECTION));
345 : GLLoadOOMatrix([self getProjection]);
346 : return;
347 : }
348 :
349 : - (OOMatrix) getMatrix: (int) which
350 : {
351 : if (which < 0 || which >= OOLITE_GL_MATRIX_END) return kIdentityMatrix;
352 : if (valid[which]) return matrices[which];
353 : OOScalar d;
354 : switch(which)
355 : {
356 : case OOLITE_GL_MATRIX_MODELVIEW_PROJECTION:
357 : matrices[which] = OOMatrixMultiply(matrices[OOLITE_GL_MATRIX_MODELVIEW], matrices[OOLITE_GL_MATRIX_PROJECTION]);
358 : break;
359 : case OOLITE_GL_MATRIX_NORMAL:
360 : matrices[which] = matrices[OOLITE_GL_MATRIX_MODELVIEW];
361 : matrices[which].m[3][0] = 0.0;
362 : matrices[which].m[3][1] = 0.0;
363 : matrices[which].m[3][2] = 0.0;
364 : matrices[which].m[0][3] = 0.0;
365 : matrices[which].m[1][3] = 0.0;
366 : matrices[which].m[2][3] = 0.0;
367 : matrices[which].m[3][3] = 1.0;
368 : matrices[which] = OOMatrixTranspose(OOMatrixInverseWithDeterminant(matrices[which], &d));
369 : if (d != 0.0)
370 : {
371 : d = powf(fabsf(d), 1.0/3);
372 : for (int i = 0; i < 3; i++)
373 : {
374 : for (int j = 0; j < 3; j++)
375 : {
376 : matrices[which].m[i][j] /= d;
377 : }
378 : }
379 : }
380 : break;
381 : case OOLITE_GL_MATRIX_MODELVIEW_INVERSE:
382 : matrices[which] = OOMatrixInverse(matrices[OOLITE_GL_MATRIX_MODELVIEW]);
383 : break;
384 : case OOLITE_GL_MATRIX_PROJECTION_INVERSE:
385 : matrices[which] = OOMatrixInverse(matrices[OOLITE_GL_MATRIX_PROJECTION]);
386 : break;
387 : case OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE:
388 : matrices[which] = OOMatrixInverse([self getMatrix: OOLITE_GL_MATRIX_MODELVIEW_PROJECTION]);
389 : break;
390 : case OOLITE_GL_MATRIX_MODELVIEW_TRANSPOSE:
391 : matrices[which] = OOMatrixTranspose(matrices[OOLITE_GL_MATRIX_MODELVIEW]);
392 : break;
393 : case OOLITE_GL_MATRIX_PROJECTION_TRANSPOSE:
394 : matrices[which] = OOMatrixTranspose(matrices[OOLITE_GL_MATRIX_PROJECTION]);
395 : break;
396 : case OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_TRANSPOSE:
397 : matrices[which] = OOMatrixTranspose([self getMatrix: OOLITE_GL_MATRIX_MODELVIEW_PROJECTION]);
398 : break;
399 : case OOLITE_GL_MATRIX_MODELVIEW_INVERSE_TRANSPOSE:
400 : matrices[which] = OOMatrixTranspose([self getMatrix: OOLITE_GL_MATRIX_MODELVIEW_INVERSE]);
401 : break;
402 : case OOLITE_GL_MATRIX_PROJECTION_INVERSE_TRANSPOSE:
403 : matrices[which] = OOMatrixTranspose([self getMatrix: OOLITE_GL_MATRIX_PROJECTION_INVERSE]);
404 : break;
405 : case OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE_TRANSPOSE:
406 : matrices[which] = OOMatrixTranspose([self getMatrix: OOLITE_GL_MATRIX_MODELVIEW_PROJECTION_INVERSE]);
407 : break;
408 : }
409 : valid[which] = YES;
410 : return matrices[which];
411 : }
412 :
413 : - (NSArray*) standardMatrixUniformLocations: (GLhandleARB) program
414 : {
415 : GLint location;
416 : NSUInteger i;
417 : NSMutableArray *locationSet = [[[NSMutableArray alloc] init] autorelease];
418 :
419 : OO_ENTER_OPENGL();
420 :
421 : for (i = 0; i < OOLITE_GL_MATRIX_END; i++) {
422 : location = glGetUniformLocationARB(program, ooliteStandardMatrixUniforms[i]);
423 : if (location >= 0) {
424 : if (i == OOLITE_GL_MATRIX_NORMAL)
425 : {
426 : [locationSet addObject:
427 : [NSArray arrayWithObjects:
428 : [NSNumber numberWithInt: location],
429 : [NSNumber numberWithInteger: i],
430 : @"mat3",
431 : nil]];
432 : }
433 : else
434 : {
435 : [locationSet addObject:
436 : [NSArray arrayWithObjects:
437 : [NSNumber numberWithInt: location],
438 : [NSNumber numberWithInteger: i],
439 : @"mat4",
440 : nil]];
441 : }
442 : }
443 : }
444 : return [[NSArray arrayWithArray: locationSet] retain];
445 : }
446 :
447 : @end
448 :
449 0 : void OOGLPushModelView()
450 : {
451 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
452 : [matrixManager pushModelView];
453 : [matrixManager syncModelView];
454 : }
455 :
456 0 : OOMatrix OOGLPopModelView()
457 : {
458 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
459 : OOMatrix matrix = [matrixManager popModelView];
460 : [matrixManager syncModelView];
461 : return matrix;
462 : }
463 :
464 0 : OOMatrix OOGLGetModelView()
465 : {
466 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
467 : OOMatrix matrix = [matrixManager getModelView];
468 : return matrix;
469 : }
470 :
471 0 : void OOGLResetModelView()
472 : {
473 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
474 : [matrixManager resetModelView];
475 : [matrixManager syncModelView];
476 : }
477 :
478 0 : void OOGLLoadModelView(OOMatrix matrix)
479 : {
480 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
481 : [matrixManager loadModelView: matrix];
482 : [matrixManager syncModelView];
483 : }
484 :
485 0 : void OOGLMultModelView(OOMatrix matrix)
486 : {
487 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
488 : [matrixManager multModelView: matrix];
489 : [matrixManager syncModelView];
490 : }
491 :
492 0 : void OOGLTranslateModelView(Vector vector)
493 : {
494 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
495 : [matrixManager translateModelView: vector];
496 : [matrixManager syncModelView];
497 : }
498 :
499 0 : void OOGLRotateModelView(GLfloat angle, Vector axis)
500 : {
501 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
502 : [matrixManager rotateModelView: angle axis: axis];
503 : [matrixManager syncModelView];
504 : }
505 :
506 0 : void OOGLScaleModelView(Vector scale)
507 : {
508 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
509 : [matrixManager scaleModelView: scale];
510 : [matrixManager syncModelView];
511 : }
512 :
513 0 : void OOGLLookAt(Vector eye, Vector center, Vector up)
514 : {
515 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
516 : [matrixManager lookAtWithEye: eye center: center up: up];
517 : [matrixManager syncModelView];
518 : }
519 :
520 0 : void OOGLResetProjection()
521 : {
522 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
523 : [matrixManager resetProjection];
524 : [matrixManager syncProjection];
525 : }
526 :
527 0 : void OOGLPushProjection()
528 : {
529 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
530 : [matrixManager pushProjection];
531 : [matrixManager syncProjection];
532 : }
533 :
534 0 : OOMatrix OOGLPopProjection()
535 : {
536 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
537 : OOMatrix matrix = [matrixManager popProjection];
538 : [matrixManager syncProjection];
539 : return matrix;
540 : }
541 :
542 0 : OOMatrix OOGLGetProjection()
543 : {
544 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
545 : OOMatrix matrix = [matrixManager getProjection];
546 : return matrix;
547 : }
548 :
549 0 : void OOGLLoadProjection(OOMatrix matrix)
550 : {
551 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
552 : [matrixManager loadProjection: matrix];
553 : [matrixManager syncProjection];
554 : }
555 :
556 0 : void OOGLMultProjection(OOMatrix matrix)
557 : {
558 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
559 : [matrixManager multProjection: matrix];
560 : [matrixManager syncProjection];
561 : }
562 :
563 0 : void OOGLTranslateProjection(Vector vector)
564 : {
565 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
566 : [matrixManager translateProjection: vector];
567 : [matrixManager syncProjection];
568 : }
569 :
570 0 : void OOGLRotateProjection(GLfloat angle, Vector axis)
571 : {
572 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
573 : [matrixManager rotateProjection: angle axis: axis];
574 : [matrixManager syncProjection];
575 : }
576 :
577 0 : void OOGLScaleProjection(Vector scale)
578 : {
579 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
580 : [matrixManager scaleProjection: scale];
581 : [matrixManager syncProjection];
582 : }
583 :
584 0 : void OOGLFrustum(double frleft, double frright, double frbottom, double frtop, double frnear, double frfar)
585 : {
586 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
587 : [matrixManager frustumLeft: frleft right: frright bottom: frbottom top: frtop near: frnear far: frfar];
588 : [matrixManager syncProjection];
589 : }
590 :
591 0 : void OOGLOrtho(double orleft, double orright, double orbottom, double ortop, double ornear, double orfar)
592 : {
593 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
594 : [matrixManager orthoLeft: orleft right: orright bottom: orbottom top: ortop near: ornear far: orfar];
595 : [matrixManager syncProjection];
596 : }
597 :
598 0 : void OOGLPerspective(double fovy, double aspect, double zNear, double zFar)
599 : {
600 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
601 : [matrixManager perspectiveFovy: fovy aspect: aspect zNear: zNear zFar: zFar];
602 : [matrixManager syncProjection];
603 : }
604 :
605 0 : OOMatrix OOGLGetModelViewProjection()
606 : {
607 : OOOpenGLMatrixManager *matrixManager = [[UNIVERSE gameView] getOpenGLMatrixManager];
608 : return [matrixManager getMatrix: OOLITE_GL_MATRIX_MODELVIEW_PROJECTION];
609 : }
610 :
|