1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00
occt/src/OpenGl/OpenGl_AspectsProgram.cxx
kgv bf5f0ca20a 0029570: Visualization, Graphic3d_Aspect - merge Graphic3d_Group aspects
Graphic3d_AspectFillArea3d, Graphic3d_AspectLine3d, Graphic3d_AspectMarker3d
and Graphic3d_AspectText3d have been merged into new class Graphic3d_Aspects.
The old classes are preserved as dummy sub-classes of Graphic3d_Aspects
preserving different per-aspect defaults.

Methods IsGroupPrimitivesAspectSet(), GroupPrimitivesAspect(), FillAreaAspect(),
LineAspect() and MarkerAspect() have been removed from Graphic3d_Group.
Instead, a new method Graphic3d_Group::ReplaceAspects() has been introduced
for replacing existing group aspects.

AIS_Shape now uses new method AIS_InteractiveObject::replaceAspects()
for updating computed groups with new aspects without presentation recomputation
in places where SynchronizeAspects() is not applicable.

OpenGl_AspectFace, OpenGl_AspectLine, OpenGl_AspectMarker
and OpenGl_AspectText have been merged into new class OpenGl_Aspects.

ViewerTest::parseColor() - fix uninitialized alpha component.
Graphic3d_AspectText3d/Prs3d_TextAspect - removed unused properties Space, ExpansionFactor, Angle.
Remove getters Values() deprecated since OCCT 7.1.0.
2019-03-07 18:08:36 +03:00

79 lines
2.6 KiB
C++

// Copyright (c) 2019 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 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.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_AspectsProgram.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_ShaderManager.hxx>
#include <OpenGl_ShaderProgram.hxx>
namespace
{
static const TCollection_AsciiString THE_EMPTY_KEY;
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::Release (OpenGl_Context* theCtx)
{
if (!myShaderProgram.IsNull() && theCtx != NULL)
{
theCtx->ShaderManager()->Unregister (myShaderProgramId,
myShaderProgram);
}
myShaderProgramId.Clear();
myIsShaderReady = Standard_False;
}
// =======================================================================
// function : UpdateRediness
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::UpdateRediness (const Handle(Graphic3d_Aspects)& theAspect)
{
const TCollection_AsciiString& aShaderKey = theAspect->ShaderProgram().IsNull() ? THE_EMPTY_KEY : theAspect->ShaderProgram()->GetId();
if (aShaderKey.IsEmpty() || myShaderProgramId != aShaderKey)
{
myIsShaderReady = Standard_False;
}
}
// =======================================================================
// function : build
// purpose :
// =======================================================================
void OpenGl_AspectsProgram::build (const Handle(OpenGl_Context)& theCtx,
const Handle(Graphic3d_ShaderProgram)& theShader)
{
if (theCtx->core20fwd == NULL)
{
return;
}
// release old shader program resources
if (!myShaderProgram.IsNull())
{
theCtx->ShaderManager()->Unregister (myShaderProgramId, myShaderProgram);
myShaderProgramId.Clear();
myShaderProgram.Nullify();
}
if (theShader.IsNull())
{
return;
}
theCtx->ShaderManager()->Create (theShader, myShaderProgramId, myShaderProgram);
}