0024739: TKOpenGl - port ray-tracing from OpenCL to GLSL for better integration and...
[occt.git] / src / OpenGl / OpenGl_ShaderObject.hxx
CommitLineData
30f0ad28 1// Created on: 2013-09-19
2// Created by: Denis BOGOLEPOV
d5f74e42 3// Copyright (c) 2013-2014 OPEN CASCADE SAS
30f0ad28 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
30f0ad28 6//
d5f74e42 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
973c2be1 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.
30f0ad28 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
30f0ad28 15
16#ifndef _OpenGl_ShaderObject_Header
17#define _OpenGl_ShaderObject_Header
18
19#include <Handle_OpenGl_ShaderObject.hxx>
20#include <Graphic3d_ShaderObject.hxx>
21#include <OpenGl_GlCore20.hxx>
22#include <OpenGl_Resource.hxx>
23
24//! Wrapper for OpenGL shader object.
25class OpenGl_ShaderObject : public OpenGl_Resource
26{
27
28public:
29
30 //! Non-valid shader name.
31 static const GLuint NO_SHADER = 0;
32
33public:
34
35 //! Creates uninitialized shader object.
36 Standard_EXPORT OpenGl_ShaderObject (GLenum theType);
37
38 //! Releases resources of shader object.
39 Standard_EXPORT virtual ~OpenGl_ShaderObject();
40
41 //! Loads shader source code.
42 Standard_EXPORT Standard_Boolean LoadSource (const Handle(OpenGl_Context)& theCtx,
43 const TCollection_AsciiString& theSource);
44
45 //! Compiles the shader object.
46 Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx);
47
48 //! Initializes (loads and compiles) shader object with the specified description.
49 Standard_EXPORT Standard_Boolean Initialize (const Handle(OpenGl_Context)& theCtx,
50 const Handle(Graphic3d_ShaderObject)& theShader);
51
52 //! Fetches information log of the last compile operation.
53 Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
54 TCollection_AsciiString& theLog);
55
56 //! Creates new empty shader object of specified type.
57 Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
58
59 //! Destroys shader object.
60 Standard_EXPORT virtual void Release (const OpenGl_Context* theCtx);
61
62 //! Returns type of shader object.
63 GLenum Type() const { return myType; }
64
65protected:
66
67 GLenum myType; //!< Type of OpenGL shader object
68 GLuint myShaderID; //!< Handle of OpenGL shader object
69
70public:
71
72 DEFINE_STANDARD_RTTI (OpenGl_ShaderObject)
73 friend class OpenGl_ShaderProgram;
74
75};
76
77#endif // _OpenGl_ShaderObject_Header