From d66907ba6777a858aea95d73c470a3e0d820a16d Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 15 Dec 2021 22:17:38 +0000 Subject: [PATCH] Log OpenGL Vendor, Renderer and Version on startup --- apps/openmw/engine.cpp | 21 ++++++++++++++++++++- components/sceneutil/util.cpp | 16 ++++++++++++++++ components/sceneutil/util.hpp | 12 ++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5c9e915703..1a73ae3531 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -43,6 +43,7 @@ #include #include +#include #include "mwinput/inputmanagerimp.hpp" @@ -239,6 +240,20 @@ namespace { void operator()(std::string) const {} }; + + class IdentifyOpenGLOperation : public osg::GraphicsOperation + { + public: + IdentifyOpenGLOperation() : GraphicsOperation("IdentifyOpenGLOperation", false) + {} + + void operator()(osg::GraphicsContext* graphicsContext) override + { + Log(Debug::Info) << "OpenGL Vendor: " << glGetString(GL_VENDOR); + Log(Debug::Info) << "OpenGL Renderer: " << glGetString(GL_RENDERER); + Log(Debug::Info) << "OpenGL Version: " << glGetString(GL_VERSION); + } + }; } void OMW::Engine::executeLocalScripts() @@ -643,8 +658,12 @@ void OMW::Engine::createWindow(Settings::Manager& settings) camera->setGraphicsContext(graphicsWindow); camera->setViewport(0, 0, graphicsWindow->getTraits()->width, graphicsWindow->getTraits()->height); + osg::ref_ptr realizeOperations = new SceneUtil::OperationSequence(false); + mViewer->setRealizeOperation(realizeOperations); + realizeOperations->add(new IdentifyOpenGLOperation()); + if (Debug::shouldDebugOpenGL()) - mViewer->setRealizeOperation(new Debug::EnableGLDebugOperation()); + realizeOperations->add(new Debug::EnableGLDebugOperation()); mViewer->realize(); diff --git a/components/sceneutil/util.cpp b/components/sceneutil/util.cpp index 7065fae933..33d8f1c8a6 100644 --- a/components/sceneutil/util.cpp +++ b/components/sceneutil/util.cpp @@ -317,4 +317,20 @@ bool attachAlphaToCoverageFriendlyFramebufferToCamera(osg::Camera* camera, osg:: return addMSAAIntermediateTarget; } +OperationSequence::OperationSequence(bool keep) + : Operation("OperationSequence", keep) + , mOperationQueue(new osg::OperationQueue()) +{ +} + +void OperationSequence::operator()(osg::Object* object) +{ + mOperationQueue->runOperations(object); +} + +void OperationSequence::add(osg::Operation* operation) +{ + mOperationQueue->add(operation); +} + } diff --git a/components/sceneutil/util.hpp b/components/sceneutil/util.hpp index ddc2db845d..89d3a12e97 100644 --- a/components/sceneutil/util.hpp +++ b/components/sceneutil/util.hpp @@ -63,6 +63,18 @@ namespace SceneUtil // Alpha-to-coverage requires a multisampled framebuffer, so we need to set that up for RTTs bool attachAlphaToCoverageFriendlyFramebufferToCamera(osg::Camera* camera, osg::Camera::BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face = 0, bool mipMapGeneration = false); + + class OperationSequence : public osg::Operation + { + public: + OperationSequence(bool keep); + + void operator()(osg::Object* object) override; + + void add(osg::Operation* operation); + protected: + osg::ref_ptr mOperationQueue; + }; } #endif