NGL  6.5
The NCCA Graphics Library
Shader.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 Jon Macey
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 #ifndef SHADER_H_
18 #define SHADER_H_
19 
20 #include "Types.h"
21 
22 #include <iostream>
23 #include <cstdlib>
24 namespace ngl
25 {
26 
27 
29 // for c++ 11 use enum class at present internal only
38 //----------------------------------------------------------------------------------------------------------------------
39 
41 {
42 public :
43  //----------------------------------------------------------------------------------------------------------------------
47  //----------------------------------------------------------------------------------------------------------------------
48  Shader( std::string _name, ShaderType _type ) noexcept;
49  //----------------------------------------------------------------------------------------------------------------------
51  //----------------------------------------------------------------------------------------------------------------------
52  ~Shader();
53  //----------------------------------------------------------------------------------------------------------------------
56  //----------------------------------------------------------------------------------------------------------------------
57  void compile() noexcept;
61  //----------------------------------------------------------------------------------------------------------------------
62  void load( std::string _name ) noexcept;
63  //----------------------------------------------------------------------------------------------------------------------
64  void loadFromString(const std::string &_string ) noexcept;
65  //----------------------------------------------------------------------------------------------------------------------
67  //----------------------------------------------------------------------------------------------------------------------
68  void toggleDebug() noexcept {m_debugState ^=true;}
69  //----------------------------------------------------------------------------------------------------------------------
72  //----------------------------------------------------------------------------------------------------------------------
73  GLuint getShaderHandle()const noexcept {return m_shaderHandle;}
74  //----------------------------------------------------------------------------------------------------------------------
77  //----------------------------------------------------------------------------------------------------------------------
78  void incrementRefCount() noexcept { ++m_refCount;}
79  //----------------------------------------------------------------------------------------------------------------------
81  //----------------------------------------------------------------------------------------------------------------------
82  void decrementRefCount() noexcept { --m_refCount;}
83  //----------------------------------------------------------------------------------------------------------------------
86  //----------------------------------------------------------------------------------------------------------------------
87  int getRefCount()const noexcept { return m_refCount; }
88  //----------------------------------------------------------------------------------------------------------------------
91  //----------------------------------------------------------------------------------------------------------------------
92  const std::string getShaderSource() const noexcept {return m_source;}
93 
94 private :
95  //----------------------------------------------------------------------------------------------------------------------
97  //----------------------------------------------------------------------------------------------------------------------
99  //----------------------------------------------------------------------------------------------------------------------
101  //----------------------------------------------------------------------------------------------------------------------
103  //----------------------------------------------------------------------------------------------------------------------
106  //----------------------------------------------------------------------------------------------------------------------
108  //----------------------------------------------------------------------------------------------------------------------
110  //----------------------------------------------------------------------------------------------------------------------
112  //----------------------------------------------------------------------------------------------------------------------
114  //----------------------------------------------------------------------------------------------------------------------
116  //----------------------------------------------------------------------------------------------------------------------
118  //----------------------------------------------------------------------------------------------------------------------
120  //----------------------------------------------------------------------------------------------------------------------
122  //----------------------------------------------------------------------------------------------------------------------
124 };
125 } // end NGL namespace
126 #endif
unsigned int GLuint
Definition: glew.h:280
GLuint getShaderHandle() const noexcept
get the shader handle for this shader
Definition: Shader.h:73
main definition of types and namespace
#define NGL_DLLEXPORT
Definition: Types.h:65
bool m_debugState
flag to indicate the debug state
Definition: Shader.h:119
void incrementRefCount() noexcept
increment the shader ref count so we can see how many program objects are using this shader ...
Definition: Shader.h:78
implementation files for RibExport class
Definition: AABB.cpp:22
void toggleDebug() noexcept
toggle the debug state
Definition: Shader.h:68
std::string m_source
the actual source code for this shader (used for debug and initial loading)
Definition: Shader.h:102
int m_refCount
number of ProgramObjects referencing this shader
Definition: Shader.h:123
const std::string getShaderSource() const noexcept
the shader source
Definition: Shader.h:92
ShaderType
Definition: Shader.h:30
std::string m_name
the text name of this Shader used in the search for shader
Definition: Shader.h:98
GLuint m_shaderHandle
the GL handle for this shader object used in linking etc
Definition: Shader.h:115
and encapsulation of an OpenGL Shader object with associations for source code, etc. Used in conjunction with the ShaderProgram class
Definition: Shader.h:40
void decrementRefCount() noexcept
decrement the reference counteer
Definition: Shader.h:82
int getRefCount() const noexcept
return the number of ProgramObjects referencing this shader
Definition: Shader.h:87
ShaderType m_shaderType
what type of shader we are
Definition: Shader.h:111
bool m_compiled
flag to indicate if the shader has been compiled this will get channged on re-load of source to false...
Definition: Shader.h:107
GLsizei const GLchar *const * string
Definition: glew.h:1847