Gamedev Framework (gf)  0.6.0
A C++11 framework for 2D games
GraphicsInfo.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2017 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_GRAPHICS_INFO_H
22 #define GF_GRAPHICS_INFO_H
23 
24 #include <string>
25 #include <vector>
26 
27 #include "Portability.h"
28 #include "Vector.h"
29 
30 namespace gf {
31 #ifndef DOXYGEN_SHOULD_SKIP_THIS
32 inline namespace v1 {
33 #endif
34 
35  /**
36  * @ingroup graphics
37  * @brief A class for graphics info
38  *
39  * This class only contains static methods. It provides convenient functions
40  * for OpenGL configuration variables. The name of the variables are given
41  * in the documentation of the functions.
42  *
43  * @sa [glGetString() - docs.gl](://docs.gl/es2/glGetString)
44  * @sa [glGetIntegerv() - docs.gl](http://docs.gl/es2/glGet)
45  */
47  public:
48  /**
49  * @brief Deleted default constructor
50  */
51  GraphicsInfo() = delete;
52 
53  /**
54  * @brief Get OpenGL vendor string
55  *
56  * OpenGL name: `GL_VENDOR`
57  */
58  static std::string getVendor();
59 
60  /**
61  * @brief Get OpenGL renderer string
62  *
63  * OpenGL name: `GL_RENDERER`
64  */
65  static std::string getRenderer();
66 
67  /**
68  * @brief Get OpenGL version string
69  *
70  * OpenGL name: `GL_VERSION`
71  */
72  static std::string getVersion();
73 
74  /**
75  * @brief Get OpenGL GLSL version string
76  *
77  * OpenGL name: `GL_SHADING_LANGUAGE_VERSION`
78  */
79  static std::string getShadingLanguageVersion();
80 
81  /**
82  * @brief Get available OpenGL extensions
83  *
84  * OpenGL name: `GL_EXTENSIONS`
85  */
86  static std::vector<std::string> getExtensions();
87 
88  /**
89  * @brief An OpenGL format
90  */
91  struct Format {
92  int symbol; ///< Symbolic constant to represent the format
93  std::string name; ///< Name of the constant for the format or "UNKNOWN"
94  };
95 
96  /**
97  * @brief Get a list of supported compressed texture formats
98  *
99  * OpenGL name: `GL_NUM_COMPRESSED_TEXTURE_FORMATS` and `GL_COMPRESSED_TEXTURE_FORMATS`
100  */
102 
103  /**
104  * @brief Get a list of supported shader binary formats
105  *
106  * OpenGL name: `GL_NUM_SHADER_BINARY_FORMATS` and `GL_SHADER_BINARY_FORMATS`
107  */
109 
110  /**
111  * @brief Get the maximum supported texture image units
112  *
113  * OpenGL name: `GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS`
114  */
115  static int getMaxCombinedTextureImageUnits();
116 
117  /**
118  * @brief Get a rough estimate of the largest cube-map texture
119  *
120  * OpenGL name: `GL_MAX_CUBE_MAP_TEXTURE_SIZE`
121  */
122  static int getMaxCubeMapTextureSize();
123 
124  /**
125  * @brief Get the maximum number of four-element vectors that can be held
126  * in uniform variable storage for a fragment shader
127  *
128  * OpenGL name: `GL_MAX_FRAGMENT_UNIFORM_VECTORS`
129  */
130  static int getMaxFragmentUniformVectors();
131 
132  /**
133  * @brief Get the largest renderbuffer width and height
134  *
135  * OpenGL name: `GL_MAX_RENDERBUFFER_SIZE`
136  */
137  static int getMaxRenderbufferSize();
138 
139  /**
140  * @brief Get the maximum supported texture image units in a fragment shader
141  *
142  * OpenGL name: `GL_MAX_TEXTURE_IMAGE_UNITS`
143  */
144  static int getMaxTextureImageUnits();
145 
146  /**
147  * @brief Get a rough estimate of the largest texture
148  *
149  * OpenGL name: `GL_MAX_TEXTURE_SIZE`
150  */
151  static int getMaxTextureSize();
152 
153  /**
154  * @brief Get the maximum number four-element vectors available for varying
155  * variables used by vertex and fragment shaders
156  *
157  * OpenGL name: `GL_MAX_VARYING_VECTORS`
158  */
159  static int getMaxVaryingVectors();
160 
161  /**
162  * @brief Get the maximum number of 4-component generic vertex attributes
163  * accessible to a vertex shader
164  *
165  * OpenGL name: `GL_MAX_VERTEX_ATTRIBS`
166  */
167  static int getMaxVertexAttribs();
168 
169  /**
170  * @brief Get the maximum supported texture image units in a vertex shader
171  *
172  * OpenGL name: `GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS`
173  */
174  static int getMaxVertexTextureImageUnits();
175 
176  /**
177  * @brief Get the maximum number of four-element vectors that can be held
178  * in uniform variable storage for a vertex shader
179  *
180  * OpenGL name: `GL_MAX_VERTEX_UNIFORM_VECTORS`
181  */
182  static int getMaxVertexUniformVectors();
183 
184  /**
185  * @brief Get the maximum supported width and height of the viewport
186  *
187  * OpenGL name: `GL_MAX_VIEWPORT_DIMS`
188  */
189  static Vector2i getMaxViewportDims();
190 
191  /**
192  * @brief Get an estimate of the number of bits of subpixel resolution
193  *
194  * OpenGL name: `GL_SUBPIXEL_BITS`
195  */
196  static int getSubpixelBits();
197 
198  };
199 
200 #ifndef DOXYGEN_SHOULD_SKIP_THIS
201 }
202 #endif
203 }
204 
205 #endif // GF_GRAPHICS_INFO_H
static std::vector< Format > getCompressedTextureFormats()
Get a list of supported compressed texture formats.
static int getMaxTextureSize()
Get a rough estimate of the largest texture.
static std::vector< std::string > getExtensions()
Get available OpenGL extensions.
int symbol
Symbolic constant to represent the format.
Definition: GraphicsInfo.h:92
GraphicsInfo()=delete
Deleted default constructor.
static int getMaxVertexTextureImageUnits()
Get the maximum supported texture image units in a vertex shader.
An OpenGL format.
Definition: GraphicsInfo.h:91
static int getMaxVaryingVectors()
Get the maximum number four-element vectors available for varying variables used by vertex and fragme...
static int getMaxVertexAttribs()
Get the maximum number of 4-component generic vertex attributes accessible to a vertex shader...
static std::string getRenderer()
Get OpenGL renderer string.
static int getMaxTextureImageUnits()
Get the maximum supported texture image units in a fragment shader.
static std::string getShadingLanguageVersion()
Get OpenGL GLSL version string.
The namespace for gf classes.
Definition: Action.h:34
static Vector2i getMaxViewportDims()
Get the maximum supported width and height of the viewport.
static int getMaxFragmentUniformVectors()
Get the maximum number of four-element vectors that can be held in uniform variable storage for a fra...
static std::vector< Format > getShaderBinaryFormats()
Get a list of supported shader binary formats.
static std::string getVendor()
Get OpenGL vendor string.
static int getMaxCombinedTextureImageUnits()
Get the maximum supported texture image units.
std::string name
Name of the constant for the format or "UNKNOWN".
Definition: GraphicsInfo.h:93
static int getSubpixelBits()
Get an estimate of the number of bits of subpixel resolution.
static std::string getVersion()
Get OpenGL version string.
#define GF_API
Definition: Portability.h:35
A class for graphics info.
Definition: GraphicsInfo.h:46
static int getMaxVertexUniformVectors()
Get the maximum number of four-element vectors that can be held in uniform variable storage for a ver...
static int getMaxCubeMapTextureSize()
Get a rough estimate of the largest cube-map texture.
static int getMaxRenderbufferSize()
Get the largest renderbuffer width and height.