// Created on: 2013-11-11
// Created by: Anastasia BORISOVA
-// Copyright (c) 2013 OPEN CASCADE SAS
+// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
// function : Release
// purpose :
// =======================================================================
-void OpenGl_Flipper::Release (const Handle(OpenGl_Context)& )
+void OpenGl_Flipper::Release (OpenGl_Context*)
{
//
}
void OpenGl_Flipper::Render (const Handle(OpenGl_Workspace)& theWorkspace) const
{
// Check if rendering is to be in immediate mode
- const Standard_Boolean isImmediate = (theWorkspace->NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE)) != 0;
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
- GLint aCurrMode = GL_MODELVIEW;
- glGetIntegerv (GL_MATRIX_MODE, &aCurrMode);
-
if (!myIsEnabled)
{
- // Restore transformation
- if (isImmediate)
- {
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (GL_MODELVIEW);
- }
-
- glPopMatrix();
-
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (aCurrMode);
- }
-
- Tmatrix3 aModelWorldState = { { 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 } };
-
- aContext->ShaderManager()->RevertModelWorldStateTo (aModelWorldState);
- }
- else
- {
- // Update current model-view matrix in the top of the stack
- // replacing it with StructureMatrixT*ViewMatrix from the workspace.
- theWorkspace->UpdateModelViewMatrix();
- }
- return;
- }
-
- if (isImmediate)
- {
-
- if (!aContext->ShaderManager()->IsEmpty())
- {
- Tmatrix3 aWorldView;
- glGetFloatv (GL_MODELVIEW_MATRIX, *aWorldView);
-
- Tmatrix3 aProjection;
- glGetFloatv (GL_PROJECTION_MATRIX, *aProjection);
-
- aContext->ShaderManager()->UpdateWorldViewStateTo (aWorldView);
- aContext->ShaderManager()->UpdateProjectionStateTo (aProjection);
- }
-
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (GL_MODELVIEW);
- }
+ // restore matrix state
+ aContext->WorldViewState.Pop();
- glPushMatrix();
-
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (aCurrMode);
- }
+ // Apply since we probably in the middle of something.
+ aContext->ApplyModelViewMatrix();
+ return;
}
- OpenGl_Mat4 aMatrixMV;
- glGetFloatv (GL_MODELVIEW_MATRIX, aMatrixMV.ChangeData());
+ aContext->WorldViewState.Push();
+ OpenGl_Mat4 aMatrixMV = aContext->WorldViewState.Current() * aContext->ModelWorldState.Current();
const OpenGl_Vec4 aMVReferenceOrigin = aMatrixMV * myReferenceOrigin;
const OpenGl_Vec4 aMVReferenceX = aMatrixMV * OpenGl_Vec4 (myReferenceX.xyz() + myReferenceOrigin.xyz(), 1.0f);
aMatrixMV = aMatrixMV * aTransform;
// load transformed model-view matrix
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (GL_MODELVIEW);
- }
-
- glLoadMatrixf ((GLfloat*) aMatrixMV);
-
- if (aCurrMode != GL_MODELVIEW)
- {
- glMatrixMode (aCurrMode);
- }
+ aContext->WorldViewState.SetCurrent (aMatrixMV);
+ aContext->ApplyWorldViewMatrix();
}