1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0024776: Visualization - inherit OpenGl_View from Graphic3d_CView

Expose interface of OpenGl_View (OpenGL graphics rendering methods) to client code
and collecting all high-level API methods of application views in V3d_View class.

1) Exposing interface of OpenGl_View:

The OpenGl_View inherits from new class Graphic3d_CView.
Graphic3d_CView is an interface class that declares abstract methods for managing displayed structures,
display properties and a base layer code that implements computation
and management of HLR (or more broadly speaking view-depended) structures.

In new implementation it takes place of eliminated Visual3d_View.
As before the instance of Graphic3d_CView is still completely managed by V3d_View classes.
It can be accessed through V3d_View interface but normally this should not be required as all its methods are completely wrapped.

In more details, a concrete specialization of Graphic3d_CView is created and returned by graphical driver on request.
Right after creation the views is directly used for setting rendering properties and adding graphical structures to be displayed.

The rendering of graphics is possible after mapping a window and activating the view.
The direct setting of properties makes obsolete usage of intermediate structures with display parameter
like Visual3d_ContextView and etc (the whole package of Visual3d become redundant).

2) Collecting all high-level API methods of application views in V3d package:

The patch includes elimination of Visual3d layer.
All of its methods that could be previously used by application are now exposed and should be accessed on the level of V3d entities.
- Introduced new class Graphic3d_CView.
  This is a base class for render views.
  Made possible to specialize concrete instances of the class by graphical driver.
- Moved all methods managing rendering views into interface of Graphic3d_CView.
  The corresponding methods were removed from interface of graphical driver.

3) Eliminated Visual3d package:

- Logic of managing display of structures was put from Visual3d_ViewManager into Graphic3d_StructureManager.
- Removed Visual3d_View class. Logic of managing computed structures was put into base layer of Graphi3d_CView.
- Removed all intermediate structures for storing view parameters e.g. Visual3d_ContextView.
  All settings are kept by instances of Graphic3d_CView
- Removed Visual3d_Light intermediate class.
  All light properties are still stored in Graphic3d_CLight structure.
  The structure is directly access by instance of V3d_Light classes.
- Moved all needed enumerations into Graphic3d package.

4) Update package D3DHost to new changes.

5) Update code of OCCT samples to new changes.
This commit is contained in:
apl
2015-09-22 11:49:33 +03:00
committed by kgv
parent 97d87ffa94
commit c357e42610
159 changed files with 9998 additions and 14088 deletions

View File

@@ -206,7 +206,7 @@ const char THE_FRAG_CLIP_PLANES[] =
// purpose : Creates new empty shader manager
// =======================================================================
OpenGl_ShaderManager::OpenGl_ShaderManager (OpenGl_Context* theContext)
: myShadingModel (Visual3d_TOM_VERTEX),
: myShadingModel (Graphic3d_TOSM_VERTEX),
myContext (theContext),
myLastView (NULL)
{
@@ -340,7 +340,7 @@ Standard_Boolean OpenGl_ShaderManager::IsEmpty() const
// =======================================================================
void OpenGl_ShaderManager::switchLightPrograms()
{
TCollection_AsciiString aKey (myShadingModel == Visual3d_TOM_FRAGMENT ? "p_" : "g_");
TCollection_AsciiString aKey (myShadingModel == Graphic3d_TOSM_FRAGMENT ? "p_" : "g_");
const OpenGl_ListOfLight* aLights = myLightSourceState.LightSources();
if (aLights != NULL)
{
@@ -348,15 +348,15 @@ void OpenGl_ShaderManager::switchLightPrograms()
{
switch (aLightIter.Value().Type)
{
case Visual3d_TOLS_AMBIENT:
case Graphic3d_TOLS_AMBIENT:
break; // skip ambient
case Visual3d_TOLS_DIRECTIONAL:
case Graphic3d_TOLS_DIRECTIONAL:
aKey += "d";
break;
case Visual3d_TOLS_POSITIONAL:
case Graphic3d_TOLS_POSITIONAL:
aKey += "p";
break;
case Visual3d_TOLS_SPOT:
case Graphic3d_TOLS_SPOT:
aKey += "s";
break;
}
@@ -385,7 +385,7 @@ void OpenGl_ShaderManager::UpdateLightSourceStateTo (const OpenGl_ListOfLight* t
// function : SetShadingModel
// purpose :
// =======================================================================
void OpenGl_ShaderManager::SetShadingModel (const Visual3d_TypeOfModel theModel)
void OpenGl_ShaderManager::SetShadingModel (const Graphic3d_TypeOfShadingModel theModel)
{
myShadingModel = theModel;
switchLightPrograms();
@@ -530,7 +530,7 @@ void OpenGl_ShaderManager::PushLightSourceState (const Handle(OpenGl_ShaderProgr
for (OpenGl_ListOfLight::Iterator anIter (*myLightSourceState.LightSources()); anIter.More(); anIter.Next())
{
const OpenGl_Light& aLight = anIter.Value();
if (aLight.Type == Visual3d_TOLS_AMBIENT)
if (aLight.Type == Graphic3d_TOLS_AMBIENT)
{
anAmbient += aLight.Color;
continue;
@@ -546,10 +546,10 @@ void OpenGl_ShaderManager::PushLightSourceState (const Handle(OpenGl_ShaderProgr
OpenGl_ShaderLightParameters& aLightParams = aLightParamsArray[aLightsNb];
aLightParams.Color = aLight.Color;
aLightParams.Position = aLight.Type == Visual3d_TOLS_DIRECTIONAL
aLightParams.Position = aLight.Type == Graphic3d_TOLS_DIRECTIONAL
? -aLight.Direction
: aLight.Position;
if (aLight.Type == Visual3d_TOLS_SPOT)
if (aLight.Type == Graphic3d_TOLS_SPOT)
{
aLightParams.Direction = aLight.Direction;
}
@@ -826,7 +826,7 @@ const OpenGl_SurfaceDetailState& OpenGl_ShaderManager::SurfaceDetailState() cons
// function : UpdateSurfaceDetailStateTo
// purpose : Updates state of OCCT surface detail
// =======================================================================
void OpenGl_ShaderManager::UpdateSurfaceDetailStateTo (const Visual3d_TypeOfSurfaceDetail theDetail)
void OpenGl_ShaderManager::UpdateSurfaceDetailStateTo (const Graphic3d_TypeOfSurfaceDetail theDetail)
{
mySurfaceDetailState.Set (theDetail);
mySurfaceDetailState.Update();
@@ -1327,7 +1327,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFlat (Handle(OpenGl_Shad
// =======================================================================
TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (const Standard_Boolean theHasVertColor)
{
bool aLightsMap[Visual3d_TOLS_SPOT + 1] = { false, false, false, false };
bool aLightsMap[Graphic3d_TOLS_SPOT + 1] = { false, false, false, false };
TCollection_AsciiString aLightsFunc, aLightsLoop;
const OpenGl_ListOfLight* aLights = myLightSourceState.LightSources();
if (aLights != NULL)
@@ -1337,16 +1337,16 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (const Standard
{
switch (aLightIter.Value().Type)
{
case Visual3d_TOLS_AMBIENT:
case Graphic3d_TOLS_AMBIENT:
--anIndex;
break; // skip ambient
case Visual3d_TOLS_DIRECTIONAL:
case Graphic3d_TOLS_DIRECTIONAL:
aLightsLoop = aLightsLoop + EOL" directionalLight (" + anIndex + ", theNormal, theView, theIsFront);";
break;
case Visual3d_TOLS_POSITIONAL:
case Graphic3d_TOLS_POSITIONAL:
aLightsLoop = aLightsLoop + EOL" pointLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);";
break;
case Visual3d_TOLS_SPOT:
case Graphic3d_TOLS_SPOT:
aLightsLoop = aLightsLoop + EOL" spotLight (" + anIndex + ", theNormal, theView, aPoint, theIsFront);";
break;
}
@@ -1360,10 +1360,10 @@ TCollection_AsciiString OpenGl_ShaderManager::stdComputeLighting (const Standard
aTypeBit = true;
switch (aLightIter.Value().Type)
{
case Visual3d_TOLS_AMBIENT: break;
case Visual3d_TOLS_DIRECTIONAL: aLightsFunc += THE_FUNC_directionalLight; break;
case Visual3d_TOLS_POSITIONAL: aLightsFunc += THE_FUNC_pointLight; break;
case Visual3d_TOLS_SPOT: aLightsFunc += THE_FUNC_spotLight; break;
case Graphic3d_TOLS_AMBIENT: break;
case Graphic3d_TOLS_DIRECTIONAL: aLightsFunc += THE_FUNC_directionalLight; break;
case Graphic3d_TOLS_POSITIONAL: aLightsFunc += THE_FUNC_pointLight; break;
case Graphic3d_TOLS_SPOT: aLightsFunc += THE_FUNC_spotLight; break;
}
}
}