Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
shader.h
Go to the documentation of this file.
1 
18 #ifndef ION_GFX_SHADER_H_
19 #define ION_GFX_SHADER_H_
20 
21 #include <string>
22 
23 #include "ion/base/referent.h"
24 #include "ion/gfx/resourceholder.h"
25 
26 namespace ion {
27 namespace gfx {
28 
30 class ION_API ShaderBase : public ResourceHolder {
31  public:
33  void SetDocString(const std::string& s) { doc_string_ = s; }
34  const std::string& GetDocString() const { return doc_string_; }
35 
37  void SetInfoLog(const std::string& info_log) const {
38  info_log_ = info_log;
39  }
40  const std::string GetInfoLog() const { return info_log_; }
41 
42  protected:
44  ShaderBase();
45 
48  ~ShaderBase() override;
49 
50  private:
51  std::string doc_string_;
52 
54  mutable std::string info_log_;
55 };
56 
59 class ION_API Shader : public ShaderBase {
60  public:
62  enum Changes {
63  kSourceChanged = kNumBaseChanges,
64  kNumChanges
65  };
66 
67  Shader();
68  explicit Shader(const std::string& source);
69 
71  void SetSource(const std::string& source) {
72  source_.Set(source);
73  }
74  const std::string& GetSource() const {
75  return source_.Get();
76  }
77 
78  private:
81  ~Shader() override;
82 
83  Field<std::string> source_;
84 };
85 
88 
89 } // namespace gfx
90 } // namespace ion
91 
92 #endif // ION_GFX_SHADER_H_
const std::string GetInfoLog() const
Definition: shader.h:40
const std::string & GetDocString() const
Definition: shader.h:34
void SetSource(const std::string &source)
Sets/returns the source of the shader.
Definition: shader.h:71
base::ReferentPtr< Shader >::Type ShaderPtr
Convenience typedef for shared pointers to Shaders.
Changes
Changes that affect the resource.
Definition: shader.h:62
const std::string & GetSource() const
Definition: shader.h:74
A Shader represents an OpenGL shader stage.
Definition: shader.h:59
Base class for Shader and ShaderProgram objects.
Definition: shader.h:30
void SetDocString(const std::string &s)
Sets/returns a string documenting the shader program for help.
Definition: shader.h:33
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...
Definition: sharedptr.h:60
ResourceHolder is an internal base class for objects that hold resources managed by an outside entity...
void SetInfoLog(const std::string &info_log) const
Sets/returns the latest info log.
Definition: shader.h:37