0026122: Visualization, TKOpenGl - clipping and capping is broken when ffp is disable...
[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
30f0ad28 19#include <Graphic3d_ShaderObject.hxx>
20#include <OpenGl_GlCore20.hxx>
21#include <OpenGl_Resource.hxx>
22
c04c30b3 23class OpenGl_ShaderObject;
24DEFINE_STANDARD_HANDLE(OpenGl_ShaderObject, OpenGl_Resource)
25
30f0ad28 26//! Wrapper for OpenGL shader object.
27class OpenGl_ShaderObject : public OpenGl_Resource
28{
29
30public:
31
32 //! Non-valid shader name.
33 static const GLuint NO_SHADER = 0;
34
35public:
36
37 //! Creates uninitialized shader object.
38 Standard_EXPORT OpenGl_ShaderObject (GLenum theType);
39
40 //! Releases resources of shader object.
41 Standard_EXPORT virtual ~OpenGl_ShaderObject();
42
43 //! Loads shader source code.
44 Standard_EXPORT Standard_Boolean LoadSource (const Handle(OpenGl_Context)& theCtx,
45 const TCollection_AsciiString& theSource);
46
47 //! Compiles the shader object.
48 Standard_EXPORT Standard_Boolean Compile (const Handle(OpenGl_Context)& theCtx);
49
50 //! Initializes (loads and compiles) shader object with the specified description.
51 Standard_EXPORT Standard_Boolean Initialize (const Handle(OpenGl_Context)& theCtx,
52 const Handle(Graphic3d_ShaderObject)& theShader);
53
54 //! Fetches information log of the last compile operation.
55 Standard_EXPORT Standard_Boolean FetchInfoLog (const Handle(OpenGl_Context)& theCtx,
56 TCollection_AsciiString& theLog);
57
58 //! Creates new empty shader object of specified type.
59 Standard_EXPORT Standard_Boolean Create (const Handle(OpenGl_Context)& theCtx);
60
61 //! Destroys shader object.
10b9c7df 62 Standard_EXPORT virtual void Release (OpenGl_Context* theCtx);
30f0ad28 63
64 //! Returns type of shader object.
65 GLenum Type() const { return myType; }
66
67protected:
68
69 GLenum myType; //!< Type of OpenGL shader object
70 GLuint myShaderID; //!< Handle of OpenGL shader object
71
72public:
73
ec357c5c 74 DEFINE_STANDARD_RTTI (OpenGl_ShaderObject, OpenGl_Resource)
30f0ad28 75 friend class OpenGl_ShaderProgram;
76
77};
78
79#endif // _OpenGl_ShaderObject_Header