Page 1 of 1

probleme about decalre CEGUI out of fuction!

Posted: Tue Mar 22, 2011 13:49
by belkacem
hello again !

i have question about CEGUI declare out of the function body ,

for example in CEGUI Example you see something like this

Code: Select all


bool function()
{
  CEGUI::Direct3D11Renderer &myrender = CEGUI::Direct3D11Renderer::bootstrapSystem   ( Device->Get_Device () , Device->Get_DeviceContext());         // declare inside the function

.....................
..............

WindowManager &wmgr= WindowManager::getSingleton();             //wmgr delare inside the function too

Window* myRoot = wmgr.createWindow( "DefaultWindow", "root" );         //myRoot delare inside the function also !
FrameWindow *F = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "Demo Window");            //FrameWindowr declare inside the function!
......................


}




So try Something like this

Code: Select all


Direct3D11Renderer &myrender ;
WindowManager &wmgr ;
Window* myRoot ;
FrameWindow *F ;
bool function()
{

myrender = CEGUI::Direct3D11Renderer::bootstrapSystem   ( Device->Get_Device () , Device->Get_DeviceContext());           //myrender delare inside the function !

.....................
..............

wmgr= WindowManager::getSingleton();             wmgr delare inside the function too !

 myRoot = wmgr.createWindow( "DefaultWindow", "root" );          myRoot delare inside the function also
F = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "Demo Window");           FrameWindowr delare inside the function!



i get this error

'myrender' : references must be initialized
'wmgr' : references must be initialized


but if i change the declaration like this

Direct3D11Renderermyrender ;
WindowManager wmgr ;
Window* myRoot ;
FrameWindow *F ;

i cant initialize at all

i hope that you revive my message , so please any help for this topic
thank you !

Re: probleme about decalre CEGUI out of fuction!

Posted: Tue Mar 22, 2011 14:14
by Kulik
I suggest you to read something about what references and pointers are and what are they used to. You obviously lack C++ skills (no offense intended) as this is a very easy problem to solve.

http://en.wikipedia.org/wiki/Reference_(C%2B%2B)

Re: probleme about decalre CEGUI out of fuction!

Posted: Wed Mar 23, 2011 06:45
by belkacem
thank you

i solved the problem like this

Code: Select all

typedef CEGUI::Direct3D11Renderer &myrender ;

bool function

{
myrender render =  CEGUI::Direct3D11Renderer::bootstrapSystem   ( Device->Get_Device () , Device->Get_DeviceContext());
}


everyday i see new thing in c++ ( wow it's aamzing language )

Re: probleme about decalre CEGUI out of fuction!

Posted: Wed Mar 23, 2011 07:49
by Kulik
Hehe, you will soon discover that this is not what you wanted :D but it's best not to spoil the fun

You actually want pointers in this case IMO