X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fod_gauge.cxx;h=6760bcd2244e17562d3aea218f89c3afda3a32ed;hb=caf0138ab35b03bbe7bf367ff2222d0a31be3157;hp=820f0a9d8744d2de031d82a7484731634f41d9e7;hpb=1df8130bddbbc3bc590c37c31f5256470f839cfb;p=flightgear.git diff --git a/src/Instrumentation/od_gauge.cxx b/src/Instrumentation/od_gauge.cxx index 820f0a9d8..6760bcd22 100644 --- a/src/Instrumentation/od_gauge.cxx +++ b/src/Instrumentation/od_gauge.cxx @@ -26,6 +26,7 @@ # include "config.h" #endif +#include #include #include #include @@ -38,26 +39,24 @@ #include #include -#include #include #include
-#include
+#include #include #include "od_gauge.hxx" FGODGauge::FGODGauge() : - rtAvailable( false )// , -// rt( 0 ) + rtAvailable( false ) { } -void FGODGauge::allocRT () { +void FGODGauge::allocRT () +{ camera = new osg::Camera; // Only the far camera should trigger this texture to be rendered. camera->setNodeMask(simgear::BACKGROUND_BIT); - camera->setProjectionMatrix(osg::Matrix::ortho2D(-256.0, 256.0, -256.0, - 256.0)); + camera->setProjectionMatrix(osg::Matrix::ortho2D(-textureWH/2.0, textureWH/2.0, -textureWH/2.0, textureWH/2.0)); camera->setViewport(0, 0, textureWH, textureWH); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setRenderOrder(osg::Camera::PRE_RENDER); @@ -89,65 +88,25 @@ void FGODGauge::allocRT () { camera->attach(osg::Camera::COLOR_BUFFER, texture.get()); globals->get_renderer()->addCamera(camera.get(), false); rtAvailable = true; - - // GLint colorBits = 0; -// glGetIntegerv( GL_BLUE_BITS, &colorBits ); -// rt = new RenderTexture(); -// if( colorBits < 8 ) -// rt->Reset("rgba=5,5,5,1 ctt"); -// else -// rt->Reset("rgba ctt"); - -// if( rt->Initialize(256, 256, true) ) { -// SG_LOG(SG_ALL, SG_INFO, "FGODGauge:Initialize sucessfull"); -// if (rt->BeginCapture()) -// { -// SG_LOG(SG_ALL, SG_INFO, "FGODGauge:BeginCapture sucessfull, RTT available"); -// rtAvailable = true; -// glViewport(0, 0, textureWH, textureWH); -// glMatrixMode(GL_PROJECTION); -// glLoadIdentity(); -// gluOrtho2D( -256.0, 256.0, -256.0, 256.0 ); -// glMatrixMode(GL_MODELVIEW); -// glLoadIdentity(); -// glDisable(GL_LIGHTING); -// glEnable(GL_COLOR_MATERIAL); -// glDisable(GL_CULL_FACE); -// glDisable(GL_FOG); -// glDisable(GL_DEPTH_TEST); -// glClearColor(0.0, 0.0, 0.0, 0.0); -// glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); -// glBindTexture(GL_TEXTURE_2D, 0); -// glEnable(GL_TEXTURE_2D); -// glEnable(GL_ALPHA_TEST); -// glAlphaFunc(GL_GREATER, 0.0f); -// glDisable(GL_SMOOTH); -// glEnable(GL_BLEND); -// glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA ); -// rt->EndCapture(); -// } else -// SG_LOG(SG_ALL, SG_WARN, "FGODGauge:BeginCapture failed, RTT not available, using backbuffer"); -// } else -// SG_LOG(SG_ALL, SG_WARN, "FGODGauge:Initialize failed, RTT not available, using backbuffer"); -} - -FGODGauge::~FGODGauge() { -// delete rt; -} - -void FGODGauge::init () { } -void FGODGauge::update (double dt) { +FGODGauge::~FGODGauge() +{ + if (camera.valid()) { + globals->get_renderer()->removeCamera(camera.get()); + } } - -void FGODGauge::setSize(int viewSize) { +void FGODGauge::setSize(int viewSize) +{ textureWH = viewSize; -// glViewport(0, 0, textureWH, textureWH); + if (texture.valid()) { + texture->setTextureSize(textureWH, textureWH); + } } -bool FGODGauge::serviceable(void) { +bool FGODGauge::serviceable(void) +{ return rtAvailable; }