|
|
|||
File indexing completed on 2026-09-23 09:18:39
0001 // Created on: 2013-09-19 0002 // Created by: Denis BOGOLEPOV 0003 // Copyright (c) 2013-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef OpenGl_ShaderObject_HeaderFile 0017 #define OpenGl_ShaderObject_HeaderFile 0018 0019 #include <Graphic3d_ShaderObject.hxx> 0020 #include <OpenGl_GlCore20.hxx> 0021 #include <OpenGl_Resource.hxx> 0022 #include <Quantity_Date.hxx> 0023 0024 //! Wrapper for OpenGL shader object. 0025 class OpenGl_ShaderObject : public OpenGl_Resource 0026 { 0027 DEFINE_STANDARD_RTTIEXT(OpenGl_ShaderObject, OpenGl_Resource) 0028 friend class OpenGl_ShaderProgram; 0029 0030 public: 0031 //! Non-valid shader name. 0032 static const GLuint NO_SHADER = 0; 0033 0034 public: 0035 //! Creates uninitialized shader object. 0036 Standard_EXPORT OpenGl_ShaderObject(GLenum theType); 0037 0038 //! Releases resources of shader object. 0039 Standard_EXPORT ~OpenGl_ShaderObject() override; 0040 0041 //! Loads shader source code. 0042 Standard_EXPORT bool LoadSource(const occ::handle<OpenGl_Context>& theCtx, 0043 const TCollection_AsciiString& theSource); 0044 0045 //! Compiles the shader object. 0046 Standard_EXPORT bool Compile(const occ::handle<OpenGl_Context>& theCtx); 0047 0048 //! Wrapper for compiling shader object with verbose printing on error. 0049 //! @param theCtx bound OpenGL context 0050 //! @param theId GLSL program id to define file name 0051 //! @param theSource source code to load 0052 //! @param theIsVerbose flag to print log on error 0053 //! @param theToPrintSource flag to print source code on error 0054 Standard_EXPORT bool LoadAndCompile(const occ::handle<OpenGl_Context>& theCtx, 0055 const TCollection_AsciiString& theId, 0056 const TCollection_AsciiString& theSource, 0057 bool theIsVerbose = true, 0058 bool theToPrintSource = true); 0059 0060 //! Print source code of this shader object to messenger. 0061 Standard_EXPORT void DumpSourceCode(const occ::handle<OpenGl_Context>& theCtx, 0062 const TCollection_AsciiString& theId, 0063 const TCollection_AsciiString& theSource) const; 0064 0065 //! Fetches information log of the last compile operation. 0066 Standard_EXPORT bool FetchInfoLog(const occ::handle<OpenGl_Context>& theCtx, 0067 TCollection_AsciiString& theLog); 0068 0069 //! Creates new empty shader object of specified type. 0070 Standard_EXPORT bool Create(const occ::handle<OpenGl_Context>& theCtx); 0071 0072 //! Destroys shader object. 0073 Standard_EXPORT void Release(OpenGl_Context* theCtx) override; 0074 0075 //! Returns estimated GPU memory usage - not implemented. 0076 size_t EstimatedDataSize() const override { return 0; } 0077 0078 //! Returns type of shader object. 0079 GLenum Type() const { return myType; } 0080 0081 public: 0082 //! Update the shader object from external file in the following way: 0083 //! 1) If external file does not exist, then it will be created (current source code will be 0084 //! dumped, no recompilation) and FALSE will be returned. 2) If external file exists and it has 0085 //! the same timestamp as myDumpDate, nothing will be done and FALSE will be returned. 3) 0086 //! If external file exists and it has newer timestamp than myDumpDate, shader will be 0087 //! recompiled and TRUE will be returned. 0088 //! @param theCtx OpenGL context bound to this working thread 0089 //! @param theId GLSL program id to define file name 0090 //! @param theFolder folder to store files 0091 //! @param theToBeautify flag improving formatting (add extra newlines) 0092 //! @param theToReset when TRUE, existing dumps will be overridden 0093 Standard_EXPORT bool updateDebugDump(const occ::handle<OpenGl_Context>& theCtx, 0094 const TCollection_AsciiString& theId, 0095 const TCollection_AsciiString& theFolder, 0096 bool theToBeautify, 0097 bool theToReset); 0098 0099 protected: 0100 Quantity_Date myDumpDate; //!< The recent date of the shader dump 0101 GLenum myType; //!< Type of OpenGL shader object 0102 GLuint myShaderID; //!< Handle of OpenGL shader object 0103 }; 0104 0105 #endif // _OpenGl_ShaderObject_Header
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|