OGLplus (0.52.0) a C++ wrapper for OpenGL

string_queries.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_CONTEXT_STRING_QUERIES_1202210920_HPP
14 #define OGLPLUS_CONTEXT_STRING_QUERIES_1202210920_HPP
15 
16 #include <oglplus/glfunc.hpp>
17 #include <oglplus/string_query.hpp>
18 
19 #include <cassert>
20 
21 namespace oglplus {
22 namespace aux {
23 
24 class StrQueryRange
25 {
26 private:
27  GLuint _index, _count;
28  GLenum _param;
29 public:
30  typedef String ValueType;
31 
32  StrQueryRange(GLuint n, GLenum p)
33  : _index(0)
34  , _count(n)
35  , _param(p)
36  { }
37 
38  bool Empty(void) const
39  {
40  assert(_index <= _count);
41  return _index == _count;
42  }
43 
44  std::size_t Size(void) const
45  {
46  return _count;
47  }
48 
49  StrCRef Front(void) const
50  {
51  assert(!Empty());
52  const GLubyte* result = OGLPLUS_GLFUNC(GetStringi)(
53  _param,
54  _index
55  );
56  OGLPLUS_VERIFY_SIMPLE(GetStringi);
57  return StrCRef((const GLchar*)result);
58  }
59 
60  void Next(void)
61  {
62  assert(!Empty());
63  ++_index;
64  }
65 };
66 
67 } // namespace aux
68 
69 namespace context {
70 
72 
76 {
77 public:
79 
85  static const GLubyte* GetString(StringQuery query)
86  {
87  const GLubyte* result = OGLPLUS_GLFUNC(GetString)(GLenum(query));
88  OGLPLUS_VERIFY_SIMPLE(GetString);
89  return result;
90  }
91 
93 
98  static const char* Vendor(void)
99  {
100  return (const char*)GetString(StringQuery::Vendor);
101  }
102 
104 
109  static const char* Version(void)
110  {
111  return (const char*)GetString(StringQuery::Version);
112  }
113 
114 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_3
115 
126  static GLuint NumShadingLanguageVersions(void)
127  {
128  GLint result = 0;
129  OGLPLUS_GLFUNC(GetIntegerv)(
130  GL_NUM_SHADING_LANGUAGE_VERSIONS,
131  &result
132  );
133  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
134  return GLuint(result);
135  }
136 
138 
148  static const GLubyte* ShadingLanguageVersion(GLuint index)
149  {
150  const GLubyte* result = OGLPLUS_GLFUNC(GetStringi)(
151  GL_SHADING_LANGUAGE_VERSION,
152  index
153  );
154  OGLPLUS_VERIFY_SIMPLE(GetStringi);
155  return result;
156  }
157 #endif // GL_VERSION_4_3
158 
159 #if OGLPLUS_DOCUMENTATION_ONLY
160 
168 #elif GL_VERSION_4_3
169  static aux::StrQueryRange ShadingLanguageVersions(void)
170  {
171  return aux::StrQueryRange(
173  GL_SHADING_LANGUAGE_VERSION
174  );
175  }
176 #endif
177 
179 
184  static const char* ShadingLanguageVersion(void)
185  {
186  return (const char*)GetString(StringQuery::ShadingLanguageVersion);
187  }
188 
190 
195  static const char* Renderer(void)
196  {
197  return (const char*)GetString(StringQuery::Renderer);
198  }
199 
201 
210  static GLuint NumExtensions(void)
211  {
212  GLint result = 0;
213  OGLPLUS_GLFUNC(GetIntegerv)(GL_NUM_EXTENSIONS, &result);
214  OGLPLUS_VERIFY_SIMPLE(GetIntegerv);
215  return GLuint(result);
216  }
217 
218 
220 
229  static const GLubyte* Extensions(GLuint index)
230  {
231  const GLubyte* result = OGLPLUS_GLFUNC(GetStringi)(
232  GL_EXTENSIONS,
233  index
234  );
235  OGLPLUS_VERIFY_SIMPLE(GetStringi);
236  return result;
237  }
238 
239 #if OGLPLUS_DOCUMENTATION_ONLY
240 
246  static Range<StrCRef> Extensions(void);
247 #else
248  static aux::StrQueryRange Extensions(void)
249  {
250  return aux::StrQueryRange(
251  NumExtensions(),
252  GL_EXTENSIONS
253  );
254  }
255 #endif
256 };
257 
258 } // namespace context
259 } // namespace oglplus
260 
261 #endif // include guard
OpenGL string query enumeration.
Wrapper for the GL string-query-related operations.
Definition: string_queries.hpp:75
Wrapper class for all ranges that can be used for Element traversal.
Definition: ranges.hpp:39
static GLuint NumExtensions(void)
Queries the number of extension strings.
Definition: string_queries.hpp:210
static const char * ShadingLanguageVersion(void)
Returns the shading language version string.
Definition: string_queries.hpp:184
static const GLubyte * Extensions(GLuint index)
Returns the name of the index -th extension.
Definition: string_queries.hpp:229
::std::basic_string< ALchar > String
static const GLubyte * GetString(StringQuery query)
Queries a string describing GL properties.
Definition: string_queries.hpp:85
static Range< StrCRef > Extensions(void)
Returns a range of extension strings.
String const reference wrapper template.
Definition: ref_tpl.hpp:72
StringQuery
OpenGL string query enumeration.
Definition: string_query.hpp:27
Helper macro for optional checking of availability of GL function.
static const char * Renderer(void)
Returns the renderer name.
Definition: string_queries.hpp:195
static const GLubyte * ShadingLanguageVersion(GLuint index)
Returns the name of index -th supported shading language version.
Definition: string_queries.hpp:148
static GLuint NumShadingLanguageVersions(void)
Queries the number of supported shading language versions.
Definition: string_queries.hpp:126
StrCRefTpl< GLchar > StrCRef
String const reference wrapper.
Definition: ref.hpp:21
static const char * Vendor(void)
Returns the vendor name.
Definition: string_queries.hpp:98
static Range< String > ShadingLanguageVersions(void)
Returns a range of supported GLSL version strings.
static const char * Version(void)
Returns the version string.
Definition: string_queries.hpp:109

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).