optimise property usage for camera using local static for ratio.
This commit is contained in:
parent
832654fd2b
commit
cbde4c90da
2 changed files with 9 additions and 8 deletions
|
@ -90,6 +90,8 @@ protected:
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
double PUICamera::pixelRatio;
|
||||||
|
|
||||||
class PUIDrawable : public osg::Drawable
|
class PUIDrawable : public osg::Drawable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -285,9 +287,8 @@ void PUICamera::puGetWindowSize(int* width, int* height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
osg::Viewport* vport = camera->getViewport();
|
osg::Viewport* vport = camera->getViewport();
|
||||||
const double ratio = fgGetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
*width = static_cast<int>(vport->width() / pixelRatio);
|
||||||
*width = static_cast<int>(vport->width() / ratio);
|
*height = static_cast<int>(vport->height() / pixelRatio);
|
||||||
*height = static_cast<int>(vport->height() / ratio);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PUICamera::initPUI()
|
void PUICamera::initPUI()
|
||||||
|
@ -296,10 +297,10 @@ void PUICamera::initPUI()
|
||||||
PUICamera::puGetWindowSize, nullptr);
|
PUICamera::puGetWindowSize, nullptr);
|
||||||
puRealInit();
|
puRealInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
PUICamera::PUICamera() :
|
PUICamera::PUICamera() :
|
||||||
osg::Camera()
|
osg::Camera()
|
||||||
{
|
{
|
||||||
|
pixelRatio = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PUICamera::init(osg::Group* parent)
|
void PUICamera::init(osg::Group* parent)
|
||||||
|
@ -388,9 +389,9 @@ void PUICamera::manuallyResizeFBO(int width, int height)
|
||||||
|
|
||||||
void PUICamera::resizeUi(int width, int height)
|
void PUICamera::resizeUi(int width, int height)
|
||||||
{
|
{
|
||||||
double ratio = fgGetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
pixelRatio = fgGetDouble("/sim/rendering/gui-pixel-ratio", 1.0);
|
||||||
const int scaledWidth = static_cast<int>(width / ratio);
|
const int scaledWidth = static_cast<int>(width / pixelRatio);
|
||||||
const int scaledHeight = static_cast<int>(height / ratio);
|
const int scaledHeight = static_cast<int>(height / pixelRatio);
|
||||||
|
|
||||||
setViewport(0, 0, scaledWidth, scaledHeight);
|
setViewport(0, 0, scaledWidth, scaledHeight);
|
||||||
#if OSG_VERSION_LESS_THAN(3,4,0)
|
#if OSG_VERSION_LESS_THAN(3,4,0)
|
||||||
|
|
|
@ -47,7 +47,7 @@ private:
|
||||||
class UpdateViewportAndFBOAfterTextureResizeCallback;
|
class UpdateViewportAndFBOAfterTextureResizeCallback;
|
||||||
UpdateViewportAndFBOAfterTextureResizeCallback* _resizeCullCallback = nullptr;
|
UpdateViewportAndFBOAfterTextureResizeCallback* _resizeCullCallback = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
static double pixelRatio;
|
||||||
void manuallyResizeFBO(int width, int height);
|
void manuallyResizeFBO(int width, int height);
|
||||||
|
|
||||||
osg::Texture2D* _fboTexture = nullptr;
|
osg::Texture2D* _fboTexture = nullptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue