20,741
edits
(→Status) |
(→Issues) |
||
Line 128: | Line 128: | ||
Alternatively, it would be possible to delegate the control flow to Nasal space to handle loading suitable defaults for the detected vendor/renderer. | Alternatively, it would be possible to delegate the control flow to Nasal space to handle loading suitable defaults for the detected vendor/renderer. | ||
{{Flightgear file|GUI/gui.cxx|l=102}} | |||
<syntaxhighlight lang="cpp"> | |||
// Operation for querying OpenGL parameters. This must be done in a | |||
// valid OpenGL context, potentially in another thread. | |||
struct GeneralInitOperation : public GraphicsContextOperation | |||
{ | |||
GeneralInitOperation() | |||
: GraphicsContextOperation(std::string("General init")) | |||
{ | |||
} | |||
void run(osg::GraphicsContext* gc) | |||
{ | |||
SGPropertyNode* simRendering = fgGetNode("/sim/rendering"); | |||
simRendering->setStringValue("gl-vendor", (char*) glGetString(GL_VENDOR)); | |||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VENDOR)); | |||
simRendering->setStringValue("gl-renderer", (char*) glGetString(GL_RENDERER)); | |||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_RENDERER)); | |||
simRendering->setStringValue("gl-version", (char*) glGetString(GL_VERSION)); | |||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VERSION)); | |||
// Old hardware without support for OpenGL 2.0 does not support GLSL and | |||
// glGetString returns NULL for GL_SHADING_LANGUAGE_VERSION. | |||
// | |||
// See http://flightgear.org/forums/viewtopic.php?f=17&t=19670&start=15#p181945 | |||
const char* glsl_version = (const char*) glGetString(GL_SHADING_LANGUAGE_VERSION); | |||
if( !glsl_version ) | |||
glsl_version = "UNSUPPORTED"; | |||
simRendering->setStringValue("gl-shading-language-version", glsl_version); | |||
SG_LOG( SG_GENERAL, SG_INFO, glsl_version); | |||
GLint tmp; | |||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tmp ); | |||
simRendering->setIntValue("max-texture-size", tmp); | |||
glGetIntegerv( GL_DEPTH_BITS, &tmp ); | |||
simRendering->setIntValue("depth-buffer-bits", tmp); | |||
} | |||
}; | |||
</syntaxhighlight> | |||
== Roadmap == | == Roadmap == |