/*----------------------------------------------------------------------*/
-static const OPENGL_BG_TEXTURE myDefaultBgTexture = { 0, 0, 0, Aspect_FM_CENTERED };
-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 };
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 } };
static const OPENGL_ZCLIP myDefaultZClip = { { Standard_True, 0.F }, { Standard_True, 1.F } };
OpenGl_View::OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext,
OpenGl_StateCounter* theCounter)
-: mySurfaceDetail(Visual3d_TOD_NONE),
+: mySurfaceDetail(Visual3d_TOD_ALL),
myBackfacing(0),
- myBgTexture(myDefaultBgTexture),
- myBgGradient(myDefaultBgGradient),
//shield_indicator = TOn,
//shield_colour = { { 0.F, 0.F, 0.F, 1.F } },
//border_indicator = TOff,
myZClip(myDefaultZClip),
myCamera(AContext.Camera),
myFog(myDefaultFog),
- myTrihedron(NULL),
- myGraduatedTrihedron(NULL),
+ myToShowTrihedron (false),
+ myToShowGradTrihedron (false),
myVisualization(AContext.Visualization),
myShadingModel ((Visual3d_TypeOfModel )AContext.Model),
myAntiAliasing(Standard_False),
myProjectionState (0),
myModelViewState (0),
myStateCounter (theCounter),
- myLastLightSourceState (0, 0)
+ myLastLightSourceState (0, 0),
+ myTextureParams (new OpenGl_AspectFace()),
+ myBgGradientArray (new OpenGl_BackgroundArray (Graphic3d_TOB_GRADIENT)),
+ myBgTextureArray (new OpenGl_BackgroundArray (Graphic3d_TOB_TEXTURE)),
+ // ray-tracing fields initialization
+ myRaytraceInitStatus (OpenGl_RT_NONE),
+ myIsRaytraceDataValid (Standard_False),
+ myIsRaytraceWarnTextures (Standard_False),
+ myToUpdateEnvironmentMap (Standard_False),
+ myLayersModificationStatus (0)
{
myCurrLightSourceState = myStateCounter->Increment();
- myModificationState = 1; // initial state
}
/*----------------------------------------------------------------------*/
-OpenGl_View::~OpenGl_View ()
+OpenGl_View::~OpenGl_View()
{
ReleaseGlResources (NULL); // ensure ReleaseGlResources() was called within valid context
- OpenGl_Element::Destroy (NULL, myTrihedron);
- OpenGl_Element::Destroy (NULL, myGraduatedTrihedron);
+ OpenGl_Element::Destroy (NULL, myBgGradientArray);
+ OpenGl_Element::Destroy (NULL, myBgTextureArray);
+ OpenGl_Element::Destroy (NULL, myTextureParams);
}
void OpenGl_View::ReleaseGlResources (const Handle(OpenGl_Context)& theCtx)
{
- if (myTrihedron != NULL)
- {
- myTrihedron->Release (theCtx.operator->());
- }
- if (myGraduatedTrihedron != NULL)
- {
- myGraduatedTrihedron->Release (theCtx.operator->());
- }
+ myTrihedron .Release (theCtx.operator->());
+ myGraduatedTrihedron.Release (theCtx.operator->());
if (!myTextureEnv.IsNull())
{
theCtx->DelayedRelease (myTextureEnv);
myTextureEnv.Nullify();
}
- if (myBgTexture.TexId != 0)
+
+ if (myTextureParams != NULL)
+ {
+ myTextureParams->Release (theCtx.operator->());
+ }
+ if (myBgGradientArray != NULL)
{
- glDeleteTextures (1, (GLuint*)&(myBgTexture.TexId));
- myBgTexture.TexId = 0;
+ myBgGradientArray->Release (theCtx.operator->());
}
+ if (myBgTextureArray != NULL)
+ {
+ myBgTextureArray->Release (theCtx.operator->());
+ }
+
+ releaseRaytraceResources (theCtx);
}
void OpenGl_View::SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
if (!anImage.IsNull())
myTextureEnv->Init (theCtx, *anImage.operator->(), theTexture->Type());
- myModificationState++;
+ myToUpdateEnvironmentMap = Standard_True;
}
void OpenGl_View::SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail theMode)
{
mySurfaceDetail = theMode;
- myModificationState++;
+ myToUpdateEnvironmentMap = Standard_True;
}
// =======================================================================
/*----------------------------------------------------------------------*/
-void OpenGl_View::TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
- const Aspect_TypeOfTriedronPosition thePosition,
+void OpenGl_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
const Quantity_NameOfColor theColor,
const Standard_Real theScale,
const Standard_Boolean theAsWireframe)
{
- OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
- myTrihedron = new OpenGl_Trihedron (thePosition, theColor, theScale, theAsWireframe);
+ myToShowTrihedron = true;
+ myTrihedron.SetWireframe (theAsWireframe);
+ myTrihedron.SetPosition (thePosition);
+ myTrihedron.SetScale (theScale);
+ myTrihedron.SetLabelsColor (theColor);
}
/*----------------------------------------------------------------------*/
void OpenGl_View::TriedronErase (const Handle(OpenGl_Context)& theCtx)
{
- OpenGl_Element::Destroy (theCtx.operator->(), myTrihedron);
+ myToShowTrihedron = false;
+ myTrihedron.Release (theCtx.operator->());
}
/*----------------------------------------------------------------------*/
-void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
- const Graphic3d_CGraduatedTrihedron& theData)
+void OpenGl_View::GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
+ const Graphic3d_GraduatedTrihedron& theData)
{
- OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
- myGraduatedTrihedron = new OpenGl_GraduatedTrihedron (theData);
+ myToShowGradTrihedron = true;
+ myGraduatedTrihedron.SetValues (theCtx, theData);
}
/*----------------------------------------------------------------------*/
void OpenGl_View::GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx)
{
- OpenGl_Element::Destroy (theCtx.operator->(), myGraduatedTrihedron);
+ myToShowGradTrihedron = false;
+ myGraduatedTrihedron.Release (theCtx.operator->());
}
/*----------------------------------------------------------------------*/
aModelMatrix,
aProjMatrix,
aViewport,
- aWinZ,
+ aWinX,
aWinY,
aWinZ);
}