I need to print out the OpenGL Version of my GPU in an application and then put it in a string.
Asked
Active
Viewed 717 times
-1
-
1I also recommend a library called IMGUI which allows you to create a gui in opengl which makes it easier to log things. https://github.com/ocornut/imgui. – anom1 Aug 14 '21 at 16:12
-
see https://stackoverflow.com/a/35826975/2521214 and https://stackoverflow.com/a/50385807/2521214 – Spektre Aug 17 '21 at 09:08
1 Answers
1
You can use the following code as an example:
std::cout << "" << std::endl;
std::cout << "" << "OpenGL Vendor: " << glGetString(GL_VENDOR) << std::endl;
std::cout << "" << "OpenGL Renderer: " << glGetString(GL_RENDERER) << std::endl;
std::cout << "" << "OpenGL Version: " << glGetString(GL_VERSION) << std::endl;
std::cout << "" << "OpenGL Shading Language Version: " << glGetString(GL_SHADING_LANGUAGE_VERSION) << std::endl;
std::cout << "" << std::endl;
std::string Vendor(reinterpret_cast<const char*>(glGetString(GL_VENDOR)));
std::string Renderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER)));
std::string Version(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
std::string ShadingLanguageVersion(reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION)));
mystring = "\n";
mystring = "OpenGL Vendor: " + Vendor + "\n";
mystring = "OpenGL Renderer : " + Renderer + "\n";
mystring = "OpenGL Version: " + Version + "\n";
mystring = "OpenGL Shading Language Version: " + ShadingLanguageVersion + "\n";
mystring = "\n";
I also recommend this documentation.
-
7Definitely want to mention that you'll need a current GL context for any of that to work. – genpfault Aug 14 '21 at 16:10