OGLplus (0.52.0) a C++ wrapper for OpenGL

program_resource.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_PROGRAM_RESOURCE_1208301144_HPP
14 #define OGLPLUS_PROGRAM_RESOURCE_1208301144_HPP
15 
16 #include <oglplus/error/object.hpp>
17 #include <oglplus/data_type.hpp>
18 #include <oglplus/shader_type.hpp>
20 #include <oglplus/detail/program.hpp>
21 
22 namespace oglplus {
23 
24 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3
25 
47 {
48 private:
49  GLint _program;
50  GLenum _interface;
51  GLuint _index;
52  String _name;
53 
54  void QueryParams(
55  GLenum property,
56  GLsizei bufsize,
57  GLsizei* written,
58  GLint* params
59  ) const
60  {
61  OGLPLUS_GLFUNC(GetProgramResourceiv)(
62  _program,
63  _interface,
64  _index,
65  1, &property,
66  bufsize,
67  written,
68  params
69  );
70  }
71 
72  GLint GetParam(GLenum property) const
73  {
74  GLint res;
75  QueryParams(property, 1, nullptr, &res);
76  OGLPLUS_VERIFY(
77  GetProgramResourceiv,
78  Error,
79  EnumParam(property)
80  );
81  return res;
82  }
83 
84  bool HasProp(GLenum property) const
85  {
86  GLint res;
87  QueryParams(GLenum(property), 1, nullptr, &res);
88  return OGLPLUS_GLFUNC(GetError)() == GL_NO_ERROR;
89  }
90 public:
92  aux::ProgramInterfaceContext& context,
93  GLuint index
94  );
95 
97 
101  GLint GetIntParam(ProgramResourceProperty property) const
102  {
103  return GetParam(GLenum(property));
104  }
105 
107 
112  {
113  return GetParam(GLenum(property)) == GL_TRUE;
114  }
115 
117 
121  bool Has(ProgramResourceProperty property) const
122  {
123  return HasProp(GLenum(property));
124  }
125 
128  {
129  return ProgramInterface(_interface);
130  }
131 
133 
137  const String& Name(void) const
138  {
139  return _name;
140  }
141 
143  GLuint Index(void) const
144  {
145  return _index;
146  }
147 
149  bool HasType(void) const
150  {
151  return HasProp(GL_TYPE);
152  }
153 
155 
160  SLDataType Type(void) const
161  {
162  return SLDataType(GetParam(GL_TYPE));
163  }
164 
166 
171  GLint Location(void) const
172  {
173  return GetParam(GL_LOCATION);
174  }
175 
177 
182  GLint LocationIndex(void) const
183  {
184  return GetParam(GL_LOCATION_INDEX);
185  }
186 
188 
193  GLint ArraySize(void) const
194  {
195  return GetParam(GL_ARRAY_SIZE);
196  }
197 
198  GLenum ReferencedByProperty(ShaderType type) const;
199 
201 
211  bool ReferencedBy(ShaderType shader_type) const
212  {
213  return GetParam(ReferencedByProperty(shader_type)) == GL_TRUE;
214  }
215 
217 
222  bool IsPerPatch(void) const
223  {
224  return GetParam(GL_IS_PER_PATCH) == GL_TRUE;
225  }
226 
227  // TODO: finish this
228 };
229 
230 #endif // GL_VERSION_4_3
231 
232 } // namespace oglplus
233 
234 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
235 #include <oglplus/program_resource.ipp>
236 #endif // OGLPLUS_LINK_LIBRARY
237 
238 #endif // include guard
ShaderType
The type of a Shader.
Definition: shader_type.hpp:26
Information about a single active program resource.
Definition: program_resource.hpp:46
ProgramInterface Interface(void) const
Returns the interface of the resource.
Definition: program_resource.hpp:127
bool HasType(void) const
Returns true if the resource has a type.
Definition: program_resource.hpp:149
Shader type enumeration.
bool IsPerPatch(void) const
Returns true if the resource is per-patch (if applicable)
Definition: program_resource.hpp:222
SLDataType Type(void) const
Returns the data type of the resource (if applicable)
Definition: program_resource.hpp:160
GLint GetIntParam(ProgramResourceProperty property) const
Gets the value of a single property (as an GLint)
Definition: program_resource.hpp:101
Declaration of OGLplus object-related error.
bool GetBoolParam(ProgramResourceProperty property) const
Gets the value of a single property (as a boolean value)
Definition: program_resource.hpp:111
bool ReferencedBy(ShaderType shader_type) const
Returns true if the resource is_referenced by shader (if applicable)
Definition: program_resource.hpp:211
GLint LocationIndex(void) const
Returns the program resource location index (if applicable)
Definition: program_resource.hpp:182
GLint ArraySize(void) const
Returns the array size of the resource (if applicable)
Definition: program_resource.hpp:193
ProgramInterface
Program interface enumeration.
Definition: program_interface.hpp:33
GLuint Index(void) const
Returns the index of the resource.
Definition: program_resource.hpp:143
OpenGL program interface enumeration.
Data type-related declarations.
const String & Name(void) const
Returns the name of the resource.
Definition: program_resource.hpp:137
::std::basic_string< GLchar > String
String class.
Definition: def.hpp:36
Exception class for general OpenGL errors.
Definition: basic.hpp:43
GLint Location(void) const
Returns the program resource location (if applicable)
Definition: program_resource.hpp:171
SLDataType
OpenGL Shading Language data type enumeration.
Definition: data_type.hpp:123
bool Has(ProgramResourceProperty property) const
Checks if this resource has the specified property.
Definition: program_resource.hpp:121
ProgramResourceProperty
Program resource property enumeration.
Definition: program_interface.hpp:55

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).