Move GUI init code to gui module.
This commit is contained in:
parent
e5b81a8bb6
commit
dac8706e2e
3 changed files with 78 additions and 81 deletions
|
@ -44,6 +44,7 @@
|
||||||
#include <Main/locale.hxx>
|
#include <Main/locale.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <Viewer/WindowSystemAdapter.hxx>
|
#include <Viewer/WindowSystemAdapter.hxx>
|
||||||
|
#include <Viewer/CameraGroup.hxx>
|
||||||
#include <GUI/new_gui.hxx>
|
#include <GUI/new_gui.hxx>
|
||||||
#include <GUI/FGFontCache.hxx>
|
#include <GUI/FGFontCache.hxx>
|
||||||
|
|
||||||
|
@ -97,24 +98,81 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Operation for querying OpenGL parameters. This must be done in a
|
||||||
|
// valid OpenGL context, potentially in another thread.
|
||||||
|
|
||||||
|
struct GeneralInitOperation : public GraphicsContextOperation
|
||||||
|
{
|
||||||
|
GeneralInitOperation()
|
||||||
|
: GraphicsContextOperation(std::string("General init"))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void run(osg::GraphicsContext* gc)
|
||||||
|
{
|
||||||
|
SGPropertyNode* simRendering = fgGetNode("/sim/rendering");
|
||||||
|
|
||||||
|
simRendering->setStringValue("gl-vendor", (char*) glGetString(GL_VENDOR));
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VENDOR));
|
||||||
|
|
||||||
|
simRendering->setStringValue("gl-renderer", (char*) glGetString(GL_RENDERER));
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_RENDERER));
|
||||||
|
|
||||||
|
simRendering->setStringValue("gl-version", (char*) glGetString(GL_VERSION));
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VERSION));
|
||||||
|
|
||||||
|
simRendering->setStringValue("gl-shading-language-version", (char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
|
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
|
|
||||||
|
GLint tmp;
|
||||||
|
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tmp );
|
||||||
|
simRendering->setIntValue("max-texture-size", tmp);
|
||||||
|
|
||||||
|
glGetIntegerv( GL_DEPTH_BITS, &tmp );
|
||||||
|
simRendering->setIntValue("depth-buffer-bits", tmp);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
osg::ref_ptr<GUIInitOperation> initOp;
|
osg::ref_ptr<GUIInitOperation> initOp;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void guiStartInit(osg::GraphicsContext* gc)
|
/** Initializes GUI.
|
||||||
|
* Returns true when done, false when still busy (call again). */
|
||||||
|
bool guiInit()
|
||||||
{
|
{
|
||||||
if (gc) {
|
static osg::ref_ptr<GeneralInitOperation> genOp;
|
||||||
initOp = new GUIInitOperation;
|
|
||||||
gc->add(initOp.get());
|
if (!genOp.valid())
|
||||||
|
{
|
||||||
|
// Pick some window on which to do queries.
|
||||||
|
// XXX Perhaps all this graphics initialization code should be
|
||||||
|
// moved to renderer.cxx?
|
||||||
|
genOp = new GeneralInitOperation;
|
||||||
|
osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
|
||||||
|
WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
|
||||||
|
osg::GraphicsContext* gc = 0;
|
||||||
|
if (guiCamera)
|
||||||
|
gc = guiCamera->getGraphicsContext();
|
||||||
|
if (gc) {
|
||||||
|
gc->add(genOp.get());
|
||||||
|
initOp = new GUIInitOperation;
|
||||||
|
gc->add(initOp.get());
|
||||||
|
} else {
|
||||||
|
wsa->windows[0]->gc->add(genOp.get());
|
||||||
|
}
|
||||||
|
return false; // not ready yet
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!genOp->isFinished())
|
||||||
|
return false;
|
||||||
|
if (!initOp.valid())
|
||||||
|
return true;
|
||||||
|
if (!initOp->isFinished())
|
||||||
|
return false;
|
||||||
|
genOp = 0;
|
||||||
|
initOp = 0;
|
||||||
|
// we're done
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool guiFinishInit()
|
|
||||||
{
|
|
||||||
if (!initOp.valid())
|
|
||||||
return true;
|
|
||||||
if (!initOp->isFinished())
|
|
||||||
return false;
|
|
||||||
initOp = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ namespace osg
|
||||||
class GraphicsContext;
|
class GraphicsContext;
|
||||||
}
|
}
|
||||||
// gui.cxx
|
// gui.cxx
|
||||||
extern void guiStartInit(osg::GraphicsContext*);
|
extern bool guiInit();
|
||||||
extern bool guiFinishInit();
|
|
||||||
extern bool openBrowser(const std::string& address);
|
extern bool openBrowser(const std::string& address);
|
||||||
extern void mkDialog(const char *txt);
|
extern void mkDialog(const char *txt);
|
||||||
extern void guiErrorMessage(const char *txt);
|
extern void guiErrorMessage(const char *txt);
|
||||||
|
|
|
@ -55,8 +55,6 @@
|
||||||
#include <Sound/soundmanager.hxx>
|
#include <Sound/soundmanager.hxx>
|
||||||
#include <Time/TimeManager.hxx>
|
#include <Time/TimeManager.hxx>
|
||||||
#include <GUI/gui.h>
|
#include <GUI/gui.h>
|
||||||
#include <Viewer/CameraGroup.hxx>
|
|
||||||
#include <Viewer/WindowSystemAdapter.hxx>
|
|
||||||
#include <Viewer/splash.hxx>
|
#include <Viewer/splash.hxx>
|
||||||
#include <Viewer/renderer.hxx>
|
#include <Viewer/renderer.hxx>
|
||||||
#include <Navaids/NavDataCache.hxx>
|
#include <Navaids/NavDataCache.hxx>
|
||||||
|
@ -105,42 +103,6 @@ static void fgMainLoop( void )
|
||||||
SG_LOG( SG_GENERAL, SG_DEBUG, "" );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Operation for querying OpenGL parameters. This must be done in a
|
|
||||||
// valid OpenGL context, potentially in another thread.
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct GeneralInitOperation : public GraphicsContextOperation
|
|
||||||
{
|
|
||||||
GeneralInitOperation()
|
|
||||||
: GraphicsContextOperation(std::string("General init"))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
void run(osg::GraphicsContext* gc)
|
|
||||||
{
|
|
||||||
SGPropertyNode* simRendering = fgGetNode("/sim/rendering");
|
|
||||||
|
|
||||||
simRendering->setStringValue("gl-vendor", (char*) glGetString(GL_VENDOR));
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VENDOR));
|
|
||||||
|
|
||||||
simRendering->setStringValue("gl-renderer", (char*) glGetString(GL_RENDERER));
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_RENDERER));
|
|
||||||
|
|
||||||
simRendering->setStringValue("gl-version", (char*) glGetString(GL_VERSION));
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_VERSION));
|
|
||||||
|
|
||||||
simRendering->setStringValue("gl-shading-language-version", (char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
SG_LOG( SG_GENERAL, SG_INFO, glGetString(GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
|
|
||||||
GLint tmp;
|
|
||||||
glGetIntegerv( GL_MAX_TEXTURE_SIZE, &tmp );
|
|
||||||
simRendering->setIntValue("max-texture-size", tmp);
|
|
||||||
|
|
||||||
glGetIntegerv( GL_DEPTH_BITS, &tmp );
|
|
||||||
simRendering->setIntValue("depth-buffer-bits", tmp);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is the top level master main function that is registered as
|
// This is the top level master main function that is registered as
|
||||||
// our idle function
|
// our idle function
|
||||||
|
@ -155,34 +117,12 @@ static void fgIdleFunction ( void ) {
|
||||||
// splash screen up and running right away.
|
// splash screen up and running right away.
|
||||||
static int idle_state = 0;
|
static int idle_state = 0;
|
||||||
|
|
||||||
static osg::ref_ptr<GeneralInitOperation> genOp;
|
|
||||||
if ( idle_state == 0 ) {
|
if ( idle_state == 0 ) {
|
||||||
idle_state++;
|
if (guiInit())
|
||||||
// Pick some window on which to do queries.
|
{
|
||||||
// XXX Perhaps all this graphics initialization code should be
|
idle_state+=2;
|
||||||
// moved to renderer.cxx?
|
fgSplashProgress("loading-aircraft-list");
|
||||||
genOp = new GeneralInitOperation;
|
|
||||||
osg::Camera* guiCamera = getGUICamera(CameraGroup::getDefault());
|
|
||||||
WindowSystemAdapter* wsa = WindowSystemAdapter::getWSA();
|
|
||||||
osg::GraphicsContext* gc = 0;
|
|
||||||
if (guiCamera)
|
|
||||||
gc = guiCamera->getGraphicsContext();
|
|
||||||
if (gc) {
|
|
||||||
gc->add(genOp.get());
|
|
||||||
} else {
|
|
||||||
wsa->windows[0]->gc->add(genOp.get());
|
|
||||||
}
|
}
|
||||||
guiStartInit(gc);
|
|
||||||
} else if ( idle_state == 1 ) {
|
|
||||||
if (genOp.valid()) {
|
|
||||||
if (!genOp->isFinished())
|
|
||||||
return;
|
|
||||||
genOp = 0;
|
|
||||||
}
|
|
||||||
if (!guiFinishInit())
|
|
||||||
return;
|
|
||||||
idle_state++;
|
|
||||||
fgSplashProgress("loading-aircraft-list");
|
|
||||||
|
|
||||||
} else if ( idle_state == 2 ) {
|
} else if ( idle_state == 2 ) {
|
||||||
idle_state++;
|
idle_state++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue