def318ae990cc01c04cba79f613a877c3367e1cc
[occt.git] / src / Graphic3d / Graphic3d_ShaderObject.hxx
1 // Created on: 2013-09-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _Graphic3d_ShaderObject_HeaderFile
17 #define _Graphic3d_ShaderObject_HeaderFile
18
19 #include <OSD_Path.hxx>
20
21 #include <Graphic3d_TypeOfShaderObject.hxx>
22
23 //! Forward declaration
24 class Handle(Graphic3d_ShaderObject);
25
26 //! This class is responsible for managing shader objects.
27 class Graphic3d_ShaderObject : public Standard_Transient
28 {
29 private:
30
31   //! Creates new shader object of specified type.
32   Standard_EXPORT Graphic3d_ShaderObject (const Graphic3d_TypeOfShaderObject theType);
33
34 public:
35
36   //! Releases resources of shader object. 
37   Standard_EXPORT virtual ~Graphic3d_ShaderObject();
38   
39   //! Checks if the shader object is valid or not.
40   Standard_EXPORT virtual Standard_Boolean IsDone() const;
41   
42   //! Returns the full path to the shader source.
43   const OSD_Path& Path() const { return myPath; }
44
45   //! Returns the source code of the shader object.
46   const TCollection_AsciiString& Source() const { return mySource; }
47
48   //! Returns type of the shader object.
49   Graphic3d_TypeOfShaderObject Type() const { return myType; }
50   
51   //! Returns unique ID used to manage resource in graphic driver.
52   const TCollection_AsciiString& GetId() const { return myID; }
53
54   //! Creates new shader object from specified file.
55   Standard_EXPORT static Handle(Graphic3d_ShaderObject) CreateFromFile (const Graphic3d_TypeOfShaderObject theType,
56                                                                         const TCollection_AsciiString&     thePath);
57
58   //! Creates new shader object from specified source.
59   Standard_EXPORT static Handle(Graphic3d_ShaderObject) CreateFromSource (const Graphic3d_TypeOfShaderObject theType,
60                                                                           const TCollection_AsciiString&     theSource);
61
62 public:
63
64   DEFINE_STANDARD_RTTI (Graphic3d_ShaderObject, Standard_Transient)
65
66 protected:
67
68   TCollection_AsciiString myID;     //!< the ID of shader object
69   TCollection_AsciiString mySource; //!< the source code of shader object
70   OSD_Path                myPath;   //!< the path to shader source (may be empty)
71
72 private:
73   
74   //! The type of shader object.
75   Graphic3d_TypeOfShaderObject myType;
76 };
77
78 DEFINE_STANDARD_HANDLE (Graphic3d_ShaderObject, Standard_Transient)
79
80 #endif