Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
glfShader.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __glfShader_hh__
26 #define __glfShader_hh__
27 
28 #include "glfCommon.hh"
29 #include <string>
30 
31 namespace BIAS {
32 
33  /**
34  * \brief A GLSL vertex shader or fragment shader, which must be linked
35  * in a shader program.
36  * \ingroup g_openglframework
37  * \author jkollmann
38  */
39  class BIASOpenGLFramework_EXPORT glfShader {
40  public:
41  glfShader();
42  ~glfShader();
43 
44  /**
45  * Creates the shader without the GLSL source code, use other
46  * Create() methods to upload source afterwards.
47  * \param type e.g. GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
48  * \param sourceCode The GLSL source.
49  */
50  void Create(GLenum type);
51 
52  /**
53  * Creates the shader from the given GLSL source code.
54  * \param type e.g. GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
55  * \param sourceCode The GLSL source.
56  */
57  void Create(GLenum type, const std::string& sourceCode);
58 
59  /**
60  * Creates the shader from GLSL source code loaded from a file.
61  * \param type Either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER.
62  * \param fileName Name of file to load the GLSL source from.
63  */
64  void CreateFromFile(GLenum type, const std::string& fileName);
65 
66 
67  /**
68  * Returns the info log containing information about the compilation
69  * of the shader.
70  * \note If compiling the shader fails, the info log is also contained in
71  * the message of the thrown exception.
72  */
73  std::string GetInfoLog() const;
74 
75  /**
76  * Returns the OpenGL id of the shader.
77  */
78  GLuint GetShaderID() const;
79 
80  /**
81  * Returns the OpenGL id of the shader.
82  */
83  inline GLenum GetType() {return type_;};
84 
85  private:
86  GLuint id_;
87  GLenum type_;
88 
89  /** An intuitive assignment operator should generate a copy, as long as nobody is willing to implement
90  * the generation of a copy in gl controlled memory this operator cannot be used.
91  */
92  glfShader& operator=(const glfShader& b);
93 
94  /** An intuitive copy constructor should generate a copy, as long as nobody is willing to implement
95  * the generation of a copy in gl controlled memory this constructor cannot be used.
96  */
97  glfShader(const glfShader& b);
98  };
99 }
100 
101 #endif // __glfShader_hh__
A GLSL vertex shader or fragment shader, which must be linked in a shader program.
Definition: glfShader.hh:39
GLenum GetType()
Returns the OpenGL id of the shader.
Definition: glfShader.hh:83