In .h file:
#include <GL/glew.h>
struct CGLContextInfo
{
struct {
GLint Major, Minor;
std::string Driver;
std::string ShadingLanguage;
} Version;
std::string Vendor;
std::string Renderer;
std::list<std::string> SupportedExtensions;
std::list<std::string> SupportedGLSLVersions;
struct {
bool IsDebugContext;
bool IsForwardCompatibleContext;
bool IsRobustAccessContext;
} Flags;
struct {
bool IsCore;
bool IsCompatiblity;
} Profile;
};
GLContextInfo GetContextInfos();
In .cpp file:
GLContextInfo GetContextInfos()
{
CGLContextInfo infos;
glGetIntegerv(GL_MAJOR_VERSION, &infos.Version.Major);
glGetIntegerv(GL_MINOR_VERSION, &infos.Version.Minor);
infos.Version.Driver = (const char*)glGetString(GL_VERSION);
infos.Vendor = (const char*)glGetString(GL_VENDOR);
infos.Renderer = (const char*)glGetString(GL_RENDERER);
infos.Version.ShadingLanguage = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
GLint numberofextensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numberofextensions);
for (int i = 0; i < numberofextensions; i++)
infos.SupportedExtensions.push_back((const char*)glGetStringi(GL_EXTENSIONS, i));
GLint numberofsupportedglslversions = 0;
glGetIntegerv(GL_NUM_SHADING_LANGUAGE_VERSIONS, &numberofsupportedglslversions);
for (int i = 0; i < numberofsupportedglslversions; i++)
infos.SupportedGLSLVersions.push_back((const char*)glGetStringi(GL_SHADING_LANGUAGE_VERSION, i));
GLint contextflags = 0;
glGetIntegerv(GL_CONTEXT_FLAGS, &contextflags);
infos.Flags.IsDebugContext = contextflags & GL_CONTEXT_FLAG_DEBUG_BIT;
infos.Flags.IsForwardCompatibleContext = contextflags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
infos.Flags.IsRobustAccessContext = contextflags & GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT;
GLint contextprofilemask = 0;
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &contextprofilemask);
infos.Profile.IsCore = contextprofilemask & GL_CONTEXT_CORE_PROFILE_BIT;
infos.Profile.IsCompatiblity = contextprofilemask & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT;
return infos;
}