1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
25 #include <NCollection_Mat4.hxx>
27 #include <OpenGl_Context.hxx>
28 #include <OpenGl_Display.hxx>
29 #include <OpenGl_GlCore11.hxx>
30 #include <OpenGl_GraduatedTrihedron.hxx>
31 #include <OpenGl_ShaderManager.hxx>
32 #include <OpenGl_Texture.hxx>
33 #include <OpenGl_Trihedron.hxx>
34 #include <OpenGl_transform_persistence.hxx>
35 #include <OpenGl_View.hxx>
36 #include <OpenGl_Workspace.hxx>
38 #include <Graphic3d_TextureEnv.hxx>
40 IMPLEMENT_STANDARD_HANDLE(OpenGl_View,MMgt_TShared)
41 IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,MMgt_TShared)
43 /*----------------------------------------------------------------------*/
45 static const OPENGL_BG_TEXTURE myDefaultBgTexture = { 0, 0, 0, Aspect_FM_CENTERED };
46 static const OPENGL_BG_GRADIENT myDefaultBgGradient = { {{ 0.F, 0.F, 0.F, 1.F }}, {{ 0.F, 0.F, 0.F, 1.F }}, Aspect_GFM_NONE };
47 static const Tmatrix3 myDefaultMatrix = { { 1.F, 0.F, 0.F, 0.F }, { 0.F, 1.F, 0.F, 0.F }, { 0.F, 0.F, 1.F, 0.F }, { 0.F, 0.F, 0.F, 1.F } };
48 static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
49 static const OPENGL_EXTRA_REP myDefaultExtra =
60 { 0.F, 0.F, 1.F, 1.F },
62 { 0.F, 0.F, 0.F, 1.F, 1.F, 1.F },
78 static const OPENGL_FOG myDefaultFog = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
79 static const TEL_TRANSFORM_PERSISTENCE myDefaultTransPers = { 0, 0.F, 0.F, 0.F };
80 static const GLdouble THE_IDENTITY_MATRIX[4][4] =
88 /*----------------------------------------------------------------------*/
90 OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext)
91 : mySurfaceDetail(Visual3d_TOD_NONE),
93 myBgTexture(myDefaultBgTexture),
94 myBgGradient(myDefaultBgGradient),
95 //myOrientationMatrix(myDefaultMatrix),
96 //myMappingMatrix(myDefaultMatrix),
97 //shield_indicator = TOn,
98 //shield_colour = { { 0.F, 0.F, 0.F, 1.F } },
99 //border_indicator = TOff,
100 //border_colour = { { 0.F, 0.F, 0.F, 1.F } },
101 //active_status = TOn,
102 myZClip(myDefaultZClip),
103 myExtra(myDefaultExtra),
106 myGraduatedTrihedron(NULL),
107 myVisualization(AContext.Visualization),
108 myIntShadingMethod(TEL_SM_GOURAUD),
109 myAntiAliasing(Standard_False),
110 myTransPers(&myDefaultTransPers),
111 myIsTransPers(Standard_False),
112 myOrientationChanged (Standard_True),
113 myViewMappingChanged (Standard_True),
114 myLightSourcesChanged (Standard_True)
116 // Initialize matrices
117 memcpy(myOrientationMatrix,myDefaultMatrix,sizeof(Tmatrix3));
118 memcpy(myMappingMatrix,myDefaultMatrix,sizeof(Tmatrix3));
121 switch (AContext.Model)
123 case 1 : /* VISUAL3D_TOM_INTERP_COLOR */
124 case 3 : /* VISUAL3D_TOM_VERTEX */
125 myIntShadingMethod = TEL_SM_GOURAUD;
128 myIntShadingMethod = TEL_SM_FLAT;
133 myModificationState = 1; // initial state
137 /*----------------------------------------------------------------------*/
139 OpenGl_View::~OpenGl_View ()
141 ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
144 void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
146 OpenGl_Element::Destroy (theCtx, myTrihedron);
147 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
149 if (!myTextureEnv.IsNull())
151 theCtx->DelayedRelease (myTextureEnv);
152 myTextureEnv.Nullify();
154 if (myBgTexture.TexId != 0)
156 glDeleteTextures (1, (GLuint*)&(myBgTexture.TexId));
157 myBgTexture.TexId = 0;
161 void OpenGl_View::SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
162 const Handle(Graphic3d_TextureEnv)& theTexture)
164 if (!myTextureEnv.IsNull())
166 theCtx->DelayedRelease (myTextureEnv);
167 myTextureEnv.Nullify();
170 if (theTexture.IsNull())
175 myTextureEnv = new OpenGl_Texture (theTexture->GetParams());
176 Handle(Image_PixMap) anImage = theTexture->GetImage();
177 if (!anImage.IsNull())
178 myTextureEnv->Init (theCtx, *anImage.operator->(), theTexture->Type());
181 myModificationState++;
185 void OpenGl_View::SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail theMode)
187 mySurfaceDetail = theMode;
190 myModificationState++;
194 /*----------------------------------------------------------------------*/
196 void OpenGl_View::SetBackfacing (const Standard_Integer theMode)
198 myBackfacing = theMode;
201 /*----------------------------------------------------------------------*/
204 void OpenGl_View::SetLights (const CALL_DEF_VIEWCONTEXT &AContext)
208 const int nb_lights = AContext.NbActiveLight;
211 const CALL_DEF_LIGHT *alight = &(AContext.ActiveLight[0]);
212 for ( ; i < nb_lights; i++, alight++ )
215 memset(&rep,0,sizeof(rep));
217 switch( alight->LightType )
219 case 0 : /* TOLS_AMBIENT */
220 rep.type = TLightAmbient;
221 rep.col.rgb[0] = alight->Color.r;
222 rep.col.rgb[1] = alight->Color.g;
223 rep.col.rgb[2] = alight->Color.b;
226 case 1 : /* TOLS_DIRECTIONAL */
227 rep.type = TLightDirectional;
228 rep.col.rgb[0] = alight->Color.r;
229 rep.col.rgb[1] = alight->Color.g;
230 rep.col.rgb[2] = alight->Color.b;
231 rep.dir[0] = alight->Direction.x;
232 rep.dir[1] = alight->Direction.y;
233 rep.dir[2] = alight->Direction.z;
236 case 2 : /* TOLS_POSITIONAL */
237 rep.type = TLightPositional;
238 rep.col.rgb[0] = alight->Color.r;
239 rep.col.rgb[1] = alight->Color.g;
240 rep.col.rgb[2] = alight->Color.b;
241 rep.pos[0] = alight->Position.x;
242 rep.pos[1] = alight->Position.y;
243 rep.pos[2] = alight->Position.z;
244 rep.atten[0] = alight->Attenuation[0];
245 rep.atten[1] = alight->Attenuation[1];
248 case 3 : /* TOLS_SPOT */
249 rep.type = TLightSpot;
250 rep.col.rgb[0] = alight->Color.r;
251 rep.col.rgb[1] = alight->Color.g;
252 rep.col.rgb[2] = alight->Color.b;
253 rep.pos[0] = alight->Position.x;
254 rep.pos[1] = alight->Position.y;
255 rep.pos[2] = alight->Position.z;
256 rep.dir[0] = alight->Direction.x;
257 rep.dir[1] = alight->Direction.y;
258 rep.dir[2] = alight->Direction.z;
259 rep.shine = alight->Concentration;
260 rep.atten[0] = alight->Attenuation[0];
261 rep.atten[1] = alight->Attenuation[1];
262 rep.angle = alight->Angle;
266 rep.HeadLight = alight->Headlight;
268 myLights.Append(rep);
271 myLightSourcesChanged = Standard_True;
274 /*----------------------------------------------------------------------*/
276 //call_togl_setvisualisation
277 void OpenGl_View::SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext)
279 myVisualization = AContext.Visualization;
281 switch (AContext.Model)
283 case 1 : /* VISUAL3D_TOM_INTERP_COLOR */
284 case 3 : /* VISUAL3D_TOM_VERTEX */
285 myIntShadingMethod = TEL_SM_GOURAUD;
288 myIntShadingMethod = TEL_SM_FLAT;
293 /*----------------------------------------------------------------------*/
295 //call_togl_cliplimit
296 void OpenGl_View::SetClipLimit (const Graphic3d_CView& theCView)
299 (theCView.Context.ZClipBackPlane - theCView.Mapping.BackPlaneDistance) /
300 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
301 myZClip.Front.Limit =
302 (theCView.Context.ZClipFrontPlane - theCView.Mapping.BackPlaneDistance) /
303 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
304 if (myZClip.Back.Limit < 0.0f)
305 myZClip.Back.Limit = 0.0f;
306 if (myZClip.Front.Limit > 1.0f)
307 myZClip.Front.Limit = 1.0f;
308 if (myZClip.Back.Limit > myZClip.Front.Limit)
310 myZClip.Back.Limit = 0.0f;
311 myZClip.Front.Limit = 1.0f;
314 myZClip.Back.IsOn = (theCView.Context.BackZClipping != 0);
315 myZClip.Front.IsOn = (theCView.Context.FrontZClipping != 0);
318 /*----------------------------------------------------------------------*/
320 //call_togl_viewmapping
321 void OpenGl_View::SetMapping (const Handle(OpenGl_Display)& theGlDisplay,
322 const Graphic3d_CView& theCView)
324 const float ratio = theCView.DefWindow.dy / theCView.DefWindow.dx;
325 const float r_ratio = theCView.DefWindow.dx / theCView.DefWindow.dy;
327 TEL_VIEW_MAPPING Map;
329 Map.window.xmin = theCView.Mapping.WindowLimit.um;
330 Map.window.ymin = theCView.Mapping.WindowLimit.vm;
331 Map.window.xmax = theCView.Mapping.WindowLimit.uM;
332 Map.window.ymax = theCView.Mapping.WindowLimit.vM;
334 Map.viewport.xmin = 0.F;
335 Map.viewport.xmax = ( 1.F < r_ratio ? 1.F : r_ratio );
336 Map.viewport.ymin = 0.F;
337 Map.viewport.ymax = ( 1.F < ratio ? 1.F : ratio );
338 Map.viewport.zmin = 0.F;
339 Map.viewport.zmax = 1.F;
342 switch (theCView.Mapping.Projection)
345 Map.proj = TelPerspective;
348 Map.proj = TelParallel;
352 // projection reference point
353 Map.prp[0] = theCView.Mapping.ProjectionReferencePoint.x;
354 Map.prp[1] = theCView.Mapping.ProjectionReferencePoint.y;
355 Map.prp[2] = theCView.Mapping.ProjectionReferencePoint.z;
356 if (!theGlDisplay.IsNull() && !theGlDisplay->Walkthrough())
357 Map.prp[2] += theCView.Mapping.FrontPlaneDistance;
359 // view plane distance
360 Map.vpd = theCView.Mapping.ViewPlaneDistance;
362 // back plane distance
363 Map.bpd = theCView.Mapping.BackPlaneDistance;
365 // front plane distance
366 Map.fpd = theCView.Mapping.FrontPlaneDistance;
370 // use user-defined matrix
371 if (theCView.Mapping.IsCustomMatrix)
374 for( i = 0; i < 4; i++ )
375 for( j = 0; j < 4; j++ )
376 myMappingMatrix[i][j] = theCView.Mapping.ProjectionMatrix[i][j];
379 TelEvalViewMappingMatrix (theGlDisplay, &Map, &err_ind, myMappingMatrix);
384 myViewMappingChanged = Standard_True;
387 /*----------------------------------------------------------------------*/
389 //call_togl_vieworientation
390 void OpenGl_View::SetOrientation (const Graphic3d_CView& theCView)
395 Tfloat ScaleFactors[3];
397 Vrp[0] = theCView.Orientation.ViewReferencePoint.x;
398 Vrp[1] = theCView.Orientation.ViewReferencePoint.y;
399 Vrp[2] = theCView.Orientation.ViewReferencePoint.z;
401 Vpn[0] = theCView.Orientation.ViewReferencePlane.x;
402 Vpn[1] = theCView.Orientation.ViewReferencePlane.y;
403 Vpn[2] = theCView.Orientation.ViewReferencePlane.z;
405 Vup[0] = theCView.Orientation.ViewReferenceUp.x;
406 Vup[1] = theCView.Orientation.ViewReferenceUp.y;
407 Vup[2] = theCView.Orientation.ViewReferenceUp.z;
409 ScaleFactors[0] = theCView.Orientation.ViewScaleX;
410 ScaleFactors[1] = theCView.Orientation.ViewScaleY;
411 ScaleFactors[2] = theCView.Orientation.ViewScaleZ;
415 // use user-defined matrix
416 if (theCView.Orientation.IsCustomMatrix)
419 for( i = 0; i < 4; i++ )
420 for( j = 0; j < 4; j++ )
421 myOrientationMatrix[i][j] = theCView.Orientation.ModelViewMatrix[i][j];
425 TelEvalViewOrientationMatrix (Vrp, Vpn, Vup, ScaleFactors, &err_ind, myOrientationMatrix);
430 myExtra.vrp[0] = Vrp[0];
431 myExtra.vrp[1] = Vrp[1];
432 myExtra.vrp[2] = Vrp[2];
434 myExtra.vpn[0] = Vpn[0];
435 myExtra.vpn[1] = Vpn[1];
436 myExtra.vpn[2] = Vpn[2];
438 myExtra.vup[0] = Vup[0];
439 myExtra.vup[1] = Vup[1];
440 myExtra.vup[2] = Vup[2];
442 myExtra.scaleFactors[0] = ScaleFactors[0],
443 myExtra.scaleFactors[1] = ScaleFactors[1],
444 myExtra.scaleFactors[2] = ScaleFactors[2];
447 myOrientationChanged = Standard_True;
450 /*----------------------------------------------------------------------*/
452 void OpenGl_View::SetFog (const Graphic3d_CView& theCView,
453 const Standard_Boolean theFlag)
457 myFog.IsOn = Standard_False;
461 myFog.IsOn = Standard_True;
464 (theCView.Context.DepthFrontPlane - theCView.Mapping.BackPlaneDistance) /
465 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
468 (theCView.Context.DepthBackPlane - theCView.Mapping.BackPlaneDistance) /
469 (theCView.Mapping.FrontPlaneDistance - theCView.Mapping.BackPlaneDistance);
471 if (myFog.Front < 0.F)
473 else if (myFog.Front > 1.F)
476 if (myFog.Back < 0.F)
478 else if (myFog.Back > 1.F)
481 if (myFog.Back > myFog.Front)
487 myFog.Color.rgb[0] = theCView.DefWindow.Background.r;
488 myFog.Color.rgb[1] = theCView.DefWindow.Background.g;
489 myFog.Color.rgb[2] = theCView.DefWindow.Background.b;
490 myFog.Color.rgb[3] = 1.0f;
494 /*----------------------------------------------------------------------*/
496 void OpenGl_View::TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
497 const Aspect_TypeOfTriedronPosition thePosition,
498 const Quantity_NameOfColor theColor,
499 const Standard_Real theScale,
500 const Standard_Boolean theAsWireframe)
502 OpenGl_Element::Destroy (theCtx, myTrihedron);
503 myTrihedron = new OpenGl_Trihedron (thePosition, theColor, theScale, theAsWireframe);
506 /*----------------------------------------------------------------------*/
508 void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
510 OpenGl_Element::Destroy (theCtx, myTrihedron);
513 /*----------------------------------------------------------------------*/
515 void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
516 const Graphic3d_CGraduatedTrihedron& theData)
518 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
519 myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);
522 /*----------------------------------------------------------------------*/
524 void OpenGl_View::GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx)
526 OpenGl_Element::Destroy (theCtx, myGraduatedTrihedron);
529 /*----------------------------------------------------------------------*/
531 //transform_persistence_end
532 void OpenGl_View::EndTransformPersistence(const Handle(OpenGl_Context)& theCtx)
537 glMatrixMode (GL_PROJECTION);
539 glMatrixMode (GL_MODELVIEW);
541 myIsTransPers = Standard_False;
543 // Note: the approach of accessing OpenGl matrices is used now since the matrix
544 // manipulation are made with help of OpenGl methods. This might be replaced by
545 // direct computation of matrices by OCC subroutines.
546 Tmatrix3 aResultWorldView;
547 glGetFloatv (GL_MODELVIEW_MATRIX, *aResultWorldView);
549 Tmatrix3 aResultProjection;
550 glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
552 // Set OCCT state uniform variables
553 theCtx->ShaderManager()->RevertWorldViewStateTo (aResultWorldView);
554 theCtx->ShaderManager()->RevertProjectionStateTo (aResultProjection);
558 /*----------------------------------------------------------------------*/
560 //transform_persistence_begin
561 const TEL_TRANSFORM_PERSISTENCE* OpenGl_View::BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
562 const TEL_TRANSFORM_PERSISTENCE* theTransPers)
564 const TEL_TRANSFORM_PERSISTENCE* aTransPersPrev = myTransPers;
565 myTransPers = theTransPers;
566 if (theTransPers->mode == 0)
568 EndTransformPersistence (theCtx);
569 return aTransPersPrev;
573 GLdouble aModelMatrix[4][4];
574 GLdouble aProjMatrix[4][4];
575 glGetIntegerv (GL_VIEWPORT, aViewport);
576 glGetDoublev (GL_MODELVIEW_MATRIX, (GLdouble* )aModelMatrix);
577 glGetDoublev (GL_PROJECTION_MATRIX, (GLdouble *)aProjMatrix);
578 const GLdouble aViewportW = (GLdouble )aViewport[2];
579 const GLdouble aViewportH = (GLdouble )aViewport[3];
583 // pop matrix stack - it will be overridden later
584 glMatrixMode (GL_PROJECTION);
586 glMatrixMode (GL_MODELVIEW);
591 myIsTransPers = Standard_True;
594 // push matrices into stack and reset them
595 glMatrixMode (GL_MODELVIEW);
599 glMatrixMode (GL_PROJECTION);
603 // get the window's (fixed) coordinates for theTransPers->point before matrixes modifications
604 GLdouble aWinX = 0.0, aWinY = 0.0, aWinZ = 0.0;
605 if ((theTransPers->mode & TPF_PAN) != TPF_PAN)
607 gluProject (theTransPers->pointX, theTransPers->pointY, theTransPers->pointZ,
608 (GLdouble* )aModelMatrix, (GLdouble* )aProjMatrix, aViewport,
609 &aWinX, &aWinY, &aWinZ);
613 if ((theTransPers->mode & TPF_ZOOM)
614 || (theTransPers->mode == TPF_TRIEDRON))
616 // compute fixed-zoom multiplier
617 // actually function works ugly with TelPerspective!
618 const GLdouble aDet2 = 0.002 / (aViewportW > aViewportH ? aProjMatrix[1][1] : aProjMatrix[0][0]);
619 aProjMatrix[0][0] *= aDet2;
620 aProjMatrix[1][1] *= aDet2;
621 aProjMatrix[2][2] *= aDet2;
624 // prevent translation - annulate translate matrix
625 if ((theTransPers->mode & TPF_PAN)
626 || (theTransPers->mode == TPF_TRIEDRON))
628 aModelMatrix[3][0] = 0.0;
629 aModelMatrix[3][1] = 0.0;
630 aModelMatrix[3][2] = 0.0;
631 aProjMatrix [3][0] = 0.0;
632 aProjMatrix [3][1] = 0.0;
633 aProjMatrix [3][2] = 0.0;
636 // prevent scaling-on-axis
637 if (theTransPers->mode & TPF_ZOOM)
639 const double aScaleX = myExtra.scaleFactors[0];
640 const double aScaleY = myExtra.scaleFactors[1];
641 const double aScaleZ = myExtra.scaleFactors[2];
642 for (int i = 0; i < 3; ++i)
644 aModelMatrix[0][i] /= aScaleX;
645 aModelMatrix[1][i] /= aScaleY;
646 aModelMatrix[2][i] /= aScaleZ;
650 // prevent rotating - annulate rotate matrix
651 if (theTransPers->mode & TPF_ROTATE)
653 aModelMatrix[0][0] = 1.0;
654 aModelMatrix[1][1] = 1.0;
655 aModelMatrix[2][2] = 1.0;
657 aModelMatrix[1][0] = 0.0;
658 aModelMatrix[2][0] = 0.0;
659 aModelMatrix[0][1] = 0.0;
660 aModelMatrix[2][1] = 0.0;
661 aModelMatrix[0][2] = 0.0;
662 aModelMatrix[1][2] = 0.0;
665 // load computed matrices
666 glMatrixMode (GL_MODELVIEW);
667 glMultMatrixd ((GLdouble* )aModelMatrix);
669 glMatrixMode (GL_PROJECTION);
670 glMultMatrixd ((GLdouble* )aProjMatrix);
672 if (theTransPers->mode == TPF_TRIEDRON)
674 // move to the window corner
675 if (theTransPers->pointX != 0.0
676 && theTransPers->pointY != 0.0)
678 GLdouble aW1, aH1, aW2, aH2, aDummy;
679 glMatrixMode (GL_PROJECTION);
680 gluUnProject ( 0.5 * aViewportW, 0.5 * aViewportH, 0.0,
681 (GLdouble* )THE_IDENTITY_MATRIX, (GLdouble* )aProjMatrix, aViewport,
682 &aW1, &aH1, &aDummy);
683 gluUnProject (-0.5 * aViewportW, -0.5 * aViewportH, 0.0,
684 (GLdouble* )THE_IDENTITY_MATRIX, (GLdouble* )aProjMatrix, aViewport,
685 &aW2, &aH2, &aDummy);
686 GLdouble aMoveX = 0.5 * (aW1 - aW2 - theTransPers->pointZ);
687 GLdouble aMoveY = 0.5 * (aH1 - aH2 - theTransPers->pointZ);
688 aMoveX = (theTransPers->pointX > 0.0) ? aMoveX : -aMoveX;
689 aMoveY = (theTransPers->pointY > 0.0) ? aMoveY : -aMoveY;
690 glTranslated (aMoveX, aMoveY, 0.0);
693 else if ((theTransPers->mode & TPF_PAN) != TPF_PAN)
695 // move to thePoint using saved win-coordinates ('marker-behaviour')
696 GLdouble aMoveX, aMoveY, aMoveZ;
697 glGetDoublev (GL_MODELVIEW_MATRIX, (GLdouble* )aModelMatrix);
698 glGetDoublev (GL_PROJECTION_MATRIX, (GLdouble* )aProjMatrix);
699 gluUnProject (aWinX, aWinY, aWinZ,
700 (GLdouble* )aModelMatrix, (GLdouble* )aProjMatrix, aViewport,
701 &aMoveX, &aMoveY, &aMoveZ);
703 glMatrixMode (GL_MODELVIEW);
704 glTranslated (aMoveX, aMoveY, aMoveZ);
707 // Note: the approach of accessing OpenGl matrices is used now since the matrix
708 // manipulation are made with help of OpenGl methods. This might be replaced by
709 // direct computation of matrices by OCC subroutines.
710 Tmatrix3 aResultWorldView;
711 glGetFloatv (GL_MODELVIEW_MATRIX, *aResultWorldView);
713 Tmatrix3 aResultProjection;
714 glGetFloatv (GL_PROJECTION_MATRIX, *aResultProjection);
716 // Set OCCT state uniform variables
717 theCtx->ShaderManager()->UpdateWorldViewStateTo (aResultWorldView);
718 theCtx->ShaderManager()->UpdateProjectionStateTo (aResultProjection);
720 return aTransPersPrev;