1
0
Fork 0

VSCode applied formatting.

This commit is contained in:
James Turner 2022-05-16 12:15:05 +01:00
parent 15cb5ab075
commit 3f670c84b1

View file

@ -19,50 +19,50 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifdef __linux__ #ifdef __linux__
#include <sched.h> #include <sched.h>
#endif #endif
#include <config.h> #include <config.h>
#include <algorithm> #include <algorithm>
#include <cstdlib>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <string> #include <string>
#include <cstdlib>
#include <simgear/compiler.h> #include <simgear/compiler.h>
#include <simgear/structure/exception.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/debug/OsgIoCapture.hxx> #include <simgear/debug/OsgIoCapture.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/props/props_io.hxx> #include <simgear/props/props_io.hxx>
#include <simgear/structure/exception.hxx>
#include <osg/Camera> #include <osg/Camera>
#include <osg/GraphicsContext> #include <osg/GraphicsContext>
#include <osg/Group> #include <osg/Group>
#include <osg/Matrixd> #include <osg/Matrixd>
#include <osg/Viewport>
#include <osg/Version>
#include <osg/Notify> #include <osg/Notify>
#include <osg/Version>
#include <osg/View> #include <osg/View>
#include <osgViewer/ViewerEventHandlers> #include <osg/Viewport>
#include <osgViewer/Viewer>
#include <osgViewer/GraphicsWindow> #include <osgViewer/GraphicsWindow>
#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <Scenery/scenery.hxx>
#include <Main/fg_os.hxx>
#include <Main/fg_props.hxx>
#include <Main/util.hxx>
#include <Main/globals.hxx>
#include "renderer.hxx"
#include "CameraGroup.hxx" #include "CameraGroup.hxx"
#include "FGEventHandler.hxx" #include "FGEventHandler.hxx"
#include "VRManager.hxx" #include "VRManager.hxx"
#include "WindowBuilder.hxx" #include "WindowBuilder.hxx"
#include "WindowSystemAdapter.hxx" #include "WindowSystemAdapter.hxx"
#include "renderer.hxx"
#include <Main/fg_os.hxx>
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/sentryIntegration.hxx> #include <Main/sentryIntegration.hxx>
#include <Main/util.hxx>
#include <Scenery/scenery.hxx>
#if defined(SG_MAC) #if defined(SG_MAC)
# include <GUI/CocoaHelpers.h> #include <GUI/CocoaHelpers.h>
#endif #endif
#if defined(SG_WINDOWS) #if defined(SG_WINDOWS)
@ -82,13 +82,13 @@ USE_OSGPLUGIN(pnm);
USE_OSGPLUGIN(rgb); USE_OSGPLUGIN(rgb);
USE_OSGPLUGIN(tga); USE_OSGPLUGIN(tga);
#ifdef OSG_JPEG_ENABLED #ifdef OSG_JPEG_ENABLED
USE_OSGPLUGIN(jpeg); USE_OSGPLUGIN(jpeg);
#endif #endif
#ifdef OSG_PNG_ENABLED #ifdef OSG_PNG_ENABLED
USE_OSGPLUGIN(png); USE_OSGPLUGIN(png);
#endif #endif
#ifdef OSG_TIFF_ENABLED #ifdef OSG_TIFF_ENABLED
USE_OSGPLUGIN(tiff); USE_OSGPLUGIN(tiff);
#endif #endif
// Model formats // Model formats
USE_OSGPLUGIN(3ds); USE_OSGPLUGIN(3ds);
@ -111,75 +111,58 @@ using namespace osg;
osg::ref_ptr<osgViewer::Viewer> viewer; osg::ref_ptr<osgViewer::Viewer> viewer;
static void setStereoMode( const char * mode ) static void setStereoMode(const char* mode)
{ {
DisplaySettings::StereoMode stereoMode = DisplaySettings::QUAD_BUFFER; DisplaySettings::StereoMode stereoMode = DisplaySettings::QUAD_BUFFER;
bool stereoOn = true; bool stereoOn = true;
if (strcmp(mode,"QUAD_BUFFER")==0) if (strcmp(mode, "QUAD_BUFFER") == 0) {
{
stereoMode = DisplaySettings::QUAD_BUFFER; stereoMode = DisplaySettings::QUAD_BUFFER;
} } else if (strcmp(mode, "ANAGLYPHIC") == 0) {
else if (strcmp(mode,"ANAGLYPHIC")==0)
{
stereoMode = DisplaySettings::ANAGLYPHIC; stereoMode = DisplaySettings::ANAGLYPHIC;
} } else if (strcmp(mode, "HORIZONTAL_SPLIT") == 0) {
else if (strcmp(mode,"HORIZONTAL_SPLIT")==0)
{
stereoMode = DisplaySettings::HORIZONTAL_SPLIT; stereoMode = DisplaySettings::HORIZONTAL_SPLIT;
} } else if (strcmp(mode, "VERTICAL_SPLIT") == 0) {
else if (strcmp(mode,"VERTICAL_SPLIT")==0)
{
stereoMode = DisplaySettings::VERTICAL_SPLIT; stereoMode = DisplaySettings::VERTICAL_SPLIT;
} } else if (strcmp(mode, "LEFT_EYE") == 0) {
else if (strcmp(mode,"LEFT_EYE")==0)
{
stereoMode = DisplaySettings::LEFT_EYE; stereoMode = DisplaySettings::LEFT_EYE;
} } else if (strcmp(mode, "RIGHT_EYE") == 0) {
else if (strcmp(mode,"RIGHT_EYE")==0)
{
stereoMode = DisplaySettings::RIGHT_EYE; stereoMode = DisplaySettings::RIGHT_EYE;
} } else if (strcmp(mode, "HORIZONTAL_INTERLACE") == 0) {
else if (strcmp(mode,"HORIZONTAL_INTERLACE")==0)
{
stereoMode = DisplaySettings::HORIZONTAL_INTERLACE; stereoMode = DisplaySettings::HORIZONTAL_INTERLACE;
} } else if (strcmp(mode, "VERTICAL_INTERLACE") == 0) {
else if (strcmp(mode,"VERTICAL_INTERLACE")==0)
{
stereoMode = DisplaySettings::VERTICAL_INTERLACE; stereoMode = DisplaySettings::VERTICAL_INTERLACE;
} } else if (strcmp(mode, "CHECKERBOARD") == 0) {
else if (strcmp(mode,"CHECKERBOARD")==0)
{
stereoMode = DisplaySettings::CHECKERBOARD; stereoMode = DisplaySettings::CHECKERBOARD;
} else { } else {
stereoOn = false; stereoOn = false;
} }
DisplaySettings::instance()->setStereo( stereoOn ); DisplaySettings::instance()->setStereo(stereoOn);
DisplaySettings::instance()->setStereoMode( stereoMode ); DisplaySettings::instance()->setStereoMode(stereoMode);
} }
static const char * getStereoMode() static const char* getStereoMode()
{ {
DisplaySettings::StereoMode stereoMode = DisplaySettings::instance()->getStereoMode(); DisplaySettings::StereoMode stereoMode = DisplaySettings::instance()->getStereoMode();
bool stereoOn = DisplaySettings::instance()->getStereo(); bool stereoOn = DisplaySettings::instance()->getStereo();
if( !stereoOn ) return "OFF"; if (!stereoOn) return "OFF";
if( stereoMode == DisplaySettings::QUAD_BUFFER ) { if (stereoMode == DisplaySettings::QUAD_BUFFER) {
return "QUAD_BUFFER"; return "QUAD_BUFFER";
} else if( stereoMode == DisplaySettings::ANAGLYPHIC ) { } else if (stereoMode == DisplaySettings::ANAGLYPHIC) {
return "ANAGLYPHIC"; return "ANAGLYPHIC";
} else if( stereoMode == DisplaySettings::HORIZONTAL_SPLIT ) { } else if (stereoMode == DisplaySettings::HORIZONTAL_SPLIT) {
return "HORIZONTAL_SPLIT"; return "HORIZONTAL_SPLIT";
} else if( stereoMode == DisplaySettings::VERTICAL_SPLIT ) { } else if (stereoMode == DisplaySettings::VERTICAL_SPLIT) {
return "VERTICAL_SPLIT"; return "VERTICAL_SPLIT";
} else if( stereoMode == DisplaySettings::LEFT_EYE ) { } else if (stereoMode == DisplaySettings::LEFT_EYE) {
return "LEFT_EYE"; return "LEFT_EYE";
} else if( stereoMode == DisplaySettings::RIGHT_EYE ) { } else if (stereoMode == DisplaySettings::RIGHT_EYE) {
return "RIGHT_EYE"; return "RIGHT_EYE";
} else if( stereoMode == DisplaySettings::HORIZONTAL_INTERLACE ) { } else if (stereoMode == DisplaySettings::HORIZONTAL_INTERLACE) {
return "HORIZONTAL_INTERLACE"; return "HORIZONTAL_INTERLACE";
} else if( stereoMode == DisplaySettings::VERTICAL_INTERLACE ) { } else if (stereoMode == DisplaySettings::VERTICAL_INTERLACE) {
return "VERTICAL_INTERLACE"; return "VERTICAL_INTERLACE";
} else if( stereoMode == DisplaySettings::CHECKERBOARD ) { } else if (stereoMode == DisplaySettings::CHECKERBOARD) {
return "CHECKERBOARD"; return "CHECKERBOARD";
} }
return "OFF"; return "OFF";
@ -211,17 +194,16 @@ public:
void updateOSGNotifyLevel() void updateOSGNotifyLevel()
{ {
} }
void fgOSOpenWindow(bool stencil) void fgOSOpenWindow(bool stencil)
{ {
osg::setNotifyHandler(new NotifyLogger); osg::setNotifyHandler(new NotifyLogger);
auto composite_viewer = dynamic_cast<osgViewer::CompositeViewer*>( auto composite_viewer = dynamic_cast<osgViewer::CompositeViewer*>(
globals->get_renderer()->getViewerBase() globals->get_renderer()->getViewerBase());
); if (0) {
if (0) {} } else if (composite_viewer) {
else if (composite_viewer) {
/* We are using CompositeViewer. */ /* We are using CompositeViewer. */
SG_LOG(SG_VIEW, SG_DEBUG, "Using CompositeViewer"); SG_LOG(SG_VIEW, SG_DEBUG, "Using CompositeViewer");
osgViewer::ViewerBase* viewer = globals->get_renderer()->getViewerBase(); osgViewer::ViewerBase* viewer = globals->get_renderer()->getViewerBase();
@ -240,7 +222,7 @@ void fgOSOpenWindow(bool stencil)
std::string mode; std::string mode;
mode = fgGetString("/sim/rendering/multithreading-mode", "SingleThreaded"); mode = fgGetString("/sim/rendering/multithreading-mode", "SingleThreaded");
SG_LOG( SG_VIEW, SG_INFO, "mode=" << mode); SG_LOG(SG_VIEW, SG_INFO, "mode=" << mode);
if (mode == "AutomaticSelection") if (mode == "AutomaticSelection")
viewer->setThreadingModel(osgViewer::Viewer::AutomaticSelection); viewer->setThreadingModel(osgViewer::Viewer::AutomaticSelection);
else if (mode == "CullDrawThreadPerContext") else if (mode == "CullDrawThreadPerContext")
@ -267,8 +249,7 @@ void fgOSOpenWindow(bool stencil)
// The viewer won't start without some root. // The viewer won't start without some root.
view->setSceneData(new osg::Group); view->setSceneData(new osg::Group);
globals->get_renderer()->setView(view); globals->get_renderer()->setView(view);
} } else {
else {
/* Not using CompositeViewer. */ /* Not using CompositeViewer. */
SG_LOG(SG_VIEW, SG_DEBUG, "Not CompositeViewer."); SG_LOG(SG_VIEW, SG_DEBUG, "Not CompositeViewer.");
SG_LOG(SG_VIEW, SG_DEBUG, "Creating osgViewer::Viewer"); SG_LOG(SG_VIEW, SG_DEBUG, "Creating osgViewer::Viewer");
@ -306,7 +287,7 @@ void fgOSOpenWindow(bool stencil)
globals->get_renderer()->setView(viewer.get()); globals->get_renderer()->setView(viewer.get());
} }
} }
SGPropertyNode* simHost = 0, *simFrameCount, *simTotalHostTime, *simFrameResetCount, *frameWait; SGPropertyNode *simHost = 0, *simFrameCount, *simTotalHostTime, *simFrameResetCount, *frameWait;
void fgOSResetProperties() void fgOSResetProperties()
{ {
SGPropertyNode* osgLevel = fgGetNode("/sim/rendering/osg-notify-level", true); SGPropertyNode* osgLevel = fgGetNode("/sim/rendering/osg-notify-level", true);
@ -327,16 +308,16 @@ void fgOSResetProperties()
fgSetInt("/sim/startup/ysize", guiViewport->height()); fgSetInt("/sim/startup/ysize", guiViewport->height());
} }
DisplaySettings * displaySettings = DisplaySettings::instance(); DisplaySettings* displaySettings = DisplaySettings::instance();
fgTie("/sim/rendering/osg-displaysettings/split-stereo-autoadjust-aspect-ratio", displaySettings, &DisplaySettings::getSplitStereoAutoAdjustAspectRatio, &DisplaySettings::setSplitStereoAutoAdjustAspectRatio ); fgTie("/sim/rendering/osg-displaysettings/split-stereo-autoadjust-aspect-ratio", displaySettings, &DisplaySettings::getSplitStereoAutoAdjustAspectRatio, &DisplaySettings::setSplitStereoAutoAdjustAspectRatio);
fgTie("/sim/rendering/osg-displaysettings/eye-separation", displaySettings, &DisplaySettings::getEyeSeparation, &DisplaySettings::setEyeSeparation ); fgTie("/sim/rendering/osg-displaysettings/eye-separation", displaySettings, &DisplaySettings::getEyeSeparation, &DisplaySettings::setEyeSeparation);
fgTie("/sim/rendering/osg-displaysettings/screen-distance", displaySettings, &DisplaySettings::getScreenDistance, &DisplaySettings::setScreenDistance ); fgTie("/sim/rendering/osg-displaysettings/screen-distance", displaySettings, &DisplaySettings::getScreenDistance, &DisplaySettings::setScreenDistance);
fgTie("/sim/rendering/osg-displaysettings/screen-width", displaySettings, &DisplaySettings::getScreenWidth, &DisplaySettings::setScreenWidth ); fgTie("/sim/rendering/osg-displaysettings/screen-width", displaySettings, &DisplaySettings::getScreenWidth, &DisplaySettings::setScreenWidth);
fgTie("/sim/rendering/osg-displaysettings/screen-height", displaySettings, &DisplaySettings::getScreenHeight, &DisplaySettings::setScreenHeight ); fgTie("/sim/rendering/osg-displaysettings/screen-height", displaySettings, &DisplaySettings::getScreenHeight, &DisplaySettings::setScreenHeight);
fgTie("/sim/rendering/osg-displaysettings/stereo-mode", getStereoMode, setStereoMode ); fgTie("/sim/rendering/osg-displaysettings/stereo-mode", getStereoMode, setStereoMode);
fgTie("/sim/rendering/osg-displaysettings/double-buffer", displaySettings, &DisplaySettings::getDoubleBuffer, &DisplaySettings::setDoubleBuffer ); fgTie("/sim/rendering/osg-displaysettings/double-buffer", displaySettings, &DisplaySettings::getDoubleBuffer, &DisplaySettings::setDoubleBuffer);
fgTie("/sim/rendering/osg-displaysettings/depth-buffer", displaySettings, &DisplaySettings::getDepthBuffer, &DisplaySettings::setDepthBuffer ); fgTie("/sim/rendering/osg-displaysettings/depth-buffer", displaySettings, &DisplaySettings::getDepthBuffer, &DisplaySettings::setDepthBuffer);
fgTie("/sim/rendering/osg-displaysettings/rgb", displaySettings, &DisplaySettings::getRGB, &DisplaySettings::setRGB ); fgTie("/sim/rendering/osg-displaysettings/rgb", displaySettings, &DisplaySettings::getRGB, &DisplaySettings::setRGB);
#ifdef ENABLE_OSGXR #ifdef ENABLE_OSGXR
fgSetBool("/sim/vr/built", true); fgSetBool("/sim/vr/built", true);
@ -364,23 +345,22 @@ SGTimeStamp _lastUpdate;
static void ShowAffinities() static void ShowAffinities()
{ {
#ifdef __linux__ #ifdef __linux__
char command[1024]; char command[1024];
snprintf( command, sizeof( command), "for i in `ls /proc/%i/task/`; do taskset -p $i; done 1>&2", getpid()); snprintf(command, sizeof(command), "for i in `ls /proc/%i/task/`; do taskset -p $i; done 1>&2", getpid());
SG_LOG(SG_VIEW, SG_ALERT, "Running: " << command); SG_LOG(SG_VIEW, SG_ALERT, "Running: " << command);
system( command); system(command);
#endif #endif
} }
#ifdef __linux__ #ifdef __linux__
static std::ostream& operator<< (std::ostream& out, const cpu_set_t& mask) static std::ostream& operator<<(std::ostream& out, const cpu_set_t& mask)
{ {
out << "0x"; out << "0x";
unsigned char* mask2 = (unsigned char*) &mask; unsigned char* mask2 = (unsigned char*)&mask;
for (unsigned i=0; i<sizeof(mask); ++i) for (unsigned i = 0; i < sizeof(mask); ++i) {
{
char buffer[8]; char buffer[8];
snprintf(buffer, sizeof(buffer), "%02x", (unsigned) mask2[i]); snprintf(buffer, sizeof(buffer), "%02x", (unsigned)mask2[i]);
out << buffer; out << buffer;
} }
return out; return out;
@ -396,85 +376,64 @@ value='clear' and 'revert':
'revert' 'revert'
Restores thread affinities stored from previous 'clear'. Restores thread affinities stored from previous 'clear'.
*/ */
struct AffinityControl : SGPropertyChangeListener struct AffinityControl : SGPropertyChangeListener {
{
AffinityControl() AffinityControl()
{ {
m_node = globals->get_props()->getNode( "/sim/affinity-control", true /*create*/); m_node = globals->get_props()->getNode("/sim/affinity-control", true /*create*/);
m_node->addChangeListener( this); m_node->addChangeListener(this);
} }
void valueChanged(SGPropertyNode* node) override void valueChanged(SGPropertyNode* node) override
{ {
#ifdef __linux__ #ifdef __linux__
std::string s = m_node->getStringValue(); std::string s = m_node->getStringValue();
if (s == m_state) if (s == m_state) {
{
SG_LOG(SG_VIEW, SG_ALERT, "Ignoring m_node=" << s << " because same as m_state."); SG_LOG(SG_VIEW, SG_ALERT, "Ignoring m_node=" << s << " because same as m_state.");
} } else if (s == "clear") {
else if (s == "clear")
{
char buffer[64]; char buffer[64];
snprintf(buffer, sizeof(buffer), "/proc/%i/task", getpid()); snprintf(buffer, sizeof(buffer), "/proc/%i/task", getpid());
SGPath path( buffer); SGPath path(buffer);
simgear::Dir dir( path); simgear::Dir dir(path);
m_thread_masks.clear(); m_thread_masks.clear();
simgear::PathList pids = dir.children( simgear::PathList pids = dir.children(
simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
); for (SGPath path : pids) {
for (SGPath path: pids)
{
std::string leaf = path.file(); std::string leaf = path.file();
int pid = atoi( leaf.c_str()); int pid = atoi(leaf.c_str());
cpu_set_t mask; cpu_set_t mask;
int e = sched_getaffinity( pid, sizeof(mask), &mask); int e = sched_getaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_getaffinity()" SG_LOG(SG_VIEW, SG_ALERT, "Called sched_getaffinity()"
<< " pid=" << pid << " pid=" << pid << " => e=" << e << " mask=" << mask);
<< " => e=" << e if (!e) {
<< " mask=" << mask m_thread_masks[pid] = mask;
);
if (!e)
{
m_thread_masks[ pid] = mask;
memset(&mask, 255, sizeof(mask)); memset(&mask, 255, sizeof(mask));
e = sched_setaffinity( pid, sizeof(mask), &mask); e = sched_setaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()" SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()"
<< " pid=" << pid << " pid=" << pid << " => e=" << e << " mask=" << mask);
<< " => e=" << e
<< " mask=" << mask
);
//assert(!e); //assert(!e);
} }
} }
m_state = s; m_state = s;
} } else if (s == "revert") {
else if (s == "revert") for (auto it : m_thread_masks) {
{
for (auto it: m_thread_masks)
{
pid_t pid = it.first; pid_t pid = it.first;
cpu_set_t mask = it.second; cpu_set_t mask = it.second;
int e = sched_setaffinity( pid, sizeof(mask), &mask); int e = sched_setaffinity(pid, sizeof(mask), &mask);
SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()" SG_LOG(SG_VIEW, SG_ALERT, "Called sched_setaffinity()"
<< " pid=" << pid << " pid=" << pid << " => e=" << e << " mask=" << mask);
<< " => e=" << e
<< " mask=" << mask
);
//assert(!e); //assert(!e);
} }
m_thread_masks.clear(); m_thread_masks.clear();
m_state = s; m_state = s;
} } else {
else
{
SG_LOG(SG_VIEW, SG_ALERT, "Unrecognised m_node=" << s); SG_LOG(SG_VIEW, SG_ALERT, "Unrecognised m_node=" << s);
} }
#endif #endif
} }
SGPropertyNode_ptr m_node; SGPropertyNode_ptr m_node;
std::string m_state; std::string m_state;
#ifdef __linux__ #ifdef __linux__
std::map<int, cpu_set_t> m_thread_masks; std::map<int, cpu_set_t> m_thread_masks;
#endif #endif
}; };
@ -487,13 +446,12 @@ int fgOSMainLoop()
viewer_base->realize(); viewer_base->realize();
std::string affinity = fgGetString("/sim/thread-cpu-affinity"); std::string affinity = fgGetString("/sim/thread-cpu-affinity");
SG_LOG(SG_VIEW, SG_ALERT, "affinity=" << affinity); SG_LOG(SG_VIEW, SG_ALERT, "affinity=" << affinity);
if (affinity != "") if (affinity != "") {
{
ShowAffinities(); ShowAffinities();
if (affinity == "osg") { if (affinity == "osg") {
SG_LOG(SG_VIEW, SG_ALERT, "Resetting affinity of current thread getpid()=" << getpid()); SG_LOG(SG_VIEW, SG_ALERT, "Resetting affinity of current thread getpid()=" << getpid());
OpenThreads::Affinity affinity; OpenThreads::Affinity affinity;
OpenThreads::SetProcessorAffinityOfCurrentThread( affinity); OpenThreads::SetProcessorAffinityOfCurrentThread(affinity);
ShowAffinities(); ShowAffinities();
} }
} }
@ -501,18 +459,14 @@ int fgOSMainLoop()
while (!viewer_base->done()) { while (!viewer_base->done()) {
fgIdleHandler idleFunc = globals->get_renderer()->getEventHandler()->getIdleHandler(); fgIdleHandler idleFunc = globals->get_renderer()->getEventHandler()->getIdleHandler();
if (idleFunc) if (idleFunc) {
{
_lastUpdate.stamp(); _lastUpdate.stamp();
(*idleFunc)(); (*idleFunc)();
if (fgGetBool("/sim/position-finalized", false)) if (fgGetBool("/sim/position-finalized", false)) {
{ if (simHost && simFrameCount && simTotalHostTime && simFrameResetCount) {
if (simHost && simFrameCount && simTotalHostTime && simFrameResetCount)
{
int curFrameCount = simFrameCount->getIntValue(); int curFrameCount = simFrameCount->getIntValue();
double totalSimTime = simTotalHostTime->getDoubleValue(); double totalSimTime = simTotalHostTime->getDoubleValue();
if (simFrameResetCount->getBoolValue()) if (simFrameResetCount->getBoolValue()) {
{
curFrameCount = 0; curFrameCount = 0;
totalSimTime = 0; totalSimTime = 0;
simFrameResetCount->setBoolValue(false); simFrameResetCount->setBoolValue(false);
@ -521,8 +475,7 @@ int fgOSMainLoop()
double idle_wait = 0; double idle_wait = 0;
if (frameWait) if (frameWait)
idle_wait = frameWait->getDoubleValue(); idle_wait = frameWait->getDoubleValue();
if (lastSimFrame_ms > 0) if (lastSimFrame_ms > 0) {
{
totalSimTime += lastSimFrame_ms - idle_wait; totalSimTime += lastSimFrame_ms - idle_wait;
simTotalHostTime->setDoubleValue(totalSimTime); simTotalHostTime->setDoubleValue(totalSimTime);
curFrameCount++; curFrameCount++;
@ -536,7 +489,7 @@ int fgOSMainLoop()
#ifdef ENABLE_OSGXR #ifdef ENABLE_OSGXR
VRManager::instance()->update(); VRManager::instance()->update();
#endif #endif
viewer_base->frame( globals->get_sim_time_sec() ); viewer_base->frame(globals->get_sim_time_sec());
} }
flightgear::addSentryBreadcrumb("main loop exited", "info"); flightgear::addSentryBreadcrumb("main loop exited", "info");
@ -607,9 +560,8 @@ void fgOSFullScreen()
* The other windows should use fixed setup from the camera.xml file anyway. */ * The other windows should use fixed setup from the camera.xml file anyway. */
osgViewer::GraphicsWindow* window = windows[0]; osgViewer::GraphicsWindow* window = windows[0];
osg::GraphicsContext::WindowingSystemInterface *wsi = osg::GraphicsContext::getWindowingSystemInterface(); osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
if (wsi == NULL) if (wsi == NULL) {
{
SG_LOG(SG_VIEW, SG_ALERT, "ERROR: No WindowSystemInterface available. Cannot toggle window fullscreen."); SG_LOG(SG_VIEW, SG_ALERT, "ERROR: No WindowSystemInterface available. Cannot toggle window fullscreen.");
return; return;
} }
@ -637,11 +589,8 @@ void fgOSFullScreen()
//bool isFullScreen = x == 0 && y == 0 && width == (int)screenWidth && height == (int)screenHeight; //bool isFullScreen = x == 0 && y == 0 && width == (int)screenWidth && height == (int)screenHeight;
bool isFullScreen = !window->getWindowDecoration(); bool isFullScreen = !window->getWindowDecoration();
SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle (" SG_LOG(SG_VIEW, SG_DEBUG, "Toggling fullscreen. Previous window rectangle (" << x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen << ", number of screens: " << wsi->getNumScreens());
<< x << ", " << y << ") x (" << width << ", " << height << "), fullscreen: " << isFullScreen if (isFullScreen) {
<< ", number of screens: " << wsi->getNumScreens());
if (isFullScreen)
{
// limit x,y coordinates and window size to screen area // limit x,y coordinates and window size to screen area
if (previous_x + previous_width > (int)screenWidth) if (previous_x + previous_width > (int)screenWidth)
previous_x = 0; previous_x = 0;
@ -653,9 +602,7 @@ void fgOSFullScreen()
y = previous_y; y = previous_y;
width = previous_width; width = previous_width;
height = previous_height; height = previous_height;
} } else {
else
{
// remember previous setting // remember previous setting
previous_x = x; previous_x = x;
previous_y = y; previous_y = y;
@ -690,34 +637,34 @@ static void setMouseCursor(osgViewer::GraphicsWindow* gw, int cursor)
mouseCursor = osgViewer::GraphicsWindow::InheritCursor; mouseCursor = osgViewer::GraphicsWindow::InheritCursor;
if (cursor == MOUSE_CURSOR_NONE) if (cursor == MOUSE_CURSOR_NONE)
mouseCursor = osgViewer::GraphicsWindow::NoCursor; mouseCursor = osgViewer::GraphicsWindow::NoCursor;
else if(cursor == MOUSE_CURSOR_POINTER) else if (cursor == MOUSE_CURSOR_POINTER)
#ifdef SG_MAC #ifdef SG_MAC
// osgViewer-Cocoa lacks RightArrowCursor, use Left // osgViewer-Cocoa lacks RightArrowCursor, use Left
mouseCursor = osgViewer::GraphicsWindow::LeftArrowCursor; mouseCursor = osgViewer::GraphicsWindow::LeftArrowCursor;
#else #else
mouseCursor = osgViewer::GraphicsWindow::RightArrowCursor; mouseCursor = osgViewer::GraphicsWindow::RightArrowCursor;
#endif #endif
else if(cursor == MOUSE_CURSOR_WAIT) else if (cursor == MOUSE_CURSOR_WAIT)
mouseCursor = osgViewer::GraphicsWindow::WaitCursor; mouseCursor = osgViewer::GraphicsWindow::WaitCursor;
else if(cursor == MOUSE_CURSOR_CROSSHAIR) else if (cursor == MOUSE_CURSOR_CROSSHAIR)
mouseCursor = osgViewer::GraphicsWindow::CrosshairCursor; mouseCursor = osgViewer::GraphicsWindow::CrosshairCursor;
else if(cursor == MOUSE_CURSOR_LEFTRIGHT) else if (cursor == MOUSE_CURSOR_LEFTRIGHT)
mouseCursor = osgViewer::GraphicsWindow::LeftRightCursor; mouseCursor = osgViewer::GraphicsWindow::LeftRightCursor;
else if(cursor == MOUSE_CURSOR_TOPSIDE) else if (cursor == MOUSE_CURSOR_TOPSIDE)
mouseCursor = osgViewer::GraphicsWindow::TopSideCursor; mouseCursor = osgViewer::GraphicsWindow::TopSideCursor;
else if(cursor == MOUSE_CURSOR_BOTTOMSIDE) else if (cursor == MOUSE_CURSOR_BOTTOMSIDE)
mouseCursor = osgViewer::GraphicsWindow::BottomSideCursor; mouseCursor = osgViewer::GraphicsWindow::BottomSideCursor;
else if(cursor == MOUSE_CURSOR_LEFTSIDE) else if (cursor == MOUSE_CURSOR_LEFTSIDE)
mouseCursor = osgViewer::GraphicsWindow::LeftSideCursor; mouseCursor = osgViewer::GraphicsWindow::LeftSideCursor;
else if(cursor == MOUSE_CURSOR_RIGHTSIDE) else if (cursor == MOUSE_CURSOR_RIGHTSIDE)
mouseCursor = osgViewer::GraphicsWindow::RightSideCursor; mouseCursor = osgViewer::GraphicsWindow::RightSideCursor;
else if(cursor == MOUSE_CURSOR_TOPLEFT) else if (cursor == MOUSE_CURSOR_TOPLEFT)
mouseCursor = osgViewer::GraphicsWindow::TopLeftCorner; mouseCursor = osgViewer::GraphicsWindow::TopLeftCorner;
else if(cursor == MOUSE_CURSOR_TOPRIGHT) else if (cursor == MOUSE_CURSOR_TOPRIGHT)
mouseCursor = osgViewer::GraphicsWindow::TopRightCorner; mouseCursor = osgViewer::GraphicsWindow::TopRightCorner;
else if(cursor == MOUSE_CURSOR_BOTTOMLEFT) else if (cursor == MOUSE_CURSOR_BOTTOMLEFT)
mouseCursor = osgViewer::GraphicsWindow::BottomLeftCorner; mouseCursor = osgViewer::GraphicsWindow::BottomLeftCorner;
else if(cursor == MOUSE_CURSOR_BOTTOMRIGHT) else if (cursor == MOUSE_CURSOR_BOTTOMRIGHT)
mouseCursor = osgViewer::GraphicsWindow::BottomRightCorner; mouseCursor = osgViewer::GraphicsWindow::BottomRightCorner;
gw->setCursor(mouseCursor); gw->setCursor(mouseCursor);