mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0027258: Configuration - generate built-in replacement for mandatory resource files
Generation of header files from resource files was added to CMake and genproj procedures. Message_MsgFile has been extended with new method ::LoadFromString() for loading messages from embedded resources. Message_MsgFile::LoadFromString() is now a preferred way for loading message resources by application as alternative to environment variables. TObje/TObj.msg is now embedded into TObj_Application.cxx. TObj_Application now loads its global messages on instantiation of the first class instance. UnitsAPI/Lexi_Expr.dat now completely embedded into Units_Lexicon.cxx. UnitsAPI/Units.dat now embedded into Units_UnitsDictionary.cxx but can be regenerated from resource file. The definition of the following units have been removed: benne à charbon, calorie (diététique). Unused message files XSMessage/IGES.us and IGES.fr have been removed. Related code IGESData.cxx has been removed as well. XSMessage/XSTEP.us is now embedded into Interface_StaticStandards.cxx and used for fallback initialization in case when file resources defined by CSF_XSMessage environment variable are missing. SHMessage/SHAPE.us is now embedded into ShapeExtend.cxx and used for fallback initialization in case when file resources defined by CSF_XHMessage environment variable are missing. Duplicating code has been removed from ShapeProcess_OperLibrary.cxx. Shaders/Declarations.glsl and Shaders/DeclarationsImpl.glsl are now embedded into OpenGl_ShaderProgram.cxx. CSF_ShadersDirectory is no more required for using OCCT 3D Viewer. Ray-Tracing GLSL programs from Shaders are now embedded into OpenGl_View_Raytrace.cxx. File resources are still used instead of embedded programs when CSF_ShadersDirectory is defined, but this functionality is intended for OCCT development. Enumeration Graphic3d_ShaderProgram::ShaderName_Phong demonstrating custom GLSL program usage has been removed.
This commit is contained in:
@@ -13,16 +13,15 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <Standard_Atomic.hxx>
|
||||
#include <Standard_Assert.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
|
||||
#include <Graphic3d_GraphicDriver.hxx>
|
||||
#include <Graphic3d_ShaderObject.hxx>
|
||||
#include <Graphic3d_ShaderProgram.hxx>
|
||||
#include <OSD_Directory.hxx>
|
||||
#include <OSD_Environment.hxx>
|
||||
#include <OSD_File.hxx>
|
||||
#include <OSD_Path.hxx>
|
||||
#include <Standard_Atomic.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_ShaderProgram,Standard_Transient)
|
||||
|
||||
@@ -31,7 +30,6 @@ namespace
|
||||
static volatile Standard_Integer THE_PROGRAM_OBJECT_COUNTER = 0;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
// function : ShadersFolder
|
||||
// purpose :
|
||||
@@ -57,9 +55,6 @@ const TCollection_AsciiString& Graphic3d_ShaderProgram::ShadersFolder()
|
||||
|
||||
if (THE_SHADERS_FOLDER.IsEmpty())
|
||||
{
|
||||
std::cerr << "Both environment variables CSF_ShadersDirectory and CASROOT are undefined!\n"
|
||||
<< "At least one should be defined to use standard GLSL programs.\n";
|
||||
Standard_Failure::Raise ("CSF_ShadersDirectory and CASROOT are undefined");
|
||||
return THE_SHADERS_FOLDER;
|
||||
}
|
||||
|
||||
@@ -88,63 +83,15 @@ Graphic3d_ShaderProgram::Graphic3d_ShaderProgram()
|
||||
+ TCollection_AsciiString (Standard_Atomic_Increment (&THE_PROGRAM_OBJECT_COUNTER));
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Graphic3d_ShaderProgram
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
Graphic3d_ShaderProgram::Graphic3d_ShaderProgram (const Graphic3d_ShaderProgram::ShaderName theName)
|
||||
{
|
||||
const TCollection_AsciiString& aShadersRoot = Graphic3d_ShaderProgram::ShadersFolder();
|
||||
switch (theName)
|
||||
{
|
||||
case ShaderName_Phong:
|
||||
{
|
||||
myID = TCollection_AsciiString ("Graphic3d_ShaderProgram_Phong");
|
||||
const TCollection_AsciiString aSrcVert = aShadersRoot + "/PhongShading.vs";
|
||||
const TCollection_AsciiString aSrcFrag = aShadersRoot + "/PhongShading.fs";
|
||||
|
||||
if (!aSrcVert.IsEmpty()
|
||||
&& !OSD_File (aSrcVert).Exists())
|
||||
{
|
||||
Standard_Failure::Raise ("Graphic3d_ShaderProgram, PhongShading.vs is not found");
|
||||
return;
|
||||
}
|
||||
if (!aSrcFrag.IsEmpty()
|
||||
&& !OSD_File (aSrcFrag).Exists())
|
||||
{
|
||||
Standard_Failure::Raise ("Graphic3d_ShaderProgram, PhongShading.fs is not found");
|
||||
return;
|
||||
}
|
||||
|
||||
AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_VERTEX, aSrcVert));
|
||||
AttachShader (Graphic3d_ShaderObject::CreateFromFile (Graphic3d_TOS_FRAGMENT, aSrcFrag));
|
||||
break;
|
||||
}
|
||||
case ShaderName_UNKNOWN:
|
||||
default:
|
||||
{
|
||||
Standard_Failure::Raise ("Graphic3d_ShaderProgram, unknown program name");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : ~Graphic3d_ShaderProgram
|
||||
// purpose : Releases resources of program object
|
||||
// =======================================================================
|
||||
Graphic3d_ShaderProgram::~Graphic3d_ShaderProgram()
|
||||
{
|
||||
Destroy();
|
||||
//
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : Destroy
|
||||
// purpose : Releases resources of program object
|
||||
// =======================================================================
|
||||
void Graphic3d_ShaderProgram::Destroy() const
|
||||
{ }
|
||||
|
||||
// =======================================================================
|
||||
// function : IsDone
|
||||
// purpose : Checks if the program object is valid or not
|
||||
|
@@ -35,30 +35,14 @@ typedef NCollection_Sequence<Handle(Graphic3d_ShaderAttribute)> Graphic3d_Shader
|
||||
class Graphic3d_ShaderProgram : public Standard_Transient
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! The list of built-in GLSL programs
|
||||
enum ShaderName
|
||||
{
|
||||
ShaderName_UNKNOWN, //!< undefined program
|
||||
ShaderName_Phong //!< per-pixel lighting (Phong shading)
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
//! Creates new empty program object.
|
||||
Standard_EXPORT Graphic3d_ShaderProgram();
|
||||
|
||||
//! Creates program object from pre-defined shaders.
|
||||
//! Raises Standard_Failure exception if shader resources are unavailable.
|
||||
Standard_EXPORT Graphic3d_ShaderProgram (const Graphic3d_ShaderProgram::ShaderName theName);
|
||||
|
||||
//! Releases resources of program object.
|
||||
Standard_EXPORT virtual ~Graphic3d_ShaderProgram();
|
||||
|
||||
//! Releases resources of program object.
|
||||
Standard_EXPORT void Destroy() const;
|
||||
|
||||
//! Checks if the program object is valid or not.
|
||||
Standard_EXPORT virtual Standard_Boolean IsDone() const;
|
||||
|
||||
|
Reference in New Issue
Block a user