Home > other >  Cegui 0.8.7 osg3.4.1 integration problems
Cegui 0.8.7 osg3.4.1 integration problems

Time:09-21

Now find the implementation of the code on the Internet, as long as the display osg model, that CEGUI window display not to come out, please help, thank you very much!!!!!!


The code is as follows:
The class CEGUIDrawable: public osg: : Drawable
{
Public:
CEGUIDrawable ();

META_Object (osg, CEGUIDrawable);

Void loadScheme (const STD: : string& Scheme);
Void loadFont (const STD: : string& The font);
Void loadLayout (const STD: : string& Layout);

Void drawImplementation (osg: : RenderInfo& RenderInfo) const;

Protected:

Virtual ~ CEGUIDrawable ();

Unsigned int _activeContextID;

Mutable double _lastSimulationTime;

};

CEGUIDrawable: : CEGUIDrawable ()
: _lastSimulationTime (0.0)
{
SetSupportsDisplayList (false);
SetDataVariance (osg: : Object: : DYNAMIC);
GetOrCreateStateSet () - & gt; SetMode (GL_LIGHTING, osg: : StateAttribute: : OFF);
GetOrCreateStateSet () - & gt; SetMode (GL_DEPTH_TEST, osg: : StateAttribute: : OFF);

CEGUI: : OpenGLRenderer& MyRenderer=CEGUI: : OpenGLRenderer: : create ();
MyRenderer. EnableExtraStateSettings (true);//must be set to make the font display


//setEventCallback (new CEGUIEventCallback ());
CEGUI: : System: : create (myRenderer);

_activeContextID=0;

CEGUI: : DefaultResourceProvider * rp=static_cast & lt; CEGUI: : DefaultResourceProvider * & gt; (CEGUI: : System: : getSingleton () getResourceProvider ());
The rp - & gt; SetResourceGroupDirectory (" schemes ", "datafiles/schemes");
The rp - & gt; SetResourceGroupDirectory (" imagesets ", "datafiles/imagesets");
The rp - & gt; SetResourceGroupDirectory (" fonts "and" datafiles/fonts ");
The rp - & gt; SetResourceGroupDirectory (" layouts ", "datafiles/layouts");
The rp - & gt; SetResourceGroupDirectory (" looknfeels ", "datafiles/looknfeel");
The rp - & gt; SetResourceGroupDirectory (" lua_scripts ", "datafiles/lua_scripts");
//This is only really men if you are using Xerces and the need to specify the schema location
The rp - & gt; SetResourceGroupDirectory (" schemas, "" datafiles/xml_schemas");
CEGUI: : ImageManager: : setImagesetDefaultResourceGroup (" imagesets ");
CEGUI: : the Font: : setDefaultResourceGroup (" fonts ");
CEGUI: : Scheme: : setDefaultResourceGroup (" schemes ");
CEGUI: : WidgetLookManager: : setDefaultResourceGroup (" looknfeels ");
CEGUI: : WindowManager: : setDefaultResourceGroup (" layouts ");
CEGUI: : ScriptModule: : setDefaultResourceGroup (" lua_scripts ");
CEGUI: : parser XMLParser *=CEGUI: : System: : getSingleton () getXMLParser ();
If (parser - & gt; SchemaDefaultResourceGroup isPropertyPresent (" "))
Parser - & gt; SetProperty (" SchemaDefaultResourceGroup ", "schemas");
}

CEGUIDrawable: : ~ CEGUIDrawable ()
{
}

Void CEGUIDrawable: : loadScheme (const STD: : string& Scheme)
{
Try {
CEGUI: : SchemeManager: : getSingleton () createFromFile (" TaharezLook. The scheme ");
CEGUI: : System: : getSingleton () getDefaultGUIContext () getMouseCursor () setDefaultImage (" TaharezLook/MouseArrow ");
} the catch (CEGUI: : Exception e) {
STD: : cout & lt; <"CEGUIDrawable: : loadScheme Error:" & lt; }
}

Void CEGUIDrawable: : loadFont (const STD: : string& The font)
{
Try {
CEGUI: : Font& DefaultFont=CEGUI: : FontManager: : getSingleton () createFromFile (" DejaVuSans - 10. The font ");
CEGUI: : System: : getSingleton () getDefaultGUIContext () setDefaultFont (& amp; DefaultFont);
} the catch (CEGUI: : Exception e) {
STD: : cout & lt; <"CEGUIDrawable: : loadFont Error:" & lt; }
}

Void CEGUIDrawable: : loadLayout (const STD: : string& Layout)
{
Try {

CEGUI: : WindowManager& WMGR=CEGUI: : WindowManager: : getSingleton ();
CEGUI: : Windows * myRoot=(CEGUI: : Windows *) WMGR. CreateWindow (" DefaultWindow ", "root");
CEGUI: : System: : getSingleton () getDefaultGUIContext () setRootWindow (myRoot);
CEGUI: : FrameWindow * fWnd=static_cast & lt; CEGUI: : FrameWindow * & gt; (WMGR. CreateWindow (" TaharezLook/FrameWindow ", "testWindow"));
MyRoot - & gt; AddChild (fWnd);
FWnd - & gt; SetPosition (CEGUI: : UVector2 (CEGUI: : UDim (0.25 f to 0.0 f), CEGUI: : UDim (0.25 f to 0.0 f)));
FWnd - & gt; SetSize (CEGUI: : USize (CEGUI: : UDim (0.5 f to 0.0 f), CEGUI: : UDim (0.5 f to 0.0 f)));
FWnd - & gt; SetText (" Hello World!" );

} the catch (CEGUI: : Exception e) {
STD: : cout & lt; <"CEGUIDrawable: : loadLayout error:" & lt; }

}

Void CEGUIDrawable: : drawImplementation (osg: : RenderInfo& Const renderInfo)
{
if (! CEGUI: : System: : getSingletonPtr ())
return;


Osg: : State * State=renderInfo. GetState ();
The state - & gt; DisableAllVertexArrays ();
The state - & gt; DisableTexCoordPointer (0);

GlPushMatrix ();
GlPushAttrib (GL_ALL_ATTRIB_BITS);

CEGUI: : OpenGLRenderer * the renderer=static_cast & lt; CEGUI: : OpenGLRenderer * & gt; (
CEGUI: : System: : getSingleton () getRenderer ());
Osg: : Viewport. * Viewport=renderInfo getCurrentCamera () - & gt; GetViewport ();
If (the renderer & amp; nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related