-// Callback to prevent the GraphicsContext resized function from messing
-// with the projection matrix of the slave
-
-namespace
-{
-// silly function for making the default window and camera names
-std::string makeName(const string& prefix, int num)
-{
- std::stringstream stream;
- stream << prefix << num;
- return stream.str();
-}
-
-GraphicsContext::Traits*
-makeDefaultTraits(GraphicsContext::WindowingSystemInterface* wsi, bool stencil)
-{
- int w = fgGetInt("/sim/startup/xsize");
- int h = fgGetInt("/sim/startup/ysize");
- int bpp = fgGetInt("/sim/rendering/bits-per-pixel");
- bool alpha = fgGetBool("/sim/rendering/clouds3d-enable");
- bool fullscreen = fgGetBool("/sim/startup/fullscreen");
-
- GraphicsContext::Traits* traits = new osg::GraphicsContext::Traits;
- traits->readDISPLAY();
- int cbits = (bpp <= 16) ? 5 : 8;
- int zbits = (bpp <= 16) ? 16 : 24;
- traits->red = traits->green = traits->blue = cbits;
- traits->depth = zbits;
- if (alpha)
- traits->alpha = 8;
- if (stencil)
- traits->stencil = 8;
- traits->doubleBuffer = true;
- traits->mipMapGeneration = true;
- traits->windowName = "FlightGear";
- // XXX should check per window too.
- traits->sampleBuffers = fgGetBool("/sim/rendering/multi-sample-buffers", traits->sampleBuffers);
- traits->samples = fgGetBool("/sim/rendering/multi-samples", traits->samples);
- traits->vsync = fgGetBool("/sim/rendering/vsync-enable", traits->vsync);
- if (fullscreen) {
- unsigned width = 0;
- unsigned height = 0;
- wsi->getScreenResolution(*traits, width, height);
- traits->windowDecoration = false;
- traits->width = width;
- traits->height = height;
- traits->supportsResize = false;
- } else {
- traits->windowDecoration = true;
- traits->width = w;
- traits->height = h;
-#if defined(WIN32) || defined(__APPLE__)
- // Ugly Hack, why does CW_USEDEFAULT works like phase of the moon?
- // Mac also needs this to show window frame, menubar and Docks
- traits->x = 100;
- traits->y = 100;
-#endif
- traits->supportsResize = true;
- }
- return traits;
-}
-
-void setTraitsFromProperties(GraphicsContext::Traits* traits,
- const SGPropertyNode* winNode,
- GraphicsContext::WindowingSystemInterface* wsi)
-{
- traits->hostName
- = winNode->getStringValue("host-name", traits->hostName.c_str());
- traits->displayNum = winNode->getIntValue("display", traits->displayNum);
- traits->screenNum = winNode->getIntValue("screen", traits->screenNum);
- if (winNode->getBoolValue("fullscreen",
- fgGetBool("/sim/startup/fullscreen"))) {
- unsigned width = 0;
- unsigned height = 0;
- wsi->getScreenResolution(*traits, width, height);
- traits->windowDecoration = false;
- traits->width = width;
- traits->height = height;
- traits->supportsResize = false;
- } else {
- traits->windowDecoration = winNode->getBoolValue("decoration", true);
- traits->width = winNode->getIntValue("width", traits->width);
- traits->height = winNode->getIntValue("height", traits->height);
- traits->supportsResize = true;
- }
- traits->x = winNode->getIntValue("x", traits->x);
- traits->y = winNode->getIntValue("y", traits->y);
- if (winNode->hasChild("window-name"))
- traits->windowName = winNode->getStringValue("window-name");
- else if (winNode->hasChild("name"))
- traits->windowName = winNode->getStringValue("name");
-}
-
-} //namespace
-