1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028912: Visualization, TKOpenGl - multi-texture support

Graphic3d_AspectFillArea3d now stores array of textures.
Graphic3d_TextureParams stores texture unit for mapping texture.

OpenGl_Context::BindTextures() - context now manages the set of active textures.
Related code has been removed from OpenGl_Workspace.

OpenGl_Sampler has been extended to hold texture parameters structure.
OpenGl_Texture now holds OpenGl_Sampler instance as class field.
OpenGl_Texture inherits new class OpenGl_NamedResource and holds
texture identifier used for sharing resource in OpenGl_Context.

OpenGl_RaytraceGeometry now creates bindless textures taking
Sampler object directly from OpenGl_Texture.
OpenGl_Context::BindTextures() automatically recreates immutable
Sampler Object on texture parameters change.

Declared new structure OpenGl_ArbSamplerObject for platform-neutral
usage of related functionality.
Related functions are now loaded within OpenGL ES 3.0+.

Declarations.glsl - occActiveSampler has been renamed to occSampler0
with aliases occSamplerBaseColor (main) and occActiveSampler (for compatibility).
Additional texture samplers should be declared explicitly
within specific GLSL program as occSampler1, occSampler2, etc.

AIS_Shape and AIS_ColoredShape now computes Shaded presentation
with UV coordinates if texture mapping is enabled in Drawer.

vshaderprog now accepts Shader source code as parameter.
This commit is contained in:
kgv
2017-07-10 15:43:25 +03:00
committed by bugmaster
parent a6dee93dfa
commit cc8cbabe5c
59 changed files with 2095 additions and 1272 deletions

View File

@@ -130,6 +130,9 @@ Graphic3d_TextureParams.cxx
Graphic3d_TextureParams.hxx
Graphic3d_TextureRoot.cxx
Graphic3d_TextureRoot.hxx
Graphic3d_TextureUnit.hxx
Graphic3d_TextureSet.cxx
Graphic3d_TextureSet.hxx
Graphic3d_ToneMappingMethod.hxx
Graphic3d_TransformError.hxx
Graphic3d_TransformPers.hxx

View File

@@ -67,3 +67,18 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
throw Aspect_AspectFillAreaDefinitionError("Bad value for EdgeLineWidth");
}
}
// =======================================================================
// function : Graphic3d_AspectFillArea3d
// purpose :
// =======================================================================
void Graphic3d_AspectFillArea3d::SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture)
{
if (theTexture.IsNull())
{
myTextureSet.Nullify();
return;
}
myTextureSet = new Graphic3d_TextureSet (theTexture);
}

View File

@@ -26,6 +26,7 @@
#include <Graphic3d_PolygonOffset.hxx>
#include <Graphic3d_ShaderProgram.hxx>
#include <Graphic3d_TextureMap.hxx>
#include <Graphic3d_TextureSet.hxx>
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
@@ -153,12 +154,25 @@ public:
//! Sets up OpenGL/GLSL shader program.
void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
//! Return texture array to be mapped.
const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; }
//! Setup texture array to be mapped.
void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; }
//! Return texture to be mapped.
const Handle(Graphic3d_TextureMap)& TextureMap() const { return myTextureMap; }
//Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead")
Handle(Graphic3d_TextureMap) TextureMap() const
{
return !myTextureSet.IsNull() && !myTextureSet->IsEmpty()
? myTextureSet->First()
: Handle(Graphic3d_TextureMap)();
}
//! Assign texture to be mapped.
//! See also SetTextureMap() to actually activate texture mapping.
void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture) { myTextureMap = theTexture; }
//! See also SetTextureMapOn() to actually activate texture mapping.
//Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead")
Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture);
//! Return true if texture mapping is enabled (false by default).
bool ToMapTexture() const { return myToMapTexture; }
@@ -166,6 +180,9 @@ public:
//! Return true if texture mapping is enabled (false by default).
bool TextureMapState() const { return myToMapTexture; }
//! Enable or disable texture mapping (has no effect if texture is not set).
void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; }
//! Enable texture mapping (has no effect if texture is not set).
void SetTextureMapOn() { myToMapTexture = true; }
@@ -312,7 +329,7 @@ public:
protected:
Handle(Graphic3d_ShaderProgram) myProgram;
Handle(Graphic3d_TextureMap) myTextureMap;
Handle(Graphic3d_TextureSet) myTextureSet;
Graphic3d_MaterialAspect myFrontMaterial;
Graphic3d_MaterialAspect myBackMaterial;

View File

@@ -178,14 +178,24 @@ void Graphic3d_ClipPlane::SetCappingMaterial (const Graphic3d_MaterialAspect& th
// =======================================================================
void Graphic3d_ClipPlane::SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture)
{
myAspect->SetTextureMap (theTexture);
if (!theTexture.IsNull())
{
myAspect->SetTextureMapOn();
Handle(Graphic3d_TextureSet) aTextureSet = myAspect->TextureSet();
if (aTextureSet.IsNull() || aTextureSet->Size() != 1)
{
aTextureSet = new Graphic3d_TextureSet (theTexture);
}
else
{
aTextureSet->SetFirst (theTexture);
}
myAspect->SetTextureSet (aTextureSet);
}
else
{
myAspect->SetTextureMapOff();
myAspect->SetTextureSet (Handle(Graphic3d_TextureSet)());
}
++myAspectMod;
}

View File

@@ -137,7 +137,9 @@ public: // @name user-defined graphical attributes
Standard_EXPORT void SetCappingTexture (const Handle(Graphic3d_TextureMap)& theTexture);
//! @return capping texture map.
const Handle(Graphic3d_TextureMap)& CappingTexture() const { return myAspect->TextureMap(); }
Handle(Graphic3d_TextureMap) CappingTexture() const { return !myAspect->TextureSet().IsNull() && !myAspect->TextureSet()->IsEmpty()
? myAspect->TextureSet()->First()
: Handle(Graphic3d_TextureMap)(); }
//! Set hatch style (stipple) and turn hatching on.
//! @param theStyle [in] the hatch style.

View File

@@ -11,9 +11,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <Graphic3d_TextureParams.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TextureParams,Standard_Transient)
@@ -22,38 +20,31 @@ IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TextureParams,Standard_Transient)
// purpose :
// =======================================================================
Graphic3d_TextureParams::Graphic3d_TextureParams()
: myToModulate (Standard_False),
myToRepeat (Standard_False),
myFilter (Graphic3d_TOTF_NEAREST),
myAnisoLevel (Graphic3d_LOTA_OFF),
myRotAngle (0.0f),
: myGenPlaneS (0.0f, 0.0f, 0.0f, 0.0f),
myGenPlaneT (0.0f, 0.0f, 0.0f, 0.0f),
myScale (1.0f, 1.0f),
myTranslation(0.0f, 0.0f),
mySamplerRevision (0),
myTextureUnit(Graphic3d_TextureUnit_BaseColor),
myFilter (Graphic3d_TOTF_NEAREST),
myAnisoLevel (Graphic3d_LOTA_OFF),
myGenMode (Graphic3d_TOTM_MANUAL),
myGenPlaneS (0.0f, 0.0f, 0.0f, 0.0f),
myGenPlaneT (0.0f, 0.0f, 0.0f, 0.0f)
myRotAngle (0.0f),
myToModulate (Standard_False),
myToRepeat (Standard_False)
{
//
}
// =======================================================================
// function : Destroy
// function : ~Graphic3d_TextureParams
// purpose :
// =======================================================================
void Graphic3d_TextureParams::Destroy() const
Graphic3d_TextureParams::~Graphic3d_TextureParams()
{
//
}
// =======================================================================
// function : IsModulate
// purpose :
// =======================================================================
Standard_Boolean Graphic3d_TextureParams::IsModulate() const
{
return myToModulate;
}
// =======================================================================
// function : SetModulate
// purpose :
@@ -63,31 +54,17 @@ void Graphic3d_TextureParams::SetModulate (const Standard_Boolean theToModulate)
myToModulate = theToModulate;
}
// =======================================================================
// function : IsRepeat
// purpose :
// =======================================================================
Standard_Boolean Graphic3d_TextureParams::IsRepeat() const
{
return myToRepeat;
}
// =======================================================================
// function : SetRepeat
// purpose :
// =======================================================================
void Graphic3d_TextureParams::SetRepeat (const Standard_Boolean theToRepeat)
{
myToRepeat = theToRepeat;
}
// =======================================================================
// function : Filter
// purpose :
// =======================================================================
Graphic3d_TypeOfTextureFilter Graphic3d_TextureParams::Filter() const
{
return myFilter;
if (myToRepeat != theToRepeat)
{
myToRepeat = theToRepeat;
updateSamplerRevision();
}
}
// =======================================================================
@@ -96,16 +73,11 @@ Graphic3d_TypeOfTextureFilter Graphic3d_TextureParams::Filter() const
// =======================================================================
void Graphic3d_TextureParams::SetFilter (const Graphic3d_TypeOfTextureFilter theFilter)
{
myFilter = theFilter;
}
// =======================================================================
// function : AnisoFilter
// purpose :
// =======================================================================
Graphic3d_LevelOfTextureAnisotropy Graphic3d_TextureParams::AnisoFilter() const
{
return myAnisoLevel;
if (myFilter != theFilter)
{
myFilter = theFilter;
updateSamplerRevision();
}
}
// =======================================================================
@@ -114,16 +86,11 @@ Graphic3d_LevelOfTextureAnisotropy Graphic3d_TextureParams::AnisoFilter() const
// =======================================================================
void Graphic3d_TextureParams::SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel)
{
myAnisoLevel = theLevel;
}
// =======================================================================
// function : Rotation
// purpose :
// =======================================================================
Standard_ShortReal Graphic3d_TextureParams::Rotation() const
{
return myRotAngle;
if (myAnisoLevel != theLevel)
{
myAnisoLevel = theLevel;
updateSamplerRevision();
}
}
// =======================================================================
@@ -135,15 +102,6 @@ void Graphic3d_TextureParams::SetRotation (const Standard_ShortReal theAngleDegr
myRotAngle = theAngleDegrees;
}
// =======================================================================
// function : Scale
// purpose :
// =======================================================================
const Graphic3d_Vec2& Graphic3d_TextureParams::Scale() const
{
return myScale;
}
// =======================================================================
// function : SetScale
// purpose :
@@ -153,15 +111,6 @@ void Graphic3d_TextureParams::SetScale (const Graphic3d_Vec2 theScale)
myScale = theScale;
}
// =======================================================================
// function : Translation
// purpose :
// =======================================================================
const Graphic3d_Vec2& Graphic3d_TextureParams::Translation() const
{
return myTranslation;
}
// =======================================================================
// function : SetTranslation
// purpose :
@@ -171,33 +120,6 @@ void Graphic3d_TextureParams::SetTranslation (const Graphic3d_Vec2 theVec)
myTranslation = theVec;
}
// =======================================================================
// function : GenMode
// purpose :
// =======================================================================
Graphic3d_TypeOfTextureMode Graphic3d_TextureParams::GenMode() const
{
return myGenMode;
}
// =======================================================================
// function : GenPlaneS
// purpose :
// =======================================================================
const Graphic3d_Vec4& Graphic3d_TextureParams::GenPlaneS() const
{
return myGenPlaneS;
}
// =======================================================================
// function : GenPlaneT
// purpose :
// =======================================================================
const Graphic3d_Vec4& Graphic3d_TextureParams::GenPlaneT() const
{
return myGenPlaneT;
}
// =======================================================================
// function : SetGenMode
// purpose :

View File

@@ -14,130 +14,123 @@
#ifndef _Graphic3d_TextureParams_HeaderFile
#define _Graphic3d_TextureParams_HeaderFile
#include <Standard.hxx>
#include <Standard_Type.hxx>
#include <Standard_Boolean.hxx>
#include <Graphic3d_TypeOfTextureFilter.hxx>
#include <Graphic3d_LevelOfTextureAnisotropy.hxx>
#include <Standard_ShortReal.hxx>
#include <Graphic3d_Vec2.hxx>
#include <Graphic3d_TypeOfTextureMode.hxx>
#include <Graphic3d_Vec4.hxx>
#include <Graphic3d_TextureUnit.hxx>
#include <Graphic3d_TypeOfTextureFilter.hxx>
#include <Graphic3d_TypeOfTextureMode.hxx>
#include <Standard.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_ShortReal.hxx>
#include <Standard_Type.hxx>
#include <Standard_Transient.hxx>
class Graphic3d_TextureParams;
DEFINE_STANDARD_HANDLE(Graphic3d_TextureParams, Standard_Transient)
//! This class describes texture parameters.
class Graphic3d_TextureParams : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureParams, Standard_Transient)
public:
//! Default constructor.
Standard_EXPORT Graphic3d_TextureParams();
Standard_EXPORT void Destroy() const;
~Graphic3d_TextureParams()
{
Destroy();
}
//! Destructor.
Standard_EXPORT virtual ~Graphic3d_TextureParams();
//! Default texture unit to be used, default is Graphic3d_TextureUnit_BaseColor.
Graphic3d_TextureUnit TextureUnit() const { return myTextureUnit; }
//! Setup default texture unit.
void SetTextureUnit (Graphic3d_TextureUnit theUnit) { myTextureUnit = theUnit; }
//! @return TRUE if the texture is modulate.
//! Default value is FALSE.
Standard_EXPORT Standard_Boolean IsModulate() const;
Standard_Boolean IsModulate() const { return myToModulate; }
//! @param theToModulate turn modulation on/off.
Standard_EXPORT void SetModulate (const Standard_Boolean theToModulate);
//! @return TRUE if the texture repeat is enabled.
//! Default value is FALSE.
Standard_EXPORT Standard_Boolean IsRepeat() const;
Standard_Boolean IsRepeat() const { return myToRepeat; }
//! @param theToRepeat turn texture repeat mode ON or OFF (clamping).
Standard_EXPORT void SetRepeat (const Standard_Boolean theToRepeat);
//! @return texture interpolation filter.
//! Default value is Graphic3d_TOTF_NEAREST.
Standard_EXPORT Graphic3d_TypeOfTextureFilter Filter() const;
Graphic3d_TypeOfTextureFilter Filter() const { return myFilter; }
//! @param theFilter texture interpolation filter.
Standard_EXPORT void SetFilter (const Graphic3d_TypeOfTextureFilter theFilter);
//! @return level of anisontropy texture filter.
//! Default value is Graphic3d_LOTA_OFF.
Standard_EXPORT Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const;
Graphic3d_LevelOfTextureAnisotropy AnisoFilter() const { return myAnisoLevel; }
//! @param theLevel level of anisontropy texture filter.
Standard_EXPORT void SetAnisoFilter (const Graphic3d_LevelOfTextureAnisotropy theLevel);
//! @return rotation angle in degrees
//! Default value is 0.
Standard_EXPORT Standard_ShortReal Rotation() const;
Standard_ShortReal Rotation() const { return myRotAngle; }
//! @param theAngleDegrees rotation angle.
Standard_EXPORT void SetRotation (const Standard_ShortReal theAngleDegrees);
//! @return scale factor
//! Default value is no scaling (1.0; 1.0).
Standard_EXPORT const Graphic3d_Vec2& Scale() const;
const Graphic3d_Vec2& Scale() const { return myScale; }
//! @param theScale scale factor.
Standard_EXPORT void SetScale (const Graphic3d_Vec2 theScale);
//! @return translation vector
//! Default value is no translation (0.0; 0.0).
Standard_EXPORT const Graphic3d_Vec2& Translation() const;
const Graphic3d_Vec2& Translation() const { return myTranslation; }
//! @param theVec translation vector.
Standard_EXPORT void SetTranslation (const Graphic3d_Vec2 theVec);
//! @return texture coordinates generation mode.
//! Default value is Graphic3d_TOTM_MANUAL.
Standard_EXPORT Graphic3d_TypeOfTextureMode GenMode() const;
Graphic3d_TypeOfTextureMode GenMode() const { return myGenMode; }
//! @return texture coordinates generation plane S.
Standard_EXPORT const Graphic3d_Vec4& GenPlaneS() const;
const Graphic3d_Vec4& GenPlaneS() const { return myGenPlaneS; }
//! @return texture coordinates generation plane T.
Standard_EXPORT const Graphic3d_Vec4& GenPlaneT() const;
const Graphic3d_Vec4& GenPlaneT() const { return myGenPlaneT; }
//! Setup texture coordinates generation mode.
Standard_EXPORT void SetGenMode (const Graphic3d_TypeOfTextureMode theMode, const Graphic3d_Vec4 thePlaneS, const Graphic3d_Vec4 thePlaneT);
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureParams,Standard_Transient)
protected:
//! Return modification counter of parameters related to sampler state.
unsigned int SamplerRevision() const { return mySamplerRevision; }
private:
//! Increment revision.
void updateSamplerRevision() { ++mySamplerRevision; }
Standard_Boolean myToModulate;
Standard_Boolean myToRepeat;
Graphic3d_TypeOfTextureFilter myFilter;
Graphic3d_LevelOfTextureAnisotropy myAnisoLevel;
Standard_ShortReal myRotAngle;
Graphic3d_Vec2 myScale;
Graphic3d_Vec2 myTranslation;
Graphic3d_TypeOfTextureMode myGenMode;
Graphic3d_Vec4 myGenPlaneS;
Graphic3d_Vec4 myGenPlaneT;
private:
Graphic3d_Vec4 myGenPlaneS; //!< texture coordinates generation plane S
Graphic3d_Vec4 myGenPlaneT; //!< texture coordinates generation plane T
Graphic3d_Vec2 myScale; //!< texture coordinates scale factor vector; (1,1) by default
Graphic3d_Vec2 myTranslation; //!< texture coordinates translation vector; (0,0) by default
unsigned int mySamplerRevision; //!< modification counter of parameters related to sampler state
Graphic3d_TextureUnit myTextureUnit; //!< default texture unit to bind texture; Graphic3d_TextureUnit_BaseColor by default
Graphic3d_TypeOfTextureFilter myFilter; //!< texture filter, Graphic3d_TOTF_NEAREST by default
Graphic3d_LevelOfTextureAnisotropy myAnisoLevel; //!< level of anisotropy filter, Graphic3d_LOTA_OFF by default
Graphic3d_TypeOfTextureMode myGenMode; //!< texture coordinates generation mode, Graphic3d_TOTM_MANUAL by default
Standard_ShortReal myRotAngle; //!< texture coordinates rotation angle in degrees, 0 by default
Standard_Boolean myToModulate; //!< flag to modulate texture with material color, FALSE by default
Standard_Boolean myToRepeat; //!< flag to repeat (true) or wrap (false) texture coordinates out of [0,1] range
};
DEFINE_STANDARD_HANDLE(Graphic3d_TextureParams, Standard_Transient)
#endif // _Graphic3d_TextureParams_HeaderFile

View File

@@ -55,15 +55,17 @@ public:
//! This ID will be used to manage resource in graphic driver.
//!
//! Default implementation generates unique ID although inheritors may re-initialize it.
//! Default implementation generates unique ID within constructor;
//! inheritors may re-initialize it within their constructor,
//! but should never modify it afterwards.
//!
//! Multiple Graphic3d_TextureRoot instances with same ID
//! will be treated as single texture with different parameters
//! to optimize memory usage though this will be more natural
//! to use same instance of Graphic3d_TextureRoot when possible.
//!
//! Notice that inheritor may set this ID to empty string.
//! In this case independent graphical resource will be created
//! If this ID is set to empty string by inheritor,
//! then independent graphical resource will be created
//! for each instance of Graphic3d_AspectFillArea3d where texture will be used.
//!
//! @return texture identifier.
@@ -74,7 +76,7 @@ public:
//! Update image revision.
//! Can be used for signaling changes in the texture source (e.g. file update, pixmap update)
//! without re-creating texture source itself (e.g. preserving the unique id).
//! without re-creating texture source itself (since unique id should be never modified).
void UpdateRevision() { ++myRevision; }
//! This method will be called by graphic driver each time when texture resource should be created.
@@ -101,13 +103,13 @@ protected:
//! to be in Bottom-Up order (see Image_PixMap::IsTopDown()).
Standard_EXPORT Graphic3d_TextureRoot(const Handle(Image_PixMap)& thePixmap, const Graphic3d_TypeOfTexture theType);
//! Unconditionally generate new texture id.
//! Unconditionally generate new texture id. Should be called only within constructor.
Standard_EXPORT void generateId();
protected:
Handle(Graphic3d_TextureParams) myParams; //!< associated texture parameters
TCollection_AsciiString myTexId; //!< unique identifier of this resource (for sharing)
TCollection_AsciiString myTexId; //!< unique identifier of this resource (for sharing graphic resource); should never be modified outside constructor
Handle(Image_PixMap) myPixMap; //!< image pixmap - as one of the ways for defining the texture source
OSD_Path myPath; //!< image file path - as one of the ways for defining the texture source
Standard_Size myRevision; //!< image revision - for signaling changes in the texture source (e.g. file update, pixmap update)

View File

@@ -0,0 +1,16 @@
// Copyright (c) 2017 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 <Graphic3d_TextureSet.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_TextureSet, Standard_Transient)

View File

@@ -0,0 +1,90 @@
// Copyright (c) 2017 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.
#ifndef _Graphic3d_TextureSet_HeaderFile
#define _Graphic3d_TextureSet_HeaderFile
#include <Graphic3d_TextureMap.hxx>
#include <NCollection_Array1.hxx>
//! Class holding array of textures to be mapped as a set.
class Graphic3d_TextureSet : public Standard_Transient
{
DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureSet, Standard_Transient)
public:
//! Class for iterating texture set.
class Iterator : public NCollection_Array1<Handle(Graphic3d_TextureMap)>::Iterator
{
public:
//! Empty constructor.
Iterator() {}
//! Constructor.
Iterator (const Handle(Graphic3d_TextureSet)& theSet)
{
if (!theSet.IsNull())
{
NCollection_Array1<Handle(Graphic3d_TextureMap)>::Iterator::Init (theSet->myTextures);
}
}
};
public:
//! Empty constructor.
Graphic3d_TextureSet() {}
//! Constructor.
Graphic3d_TextureSet (Standard_Integer theNbTextures)
: myTextures (0, theNbTextures - 1) {}
//! Constructor for a single texture.
Graphic3d_TextureSet (const Handle(Graphic3d_TextureMap)& theTexture)
: myTextures (0, 0)
{
myTextures.ChangeFirst() = theTexture;
}
//! Return TRUE if texture array is empty.
Standard_Boolean IsEmpty() const { return myTextures.IsEmpty(); }
//! Return number of textures.
Standard_Integer Size() const { return myTextures.Size(); }
//! Return the lower index in texture set.
Standard_Integer Lower() const { return myTextures.Lower(); }
//! Return the upper index in texture set.
Standard_Integer Upper() const { return myTextures.Upper(); }
//! Return the first texture.
const Handle(Graphic3d_TextureMap)& First() const { return myTextures.First(); }
//! Return the first texture.
void SetFirst (const Handle(Graphic3d_TextureMap)& theTexture) { myTextures.ChangeFirst() = theTexture; }
//! Return the texture at specified position within [0, Size()) range.
const Handle(Graphic3d_TextureMap)& Value (Standard_Integer theIndex) const { return myTextures.Value (theIndex); }
//! Return the texture at specified position within [0, Size()) range.
void SetValue (Standard_Integer theIndex,
const Handle(Graphic3d_TextureMap)& theTexture) { myTextures.SetValue (theIndex, theTexture); }
protected:
NCollection_Array1<Handle(Graphic3d_TextureMap)> myTextures;
};
#endif // _Graphic3d_TextureSet_HeaderFile

View File

@@ -0,0 +1,49 @@
// Copyright (c) 2017 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.
#ifndef _Graphic3d_TextureUnit_HeaderFile
#define _Graphic3d_TextureUnit_HeaderFile
//! Texture unit.
enum Graphic3d_TextureUnit
{
// value as index number
Graphic3d_TextureUnit_0,
Graphic3d_TextureUnit_1,
Graphic3d_TextureUnit_2,
Graphic3d_TextureUnit_3,
Graphic3d_TextureUnit_4,
Graphic3d_TextureUnit_5,
Graphic3d_TextureUnit_6,
Graphic3d_TextureUnit_7,
Graphic3d_TextureUnit_8,
Graphic3d_TextureUnit_9,
Graphic3d_TextureUnit_10,
Graphic3d_TextureUnit_11,
Graphic3d_TextureUnit_12,
Graphic3d_TextureUnit_13,
Graphic3d_TextureUnit_14,
Graphic3d_TextureUnit_15,
Graphic3d_TextureUnit_BaseColor = Graphic3d_TextureUnit_0, //!< base color of the material
//Graphic3d_TextureUnit_Normal = Graphic3d_TextureUnit_1, //!< tangent space normal map
//Graphic3d_TextureUnit_MetallicRoughness = Graphic3d_TextureUnit_2, //!< metalness+roughness of the material
//Graphic3d_TextureUnit_Emissive = Graphic3d_TextureUnit_3, //!< emissive map controls the color and intensity of the light being emitted by the material
//Graphic3d_TextureUnit_Occlusion = Graphic3d_TextureUnit_4, //!< occlusion map indicating areas of indirect lighting
};
enum
{
Graphic3d_TextureUnit_NB = Graphic3d_TextureUnit_15 + 1
};
#endif // _Graphic3d_TextureUnit_HeaderFile

View File

@@ -21,6 +21,7 @@ enum Graphic3d_TypeOfLimit
Graphic3d_TypeOfLimit_MaxNbClipPlanes, //!< maximum number of active clipping planes
Graphic3d_TypeOfLimit_MaxNbViews, //!< maximum number of views
Graphic3d_TypeOfLimit_MaxTextureSize, //!< maximum size of texture
Graphic3d_TypeOfLimit_MaxCombinedTextureUnits, //!< maximum number of combined texture units for multitexturing
Graphic3d_TypeOfLimit_MaxMsaa, //!< maximum number of MSAA samples
Graphic3d_TypeOfLimit_HasRayTracing, //!< indicates whether ray tracing is supported
Graphic3d_TypeOfLimit_HasRayTracingTextures, //!< indicates whether ray tracing textures are supported