我需要在一个应用程序中打印出我的GPU的OpenGL版本,然后把它放在一个字符串中。
您可以使用以下代码作为示例:
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";
我也推荐这个文档。