1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <GLFW/glfw3.h>
#include <glbinding/AbstractFunction.h>
#include <glbinding/Version.h>
#include <glbinding/glbinding.h>
#include <glbinding/Binding.h>
#include <glbinding/gl/gl.h>
#include <glbinding-aux/Meta.h>
#include <glbinding-aux/ContextInfo.h>
#include <glbinding-aux/ValidVersions.h>
#include <glbinding-aux/types_to_string.h>
using namespace gl;
using namespace glbinding;
void error(int errnum, const char * errmsg)
{
std::cerr << errnum << ": " << errmsg << std::endl;
}
inline void coutFunc(const AbstractFunction * func)
{
std::cout << "\t(0x" << reinterpret_cast<void *>(func->address()) << ") " << func->name() << std::endl;
}
int main()
{
glfwSetErrorCallback(error);
if (!glfwInit())
return 1;
glfwDefaultWindowHints();
glfwWindowHint(GLFW_VISIBLE, false);
#ifdef SYSTEM_DARWIN
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif
auto window = glfwCreateWindow(320, 240, "", nullptr, nullptr);
if (!window)
{
glfwTerminate();
return -1;
}
glfwHideWindow(window);
glfwMakeContextCurrent(window);
glbinding::initialize(glfwGetProcAddress, true);
// gather available extensions
auto resolved = 0u;
auto assigned = 0u;
std::set<std::string> unknownExts;
const auto supportedExts = aux::ContextInfo::extensions(unknownExts);
const auto allExts = aux::Meta::extensions();
// sort extensions by version
auto extsByVer = std::map<Version, std::set<GLextension>>();
auto suppByVer = std::map<Version, int>(); // num supported exts by version
auto versions = aux::Meta::versions();
versions.insert(Version{}); // provide NONE Version for extensions without associated version
for (auto & version : versions)
{
const auto extensions = aux::Meta::extensions(version);
if (extensions.empty())
continue;
extsByVer[version] = extensions;
suppByVer[version] = 0;
}
// iterate over all extensions by version and show functions
auto funcsByExt = std::map<GLextension, std::set<const AbstractFunction *>>();
auto nonExtFuncs = std::set<const AbstractFunction *>();
for (auto * function : Binding::functions())
{
if (function->isResolved())
++resolved;
if (aux::Meta::extensions(function->name()).empty())
{
nonExtFuncs.insert(function);
}
else
{
const auto extensions = aux::Meta::extensions(function->name());
for (const auto & extension : extensions)
funcsByExt[extension].insert(function);
++assigned;
}
}
// print all extensions with support info and functions
for (auto i : extsByVer)
{
std::cout << std::endl << std::endl << "[" << i.first << " EXTENSIONS]" << std::endl;
for (auto & ext : i.second)
{
const auto supported = supportedExts.find(ext) != supportedExts.cend();
if (supported)
++suppByVer[i.first];
std::cout << std::endl << aux::Meta::getString(ext) << (supported ? " (supported)" : "") << std::endl;
if (funcsByExt.find(ext) != funcsByExt.cend())
for (auto func : funcsByExt[ext])
coutFunc(func);
}
}
// show unknown extensions
std::cout << std::endl << std::endl << "[EXTENSIONS NOT COVERED BY GLBINDING]" << std::endl << std::endl;
for (const auto & ext : unknownExts)
std::cout << ext << std::endl;
// show non ext functions
std::cout << std::endl << std::endl << "[NON-EXTENSION OR NOT-COVERED-EXTENSION FUNCTIONS]" << std::endl << std::endl;
for (const AbstractFunction * func : nonExtFuncs)
coutFunc(func);
// print summary
std::cout << std::endl << std::endl << "[SUMMARY]" << std::endl << std::endl;
std::cout << "# Functions: " << resolved << " of " << Binding::size() << " resolved"
<< " (" << (Binding::size() - resolved) << " unresolved)" << std::endl;
std::cout << " " << assigned << " assigned to extensions";
std::cout << "." << std::endl;
std::cout << std::endl;
std::cout << "# Extensions: " << (supportedExts.size() + unknownExts.size()) << " of " << allExts.size() + unknownExts.size() << " supported"
<< " (" << unknownExts.size() << " of which are unknown to glbinding)" << std::endl;
for (auto p : extsByVer)
{
const auto & numSupported = suppByVer[p.first];
std::cout << " # " << p.first << " assoc.: " << numSupported << " / " << p.second.size() << std::endl;
}
std::cout << std::endl;
std::cout << "# Missing Feature Extensions and Functions: " << std::endl;
auto unsupportedExtensions = std::set<GLextension>{};
auto unsupportedFunctions = std::set<AbstractFunction *>{};
for (auto p : extsByVer)
{
if (p.first.isNull())
continue;
unsupportedExtensions.clear();
unsupportedFunctions.clear();
const auto supported = aux::ContextInfo::supported(p.first, unsupportedExtensions, unsupportedFunctions);
if (supported)
continue;
if (!unsupportedExtensions.empty())
{
std::cout << " # " << p.first << " assoc. Extensions:" << std::endl;
for (const auto extension : unsupportedExtensions)
std::cout << " " << aux::Meta::getString(extension) << std::endl;
}
if(!unsupportedFunctions.empty())
{
std::cout << " # " << p.first << " assoc. Functions:" << std::endl;
for (const auto function : unsupportedFunctions)
std::cout << " " << function->name() << std::endl;
}
}
// print some gl infos (query)
std::cout << std::endl
<< "OpenGL Version: " << aux::ContextInfo::version() << std::endl
<< "OpenGL Vendor: " << aux::ContextInfo::vendor() << std::endl
<< "OpenGL Renderer: " << aux::ContextInfo::renderer() << std::endl
<< "OpenGL Revision: " << aux::Meta::glRevision() << " (gl.xml)" << std::endl << std::endl;
glfwTerminate();
return 0;
}
|