probleme about decalre CEGUI out of fuction!

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

belkacem
Quite a regular
Quite a regular
Posts: 83
Joined: Fri Jan 07, 2011 13:55

probleme about decalre CEGUI out of fuction!

Postby belkacem » Tue Mar 22, 2011 13:49

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 !

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: probleme about decalre CEGUI out of fuction!

Postby Kulik » Tue Mar 22, 2011 14:14

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)

belkacem
Quite a regular
Quite a regular
Posts: 83
Joined: Fri Jan 07, 2011 13:55

Re: probleme about decalre CEGUI out of fuction!

Postby belkacem » Wed Mar 23, 2011 06:45

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 )

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: probleme about decalre CEGUI out of fuction!

Postby Kulik » Wed Mar 23, 2011 07:49

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


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests