OpenGl_ShaderManager::PushState() now sets GL_SHADE_MODEL within FFP.
OpenGl_Context::SetShadeModel(), added property holding cached GL_SHADE_MODEL state.
#if !defined(GL_ES_VERSION_2_0)
myPointSpriteOrig (GL_UPPER_LEFT),
myRenderMode (GL_RENDER),
+ myShadeModel (GL_SMOOTH),
myPolygonMode (GL_FILL),
#else
myPointSpriteOrig (0),
myRenderMode (0),
+ myShadeModel (0),
myPolygonMode (0),
#endif
myToCullBackFaces (false),
if (core11 != NULL)
{
::glGetIntegerv (GL_RENDER_MODE, &myRenderMode);
+ ::glGetIntegerv (GL_SHADE_MODEL, &myShadeModel);
}
// cache read buffers state
return anOldGlNormalize;
}
+// =======================================================================
+// function : SetShadeModel
+// purpose :
+// =======================================================================
+void OpenGl_Context::SetShadeModel (Graphic3d_TypeOfShadingModel theModel)
+{
+#if !defined(GL_ES_VERSION_2_0)
+ if (core11 != NULL)
+ {
+ const Standard_Integer aModel = theModel == Graphic3d_TOSM_FACET
+ || theModel == Graphic3d_TOSM_PBR_FACET ? GL_FLAT : GL_SMOOTH;
+ if (myShadeModel == aModel)
+ {
+ return;
+ }
+ myShadeModel = aModel;
+ core11->glShadeModel (aModel);
+ }
+#else
+ (void )theModel;
+#endif
+}
+
// =======================================================================
// function : SetPolygonMode
// purpose :
//! Dumps the content of openGL state into the stream
Standard_EXPORT static void DumpJsonOpenGlState (Standard_OStream& theOStream, Standard_Integer theDepth = -1);
+ //! Set GL_SHADE_MODEL value.
+ Standard_EXPORT void SetShadeModel (Graphic3d_TypeOfShadingModel theModel);
+
private:
//! Wrapper to system function to retrieve GL function pointer by name.
Standard_Integer myViewportVirt[4]; //!< virtual viewport
Standard_Integer myPointSpriteOrig; //!< GL_POINT_SPRITE_COORD_ORIGIN state (GL_UPPER_LEFT by default)
Standard_Integer myRenderMode; //!< value for active rendering mode
+ Standard_Integer myShadeModel; //!< currently used shade model (glShadeModel)
Standard_Integer myPolygonMode; //!< currently used polygon rasterization mode (glPolygonMode)
Graphic3d_PolygonOffset myPolygonOffset; //!< currently applied polygon offset
bool myToCullBackFaces; //!< back face culling mode enabled state (glIsEnabled (GL_CULL_FACE))
}
}
- #if !defined(GL_ES_VERSION_2_0)
- // manage FFP lighting
- if (aCtx->ActiveProgram().IsNull()
- && aCtx->core11 != NULL)
- {
- if (aShadingModel == Graphic3d_TOSM_UNLIT)
- {
- glDisable (GL_LIGHTING);
- }
- else
- {
- glEnable (GL_LIGHTING);
- }
- }
- #endif
-
// bind textures after GLSL program to set mock textures to slots used by program
aCtx->BindTextures (aTextureSet, aCtx->ActiveProgram());
if (!aTextureSet.IsNull()
// function : PushState
// purpose : Pushes state of OCCT graphics parameters to the program
// =======================================================================
-void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& theProgram) const
+void OpenGl_ShaderManager::PushState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ Graphic3d_TypeOfShadingModel theShadingModel) const
{
const Handle(OpenGl_ShaderProgram)& aProgram = !theProgram.IsNull() ? theProgram : myFfpProgram;
PushClippingState (aProgram);
(float )myContext->Viewport()[2], (float )myContext->Viewport()[3]));
}
}
+#if !defined(GL_ES_VERSION_2_0)
+ else if (myContext->core11 != NULL)
+ {
+ // manage FFP lighting
+ myContext->SetShadeModel (theShadingModel);
+ if (theShadingModel == Graphic3d_TOSM_UNLIT)
+ {
+ glDisable (GL_LIGHTING);
+ }
+ else
+ {
+ glEnable (GL_LIGHTING);
+ }
+ }
+#else
+ (void )theShadingModel;
+#endif
}
// =======================================================================
// function : bindProgramWithState
// purpose :
// =======================================================================
-Standard_Boolean OpenGl_ShaderManager::bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram)
+Standard_Boolean OpenGl_ShaderManager::bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ Graphic3d_TypeOfShadingModel theShadingModel)
{
const Standard_Boolean isBound = myContext->BindProgram (theProgram);
if (isBound
{
theProgram->ApplyVariables (myContext);
}
- PushState (theProgram);
+ PushState (theProgram, theShadingModel);
return isBound;
}
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
- return bindProgramWithState (theCustomProgram);
+ return bindProgramWithState (theCustomProgram, theShadingModel);
}
Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
aBits |= OpenGl_PO_PointSimple;
}
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
- return bindProgramWithState (aProgram);
+ return bindProgramWithState (aProgram, theShadingModel);
}
Standard_Boolean theEnableMeshEdges,
const Handle(OpenGl_ShaderProgram)& theCustomProgram)
{
+ const Graphic3d_TypeOfShadingModel aShadeModelOnFace = theShadingModel != Graphic3d_TOSM_UNLIT
+ && (theTextures.IsNull() || theTextures->IsModulate())
+ ? theShadingModel
+ : Graphic3d_TOSM_UNLIT;
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
- return bindProgramWithState (theCustomProgram);
+ return bindProgramWithState (theCustomProgram, aShadeModelOnFace);
}
- const Graphic3d_TypeOfShadingModel aShadeModelOnFace = theShadingModel != Graphic3d_TOSM_UNLIT
- && (theTextures.IsNull() || theTextures->IsModulate())
- ? theShadingModel
- : Graphic3d_TOSM_UNLIT;
const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theInteriorStyle, theHasVertColor, theEnableEnvMap, theEnableMeshEdges);
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
- return bindProgramWithState (aProgram);
+ return bindProgramWithState (aProgram, aShadeModelOnFace);
}
//! Bind program for line rendering
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
- return bindProgramWithState (theCustomProgram);
+ return bindProgramWithState (theCustomProgram, theShadingModel);
}
Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
}
Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
- return bindProgramWithState (aProgram);
+ return bindProgramWithState (aProgram, theShadingModel);
}
//! Bind program for point rendering
if (!theCustomProgram.IsNull()
|| myContext->caps->ffpEnable)
{
- return bindProgramWithState (theCustomProgram);
+ return bindProgramWithState (theCustomProgram, Graphic3d_TOSM_UNLIT);
}
if (myFontProgram.IsNull())
prepareStdProgramFont();
}
- return bindProgramWithState (myFontProgram);
+ return bindProgramWithState (myFontProgram, Graphic3d_TOSM_UNLIT);
}
//! Bind program for outline rendering
{
prepareStdProgramUnlit (aProgram, aBits, true);
}
- return bindProgramWithState (aProgram);
+ return bindProgramWithState (aProgram, Graphic3d_TOSM_UNLIT);
}
//! Bind program for FBO blit operation.
{
prepareStdProgramBoundBox();
}
- return bindProgramWithState (myBoundBoxProgram);
+ return bindProgramWithState (myBoundBoxProgram, Graphic3d_TOSM_UNLIT);
}
//! Returns bounding box vertex buffer.
public:
//! Pushes current state of OCCT graphics parameters to specified program.
- Standard_EXPORT void PushState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
+ Standard_EXPORT void PushState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ Graphic3d_TypeOfShadingModel theShadingModel = Graphic3d_TOSM_UNLIT) const;
public:
Standard_Boolean theHasEmissive = true);
//! Bind specified program to current context and apply state.
- Standard_EXPORT Standard_Boolean bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram);
+ Standard_EXPORT Standard_Boolean bindProgramWithState (const Handle(OpenGl_ShaderProgram)& theProgram,
+ Graphic3d_TypeOfShadingModel theShadingModel);
//! Set pointer myLightPrograms to active lighting programs set from myMapOfLightPrograms
Standard_EXPORT void switchLightPrograms();
|| myBackgrounds[Graphic3d_TOB_TEXTURE]->TextureFillMethod() == Aspect_FM_CENTERED
|| myBackgrounds[Graphic3d_TOB_TEXTURE]->TextureFillMethod() == Aspect_FM_NONE))
{
- #if !defined(GL_ES_VERSION_2_0)
- GLint aShadingModelOld = GL_SMOOTH;
- if (aCtx->core11 != NULL
- && aCtx->caps->ffpEnable)
- {
- aCtx->core11fwd->glDisable (GL_LIGHTING);
- aCtx->core11fwd->glGetIntegerv (GL_SHADE_MODEL, &aShadingModelOld);
- aCtx->core11->glShadeModel (GL_SMOOTH);
- }
- #endif
-
myBackgrounds[Graphic3d_TOB_GRADIENT]->Render(theWorkspace);
-
- #if !defined(GL_ES_VERSION_2_0)
- if (aCtx->core11 != NULL
- && aCtx->caps->ffpEnable)
- {
- aCtx->core11->glShadeModel (aShadingModelOld);
- }
- #endif
}
// Drawing background image if it is defined
{
aContext->SetGlNormalizeEnabled (Standard_False);
}
-
- // Apply InteriorShadingMethod
- if (aContext->core11 != NULL)
- {
- aContext->core11->glShadeModel (myShadingModel == Graphic3d_TOSM_FACET
- || myShadingModel == Graphic3d_TOSM_UNLIT ? GL_FLAT : GL_SMOOTH);
- }
#endif
aManager->SetShadingModel (OpenGl_ShaderManager::PBRShadingModelFallback (myShadingModel, checkPBRAvailability()));
vtop
vrotate -0.9 0.1 0
vfit
+
+vcaps -ffp 1
+vdump $::imagedir/${::casename}_defaults_ffp.png
+
+vcaps -ffp 0
vdump $::imagedir/${::casename}_defaults.png
# customize shading models
vaspects p7 -setShadingModel FACET
vdrawtext t7 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD
vdisplay -topmost t1 t2 t3 t4 t5 t6 t7
+
+vcaps -ffp 1
+vdump $::imagedir/${::casename}_ffp.png
+
+vcaps -ffp 0
vdump $::imagedir/${::casename}.png