* Fonctions privees
*/
+#if !defined(GL_ES_VERSION_2_0)
/*-----------------------------------------------------------------*/
/*
* Set des lumieres
glEnable (theLightGlId++);
}
+#endif
/*----------------------------------------------------------------------*/
void OpenGl_View::DrawBackground (OpenGl_Workspace& theWorkspace)
{
+#if !defined(GL_ES_VERSION_2_0)
if ( (theWorkspace.NamedStatus & OPENGL_NS_WHITEBACK) == 0 &&
( myBgTexture.TexId != 0 || myBgGradient.type != Aspect_GFM_NONE ) )
{
glEnable (GL_DEPTH_TEST);
}
}
+#endif
}
/*----------------------------------------------------------------------*/
const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
- // Store and disable current clipping planes
- Standard_Integer aMaxPlanes = aContext->MaxClipPlanes();
-
- OPENGL_CLIP_PLANE *aOldPlanes = new OPENGL_CLIP_PLANE[aMaxPlanes];
- OPENGL_CLIP_PLANE *aPtrPlane = aOldPlanes;
-
- GLenum aClipPlaneId = GL_CLIP_PLANE0;
- const GLenum aClipLastId = GL_CLIP_PLANE0 + aMaxPlanes;
- for (; aClipPlaneId < aClipLastId; aClipPlaneId++, aPtrPlane++)
+#if !defined(GL_ES_VERSION_2_0)
+ // store and disable current clipping planes
+ const Standard_Integer aMaxPlanes = aContext->MaxClipPlanes();
+ NCollection_Array1<OPENGL_CLIP_PLANE> aOldPlanes (GL_CLIP_PLANE0, GL_CLIP_PLANE0 + aMaxPlanes - 1);
+ if (aContext->core11 != NULL)
{
- glGetClipPlane (aClipPlaneId, aPtrPlane->Equation);
- if (aPtrPlane->isEnabled)
- {
- glDisable (aClipPlaneId);
- aPtrPlane->isEnabled = GL_TRUE;
- }
- else
+ for (Standard_Integer aClipPlaneId = aOldPlanes.Lower(); aClipPlaneId <= aOldPlanes.Upper(); ++aClipPlaneId)
{
- aPtrPlane->isEnabled = GL_FALSE;
+ OPENGL_CLIP_PLANE& aPlane = aOldPlanes.ChangeValue (aClipPlaneId);
+ aContext->core11->glGetClipPlane (aClipPlaneId, aPlane.Equation);
+ if (aPlane.isEnabled)
+ {
+ aContext->core11fwd->glDisable (aClipPlaneId);
+ aPlane.isEnabled = GL_TRUE;
+ }
+ else
+ {
+ aPlane.isEnabled = GL_FALSE;
+ }
}
}
+#endif
Standard_Boolean isProjectionMatUpdateNeeded = Standard_False;
Standard_Boolean isOrientationMatUpdateNeeded = Standard_False;
}
// Set OCCT state uniform variables
- const Handle(OpenGl_ShaderManager) aManager = aContext->ShaderManager();
+ const Handle(OpenGl_ShaderManager) aManager = aContext->ShaderManager();
+ const Standard_Boolean isSameView = aManager->IsSameView (this); // force camera state update when needed
if (!aManager->IsEmpty())
{
if (StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index()) != myLastLightSourceState)
myLastLightSourceState = StateInfo (myCurrLightSourceState, aManager->LightSourceState().Index());
}
- if (myProjectionState != myCamera->ProjectionState())
+ if (myProjectionState != myCamera->ProjectionState()
+ || !isSameView)
{
myProjectionState = myCamera->ProjectionState();
aManager->UpdateProjectionStateTo ((const Tmatrix3*)myCamera->ProjectionMatrixF().GetData());
}
- if (myModelViewState != myCamera->ModelViewState())
+ if (myModelViewState != myCamera->ModelViewState()
+ || !isSameView)
{
myModelViewState = myCamera->ModelViewState();
aManager->UpdateWorldViewStateTo ((const Tmatrix3*)myCamera->OrientationMatrixF().GetData());
}
}
- if (!aManager.IsNull())
- {
- if (!aManager->IsSameView (this))
- {
- // Force update camera states
- myProjectionState = myCamera->ProjectionState();
- aManager->UpdateProjectionStateTo ((const Tmatrix3*)myCamera->ProjectionMatrixF().GetData());
-
- myModelViewState = myCamera->ModelViewState();
- aManager->UpdateWorldViewStateTo ((const Tmatrix3*)myCamera->OrientationMatrixF().GetData());
- }
- }
-
if (isProjectionMatUpdateNeeded
|| isOrientationMatUpdateNeeded)
{
DrawBackground (*theWorkspace);
}
+#if !defined(GL_ES_VERSION_2_0)
// Switch off lighting by default
glDisable(GL_LIGHTING);
+#endif
// =================================
// Step 3: Draw underlayer
glDisable( GL_CULL_FACE );
}
+#if !defined(GL_ES_VERSION_2_0)
// if the view is scaled normal vectors are scaled to unit
// length for correct displaying of shaded objects
const gp_Pnt anAxialScale = myCamera->AxialScale();
{
myFog.Front = (Standard_ShortReal )(aFogFrontConverted - myCamera->Distance());
myFog.Back = (Standard_ShortReal )(aFogBackConverted - myCamera->Distance());
- }
+ }
glFogi(GL_FOG_MODE, GL_LINEAR);
glFogf(GL_FOG_START, (Standard_ShortReal )aFogFrontConverted);
glDisable(GL_FOG);
// Apply InteriorShadingMethod
- glShadeModel( myIntShadingMethod == TEL_SM_FLAT ? GL_FLAT : GL_SMOOTH );
+ aContext->core11->glShadeModel (myShadingModel == Visual3d_TOM_FACET
+ || myShadingModel == Visual3d_TOM_NONE ? GL_FLAT : GL_SMOOTH);
+#endif
+
+ aManager->SetShadingModel (myShadingModel);
// Apply AntiAliasing
if (myAntiAliasing)
}
// safely switch to right Eye buffer
aContext->SetDrawBufferRight();
-
+
// redraw right Eye
RedrawScene (thePrintContext, theWorkspace, aRProj, aOrient);
// We need to disable (unbind) all shaders programs to ensure
// that all objects without specified aspect will be drawn
// correctly (such as background)
- OpenGl_ShaderProgram::Unbind (aContext);
+ aContext->BindProgram (NULL);
}
// Render trihedron
// Step 7: Finalize
// ===============================
- // Restore clipping planes
- aClipPlaneId = GL_CLIP_PLANE0;
- aPtrPlane = aOldPlanes;
-
- for (; aClipPlaneId < aClipLastId; aClipPlaneId++, aPtrPlane++)
+#if !defined(GL_ES_VERSION_2_0)
+ // restore clipping planes
+ if (aContext->core11 != NULL)
{
- glClipPlane (aClipPlaneId, aPtrPlane->Equation);
- if (aPtrPlane->isEnabled)
- glEnable (aClipPlaneId);
- else
- glDisable (aClipPlaneId);
+ for (Standard_Integer aClipPlaneId = aOldPlanes.Lower(); aClipPlaneId <= aOldPlanes.Upper(); ++aClipPlaneId)
+ {
+ const OPENGL_CLIP_PLANE& aPlane = aOldPlanes.ChangeValue (aClipPlaneId);
+ aContext->core11->glClipPlane (aClipPlaneId, aPlane.Equation);
+ if (aPlane.isEnabled)
+ aContext->core11fwd->glEnable (aClipPlaneId);
+ else
+ aContext->core11fwd->glDisable (aClipPlaneId);
+ }
}
-
- delete[] aOldPlanes;
+#endif
// ==============================================================
// Step 8: Keep shader manager informed about last View
if ( myZLayers.NbStructures() <= 0 )
return;
+#if !defined(GL_ES_VERSION_2_0)
glPushAttrib ( GL_DEPTH_BUFFER_BIT );
+#endif
//TsmPushAttri(); /* save previous graphics context */
if ( (AWorkspace->NamedStatus & OPENGL_NS_2NDPASSNEED) == 0 )
{
+ #if !defined(GL_ES_VERSION_2_0)
const int antiAliasingMode = AWorkspace->AntiAliasingMode();
+ #endif
if ( !myAntiAliasing )
{
+ #if !defined(GL_ES_VERSION_2_0)
glDisable(GL_POINT_SMOOTH);
glDisable(GL_LINE_SMOOTH);
if( antiAliasingMode & 2 ) glDisable(GL_POLYGON_SMOOTH);
+ #endif
glBlendFunc (GL_ONE, GL_ZERO);
glDisable (GL_BLEND);
}
else
{
+ #if !defined(GL_ES_VERSION_2_0)
glEnable(GL_POINT_SMOOTH);
glEnable(GL_LINE_SMOOTH);
if( antiAliasingMode & 2 ) glEnable(GL_POLYGON_SMOOTH);
+ #endif
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable (GL_BLEND);
}
myZLayers.Render (AWorkspace);
+#if !defined(GL_ES_VERSION_2_0)
//TsmPopAttri(); /* restore previous graphics context; before update lights */
glPopAttrib();
+#endif
}
/*----------------------------------------------------------------------*/
const Graphic3d_CView& ACView,
const Aspect_CLayer2d& ACLayer)
{
+#if !defined(GL_ES_VERSION_2_0)
if (&ACLayer == NULL
|| ACLayer.ptrLayer == NULL
|| ACLayer.ptrLayer->listIndex == 0) return;
glViewport (0, 0, (GLsizei) ACView.DefWindow.dx, (GLsizei) ACView.DefWindow.dy);
glFlush ();
+#endif
}
/*----------------------------------------------------------------------*/
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
const GLenum aDataFormat = (anImage.Format() == Image_PixMap::ImgRGB) ? GL_RGB : GL_RGBA;
+
+#if !defined(GL_ES_VERSION_2_0)
gluBuild2DMipmaps (GL_TEXTURE_2D, 3/*4*/,
GLint(anImage.SizeX()), GLint(anImage.SizeY()),
aDataFormat, GL_UNSIGNED_BYTE, anImage.Data());
+#endif
myBgTexture.TexId = aTextureId;
myBgTexture.Width = (Standard_Integer )anImage.SizeX();
aPlaneFront = new Graphic3d_ClipPlane (aFrontEquation);
}
- // do some "memory allocation"-wise optimization
+ // Specify slicing planes with identity transformation
if (!aPlaneBack.IsNull() || !aPlaneFront.IsNull())
{
Graphic3d_SequenceOfHClipPlane aSlicingPlanes;
}
}
- // Apply user clipping planes
- if (!myClipPlanes.IsEmpty())
- {
- Graphic3d_SequenceOfHClipPlane aUserPlanes;
- Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
- for (; aClippingIt.More(); aClippingIt.Next())
- {
- const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
- if (aClipPlane->IsOn())
- {
- aUserPlanes.Append (aClipPlane);
- }
- }
-
- if (!aUserPlanes.IsEmpty())
- {
- // add planes at actual matrix state.
- aContext->ChangeClipping().AddWorld (aUserPlanes);
- }
-
- if (!aContext->ShaderManager()->IsEmpty())
- {
- aContext->ShaderManager()->UpdateClippingState();
- }
- }
-
+#if !defined(GL_ES_VERSION_2_0)
// Setup view projection
glMatrixMode (GL_PROJECTION);
aContext->ShaderManager()->UpdateProjectionStateTo (&aResultProjection);
// force shader uniform restore on next frame
- myProjectionState = 0;
+ myProjectionState = 0;
}
+#endif
// Setup view orientation
theWorkspace->SetViewMatrix (theOrientation);
+ // Specify clipping planes in view transformation space
+ if (!myClipPlanes.IsEmpty())
+ {
+ Graphic3d_SequenceOfHClipPlane aUserPlanes;
+ Graphic3d_SequenceOfHClipPlane::Iterator aClippingIt (myClipPlanes);
+ for (; aClippingIt.More(); aClippingIt.Next())
+ {
+ const Handle(Graphic3d_ClipPlane)& aClipPlane = aClippingIt.Value();
+ if (aClipPlane->IsOn())
+ {
+ aUserPlanes.Append (aClipPlane);
+ }
+ }
+
+ if (!aUserPlanes.IsEmpty())
+ {
+ aContext->ChangeClipping().AddWorld (aUserPlanes);
+ }
+
+ if (!aContext->ShaderManager()->IsEmpty())
+ {
+ aContext->ShaderManager()->UpdateClippingState();
+ }
+ }
+
+#if !defined(GL_ES_VERSION_2_0)
// Apply Lights
{
// setup lights
glDisable (aLightGlId);
}
}
+#endif
// Clear status bitfields
theWorkspace->NamedStatus &= ~(OPENGL_NS_2NDPASSNEED | OPENGL_NS_2NDPASSDO);
theWorkspace->EnableTexture (myTextureEnv);
// Remember OpenGl properties
- GLint aSaveBlendDst, aSaveBlendSrc;
+ GLint aSaveBlendDst = GL_ONE_MINUS_SRC_ALPHA, aSaveBlendSrc = GL_SRC_ALPHA;
GLint aSaveZbuffFunc;
GLboolean aSaveZbuffWrite;
glGetBooleanv (GL_DEPTH_WRITEMASK, &aSaveZbuffWrite);
glGetIntegerv (GL_DEPTH_FUNC, &aSaveZbuffFunc);
+ #if !defined(GL_ES_VERSION_2_0)
glGetIntegerv (GL_BLEND_DST, &aSaveBlendDst);
glGetIntegerv (GL_BLEND_SRC, &aSaveBlendSrc);
+ #endif
GLboolean wasZbuffEnabled = glIsEnabled (GL_DEPTH_TEST);
GLboolean wasBlendEnabled = glIsEnabled (GL_BLEND);