1 // Created on: 2013-09-19
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _OpenGl_ShaderObject_Header
17 #define _OpenGl_ShaderObject_Header
19 #include <Graphic3d_ShaderObject.hxx>
20 #include <OpenGl_GlCore20.hxx>
21 #include <OpenGl_Resource.hxx>
23 //! Wrapper for OpenGL shader object.
24 class OpenGl_ShaderObject : public OpenGl_Resource
26 DEFINE_STANDARD_RTTIEXT(OpenGl_ShaderObject, OpenGl_Resource)
27 friend class OpenGl_ShaderProgram;
30 //! Non-valid shader name.
31 static const GLuint NO_SHADER = 0;
35 //! Creates uninitialized shader object.
36 Standard_EXPORT OpenGl_ShaderObject (GLenum theType);
38 //! Releases resources of shader object.
39 Standard_EXPORT virtual ~OpenGl_ShaderObject();
41 //! Loads shader source code.
42 Standard_EXPORT Standard_Boolean LoadSource (const Handle(OpenGl_Context)& theCtx,
43 const TCollection_AsciiString& theSource);
45 //! Compiles the shader object.
46 Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx);
48 //! Fetches information log of the last compile operation.
49 Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
50 TCollection_AsciiString& theLog);
52 //! Creates new empty shader object of specified type.
53 Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
55 //! Destroys shader object.
56 Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
58 //! Returns type of shader object.
59 GLenum Type() const { return myType; }
63 GLenum myType; //!< Type of OpenGL shader object
64 GLuint myShaderID; //!< Handle of OpenGL shader object
68 DEFINE_STANDARD_HANDLE(OpenGl_ShaderObject, OpenGl_Resource)
70 #endif // _OpenGl_ShaderObject_Header