mirror of https://github.com/OpenMW/openmw.git
Get the GLExtensions instance when a context is created
parent
e4a9e83609
commit
36a75cdb29
@ -0,0 +1,28 @@
|
|||||||
|
#include "glextensions.hpp"
|
||||||
|
|
||||||
|
namespace SceneUtil
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
osg::observer_ptr<osg::GLExtensions> sGLExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
osg::GLExtensions& getGLExtensions()
|
||||||
|
{
|
||||||
|
if (!sGLExtensions)
|
||||||
|
throw std::runtime_error(
|
||||||
|
"GetGLExtensionsOperation was not used when the current context was created or there is no current "
|
||||||
|
"context");
|
||||||
|
return *sGLExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
GetGLExtensionsOperation::GetGLExtensionsOperation()
|
||||||
|
: GraphicsOperation("GetGLExtensionsOperation", false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetGLExtensionsOperation::operator()(osg::GraphicsContext* graphicsContext)
|
||||||
|
{
|
||||||
|
sGLExtensions = graphicsContext->getState()->get<osg::GLExtensions>();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef OPENMW_COMPONENTS_SCENEUTIL_GLEXTENSIONS_H
|
||||||
|
#define OPENMW_COMPONENTS_SCENEUTIL_GLEXTENSIONS_H
|
||||||
|
|
||||||
|
#include <osg/GLExtensions>
|
||||||
|
#include <osg/GraphicsThread>
|
||||||
|
|
||||||
|
namespace SceneUtil
|
||||||
|
{
|
||||||
|
osg::GLExtensions& getGLExtensions();
|
||||||
|
|
||||||
|
class GetGLExtensionsOperation : public osg::GraphicsOperation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GetGLExtensionsOperation();
|
||||||
|
|
||||||
|
void operator()(osg::GraphicsContext* graphicsContext) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue