30f0ad28 |
1 | // Created on: 2013-09-19 |
2 | // Created by: Denis BOGOLEPOV |
3 | // Copyright (c) 2013 OPEN CASCADE SAS |
4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public |
6 | // License Version 6.5 (the "License"). You may not use the content of this file |
7 | // except in compliance with the License. Please obtain a copy of the License |
8 | // at http://www.opencascade.org and read it completely before using this file. |
9 | // |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
12 | // |
13 | // The Original Code and all software distributed under the License is |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
15 | // Initial Developer hereby disclaims all such warranties, including without |
16 | // limitation, any warranties of merchantability, fitness for a particular |
17 | // purpose or non-infringement. Please see the License for the specific terms |
18 | // and conditions governing the rights and limitations under the License. |
19 | |
20 | #ifndef _OpenGl_ShaderObject_Header |
21 | #define _OpenGl_ShaderObject_Header |
22 | |
23 | #include <Handle_OpenGl_ShaderObject.hxx> |
24 | #include <Graphic3d_ShaderObject.hxx> |
25 | #include <OpenGl_GlCore20.hxx> |
26 | #include <OpenGl_Resource.hxx> |
27 | |
28 | //! Wrapper for OpenGL shader object. |
29 | class OpenGl_ShaderObject : public OpenGl_Resource |
30 | { |
31 | |
32 | public: |
33 | |
34 | //! Non-valid shader name. |
35 | static const GLuint NO_SHADER = 0; |
36 | |
37 | public: |
38 | |
39 | //! Creates uninitialized shader object. |
40 | Standard_EXPORT OpenGl_ShaderObject (GLenum theType); |
41 | |
42 | //! Releases resources of shader object. |
43 | Standard_EXPORT virtual ~OpenGl_ShaderObject(); |
44 | |
45 | //! Loads shader source code. |
46 | Standard_EXPORT Standard_Boolean LoadSource (const Handle(OpenGl_Context)& theCtx, |
47 | const TCollection_AsciiString& theSource); |
48 | |
49 | //! Compiles the shader object. |
50 | Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx); |
51 | |
52 | //! Initializes (loads and compiles) shader object with the specified description. |
53 | Standard_EXPORT Standard_Boolean Initialize (const Handle(OpenGl_Context)& theCtx, |
54 | const Handle(Graphic3d_ShaderObject)& theShader); |
55 | |
56 | //! Fetches information log of the last compile operation. |
57 | Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx, |
58 | TCollection_AsciiString& theLog); |
59 | |
60 | //! Creates new empty shader object of specified type. |
61 | Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx); |
62 | |
63 | //! Destroys shader object. |
64 | Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx); |
65 | |
66 | //! Returns type of shader object. |
67 | GLenum Type() const { return myType; } |
68 | |
69 | protected: |
70 | |
71 | GLenum myType; //!< Type of OpenGL shader object |
72 | GLuint myShaderID; //!< Handle of OpenGL shader object |
73 | |
74 | public: |
75 | |
76 | DEFINE_STANDARD_RTTI (OpenGl_ShaderObject) |
77 | friend class OpenGl_ShaderProgram; |
78 | |
79 | }; |
80 | |
81 | #endif // _OpenGl_ShaderObject_Header |