compiling "The Main Menu" HOW-TO

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

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

compiling "The Main Menu" HOW-TO

Postby Yustme » Mon Jan 07, 2008 14:19

Hi,

I was trying an example which i found on the wiki page.

Link: http://www.cegui.org.uk/wiki/index.php/The_Main_Menu

But it generates me 32 errors. I've managed to fix 4 errors by simply using my ability to understand what i am reading :D

However, the remaining errors indicate that "things" have changed internally in the CEGUI engine.

So if anyone of the developers team could point me out the changes, that would be great!

The code:

Code: Select all

// CEGUI global declarations
IrrlichtRenderer* myRenderer = NULL;
WindowManager* Wmgr = NULL;
System* mGUISystem = NULL;
Window* myRoot = NULL;
// end CEGUI global declarations



Code: Select all

// initialize
void init()
{
myRenderer = new CEGUI::IrrlichtRenderer(device, true);
   Wmgr = WindowManager::getSingletonPtr();
   mGUISystem = System::getSingletonPtr();
   myRoot = Wmgr->getWindow("RootWindow"); // get default window

   /*** Stuff you need to do in the initialisation phase ***/
   FontManager::getSingletonPtr()->createFont("Tahoma-12.font");
   mGUISystem->setTooltip("TaharezLook/Tooltip");

   // Creating Imagesets and defining images
   Imageset* MenuImageset = ImagesetManager::getSingletonPtr()->createImagesetFromImageFile("Background","MenuBackground.jpg");
   Texture* texturePtr = System::getSingletonPtr()->getRenderer()->createTexture("MenuButtons.jpg");
   Imageset* ButtonsImageset = ImagesetManager::getSingletonPtr()->createImageset("Buttons", texturePtr);
   ButtonsImageset->defineImage("ButtonUp", Point(0.0f,0.0f), Size( 0.5f, 0.5f ), Point(0.0f,0.0f));
   ButtonsImageset->defineImage("ButtonDown", Point(0.0f,0.5f), Size( 0.5f, 0.5f ), Point(0.0f,0.0f));

   /*** the menu code ***/
   StaticImage* MenuBackground = (StaticImage*)Wmgr->createWindow("TaharezLook/StaticImage", "Background");
   myRoot->addChildWindow( MenuBackground );
   MenuBackground->setPosition( Point( 0.0f, 0.0f ) );
   MenuBackground->setSize( Size( 1.0f, 1.0f ) );  // full screen
   MenuBackground->setImage( MenuImageset, "full_image" );

   PushButton* NewGame = (PushButton*)Wmgr->createWindow("TaharezLook/Button", "NewGame");
   MenuBackground->addChildWindow( NewGame );
   NewGame->setPosition( Point( 0.2f, 0.2f ) );
   NewGame->setSize( Size( 0.4f, 0.2f ) );
   NewGame->setText("New Game");
   NewGame->setNormalImage( ButtonsImageset, "ButtonUp" ); 
   NewGame->setHoverImage( ButtonsImageset, "ButtonDown" );
   NewGame->setPushedImage( ButtonsImageset, "ButtonDown" );

   PushButton* LoadGame = (PushButton*)Wmgr->createWindow("TaharezLook/Button", "LoadGame");
   MenuBackground->addChildWindow( LoadGame );
   LoadGame->setPosition( Point( 0.2f, 0.45f ) );
   LoadGame->setSize( Size( 0.4f, 0.2f ) );
   LoadGame->setText("Load Game");
   LoadGame->setTooltipText("Disabled, not implemented yet");
   LoadGame->Disable();
   LoadGame->setNormalImage( ButtonsImageset, "ButtonUp" );
   LoadGame->setHoverImage( ButtonsImageset, "ButtonDown" );
   LoadGame->setPushedImage( ButtonsImageset, "ButtonDown" );
   LoadGame->setDisabledImage( ButtonsImageset, "ButtonDown" ); 

   PushButton* QuitGame= (PushButton*)Wmgr->createWindow("TaharezLook/Button", "QuitGame");
   MenuBackground->addChildWindow( QuitGame );
   QuitGame->setPosition( Point( 0.2f, 0.7f ) );
   QuitGame->setSize( Size( 0.4f, 0.2f ) );
   QuitGame->setText("Quit Game");
   QuitGame->setNormalImage( ButtonsImageset, "ButtonUp" );
   QuitGame->setHoverImage( ButtonsImageset, "ButtonDown" );
   QuitGame->setPushedImage( ButtonsImageset, "ButtonDown" );
}



The errors:

Code: Select all

1 error C2039: 'setTooltip' : is not a member of 'CEGUI::System'

2 error C2664: 'CEGUI::Texture *CEGUI::Renderer::createTexture(float)' : cannot convert parameter 1 from 'const char [16]' to 'float'

3 error C2065: 'StaticImage' : undeclared identifier

4 error C2065: 'MenuBackground' : undeclared identifier
   
5 error C2059: syntax error : ')'

6 error C2227: left of '->setPosition' must point to class/struct/union/generic type
   
7 error C2227: left of '->setSize' must point to class/struct/union/generic type

8 error C2227: left of '->setImage' must point to class/struct/union/generic type

9 error C2227: left of '->addChildWindow' must point to class/struct/union/generic type

10 error C2664: 'CEGUI::Window::setPosition' : cannot convert parameter 1 from 'CEGUI::Vector2' to 'const CEGUI::UVector2 &'
   
11 error C2664: 'CEGUI::Window::setSize' : cannot convert parameter 1 from 'CEGUI::Size' to 'const CEGUI::UVector2 &

12 error C2039: 'setNormalImage' : is not a member of 'CEGUI::PushButton'

13 error C2039: 'setHoverImage' : is not a member of 'CEGUI::PushButton'

14 error C2039: 'setPushedImage' : is not a member of 'CEGUI::PushButton'

15 error C2227: left of '->addChildWindow' must point to class/struct/union/generic type

16 error C2664: 'CEGUI::Window::setPosition' : cannot convert parameter 1 from 'CEGUI::Vector2' to 'const CEGUI::UVector2 &'   

17 error C2664: 'CEGUI::Window::setSize' : cannot convert parameter 1 from 'CEGUI::Size' to 'const CEGUI::UVector2 &'
   
18 error C2039: 'Disable' : is not a member of 'CEGUI::PushButton'

19 error C2039: 'setNormalImage' : is not a member of 'CEGUI::PushButton'
   
21 error C2039: 'setPushedImage' : is not a member of 'CEGUI::PushButton'
   
22 error C2039: 'setDisabledImage' : is not a member of 'CEGUI::PushButton'
   
23 error C2227: left of '->addChildWindow' must point to class/struct/union/generic type
   
24 error C2664: 'CEGUI::Window::setPosition' : cannot convert parameter 1 from 'CEGUI::Vector2' to 'const CEGUI::UVector2 &'

25 error C2664: 'CEGUI::Window::setSize' : cannot convert parameter 1 from 'CEGUI::Size' to 'const CEGUI::UVector2 &'   

26 error C2039: 'setNormalImage' : is not a member of 'CEGUI::PushButton'
   
27 error C2039: 'setHoverImage' : is not a member of 'CEGUI::PushButton'
   
28 error C2039: 'setPushedImage' : is not a member of 'CEGUI::PushButton'   




By the way, the last time this HOW-TO was updated was in December 2005.

Thanks in advance!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jan 07, 2008 14:40

Hi and welcome to the fun world of CEGUI :)

You are indeed correct that this article is rather out of date, this is the kind of thing that myself and the CEGUI developers are intending to address in the coming weeks and months.

If you want to have a go at updating the code yourself, then please make reference to the release notes / porting guide for CEGUI 0.5.x. If you do take this path, then please update the WIKI also, we would appreciate this help immensely.

If you can't work it out (or don't want to), I may be able to update that article later on this week - though make no promises.

CE.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Mon Jan 07, 2008 14:54

CrazyEddie wrote:Hi and welcome to the fun world of CEGUI :)

You are indeed correct that this article is rather out of date, this is the kind of thing that myself and the CEGUI developers are intending to address in the coming weeks and months.

If you want to have a go at updating the code yourself, then please make reference to the release notes / porting guide for CEGUI 0.5.x. If you do take this path, then please update the WIKI also, we would appreciate this help immensely.

If you can't work it out (or don't want to), I may be able to update that article later on this week - though make no promises.

CE.



Hi CrazyEddie,

Thank you for your reply and the kind words :D

I would love to contribute to the community. But my C++ skills are not that great yet and it would take me months to finally figure the CEGUI Engine out.

However, I will post my code I used for making the game menu once I got it finished :D

Is there any other example I could use for the menu? I'm just keeping it simple at the moment. A window with a few buttons and some text on it, that's it!

By the way, it just hit me. You're the maker of the engine CrazyEddieGUI (CEGUI).

Very nice work Eddie!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jan 07, 2008 15:15

Yes, I created CEGUI - thanks for the praise.

The sample code for CEGUI contains some hints, though unfortunately at the moment there is no specific example for an in-game menu.

In a more general sense, one of the best tutorials you could look at is Widget Galore by Rackle. It's quite large and possibly overwhelming at first sight, though does contain a wealth of useful and up-to-date information.

I think I might try and update that menu article in a minute :twisted:

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Mon Jan 07, 2008 15:28

CrazyEddie wrote:Yes, I created CEGUI - thanks for the praise.

The sample code for CEGUI contains some hints, though unfortunately at the moment there is no specific example for an in-game menu.

In a more general sense, one of the best tutorials you could look at is Widget Galore by Rackle. It's quite large and possibly overwhelming at first sight, though does contain a wealth of useful and up-to-date information.

I think I might try and update that menu article in a minute :twisted:



Hi CrazyEddie,

I think i have a minute :twisted:

Thanks :P

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Jan 07, 2008 15:36

Grr, I was typing a reply and when pressing the <preview> button I saw that CrazyEddie had just posted the same information I was going to give!

Here's what remains of my beautiful text:

Once you have the GUI on the screen you need to manage events. You can find examples within EventGalore, which also shows how to create a GUI via code.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Mon Jan 07, 2008 18:21

Hi guys,

First of al, lol @ Rackle :P

I've tried both samples. They both generate me run time errors. It's complaining about old dependencies of visual studio 2003.

Even though i have downloaded the: CEGUI 0.5.0b Binary Downloads for Microsoft Visual C++ 8 with its dependencies (3th link).

After finding and including the msvcr71d.dll it's complaining about another.

Any chance i can replace those dll's with the ones of mvc 8?

Thanks in advance!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Jan 07, 2008 18:38

Hi,

Sorry Rackle :)

Just a reply to say that I finished updating the Wiki page. I mainly just updated the CEGUI code and XML parts - some of the Ogre parts also need updating I think. I would have had it done sooner, but I got called away from the computer.

With regard to the dependency issue, I'm not sure what that is but have a vague recollection that it's my fault and has been discussed on the forum elsewhere (though I could be, and likely am, wrong!).

CE.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Mon Jan 07, 2008 20:15

CrazyEddie wrote:Hi,

Sorry Rackle :)

Just a reply to say that I finished updating the Wiki page. I mainly just updated the CEGUI code and XML parts - some of the Ogre parts also need updating I think. I would have had it done sooner, but I got called away from the computer.

With regard to the dependency issue, I'm not sure what that is but have a vague recollection that it's my fault and has been discussed on the forum elsewhere (though I could be, and likely am, wrong!).

CE.


Hi CrazyEddie,

I've done a search before i posted about the dependencies. And you're right, it has been discussed before but with no solution (afaik).

I thought that this might be solved in the mean time.

Thank you very much for the update CE (if i may call you that :D )

YM.

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Mon Jan 07, 2008 20:40

Have a look at <CELayoutEditor> Detailed Build Steps for VS2003-5 (V1.5c) which also talks about building Cegui. This may be useful. If not then you need to build the dependencies from scratch, which is quite an ordeal at this time, but may soon become easier.

A final alternative may be to download Visual Studio 2005 Express. It does not allow you to create a setup.exe but the rest of the features are functional. I'm working on a Netbeans solution, but I'm not quite there yet. One feature I'm looking forward is the profiler.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Mon Jan 07, 2008 23:17

Rackle wrote:Have a look at <CELayoutEditor> Detailed Build Steps for VS2003-5 (V1.5c) which also talks about building Cegui. This may be useful. If not then you need to build the dependencies from scratch, which is quite an ordeal at this time, but may soon become easier.

A final alternative may be to download Visual Studio 2005 Express. It does not allow you to create a setup.exe but the rest of the features are functional. I'm working on a Netbeans solution, but I'm not quite there yet. One feature I'm looking forward is the profiler.


Hi Rackle,

I've managed to compile the code from the wiki page which was updated by CE.

It doesn't complain about any dll file or whatever. But it does generate me a very strange error at run time:

Unhandled exception at 0x003d3ad5 in IrrlichtANDNewton.exe: 0xC0000005:
Access violation reading location 0x00000000.

This error indicates that something isn't properly initialized.

It stops executing code at this line:

Code: Select all

IrrlichtRenderer* myRenderer = new CEGUI::IrrlichtRenderer(device, true);


And jumps to the new.cpp file (which isn't mine) and pointing to the line containing the keyword "while" in this peace of code:



Code: Select all

void *__CRTDECL operator new(size_t size) _THROW1(_STD bad_alloc)
{       // try to allocate size bytes
   void *p;
   while ((p = malloc(size)) == 0)
        if (_callnewh(size) == 0)
        {  // report no memory
            static const std::bad_alloc nomem;
            _RAISE(nomem);
        }

   return (p);
}


I kind of became an expert in solving these kind of errors. But i have never seen this one.

My hunch is that it has to do something with the irrlichtrenderer. I have looked in the class but i don't see anything wrong in it. But I can't see whats in the lib's and dll's of irrlichtrenderer.

Any idea's what this might cause it guys?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 08, 2008 09:24

Could you post a call-stack / stacktrace / backtrace (whichever is your preferred term for it).

Also, how are you initialising the Irrlicht system, could you post that code up to the call that creates the CEGUI renderer.

Thx

CE.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Tue Jan 08, 2008 10:52

Hi CE,

Thanks for your reply.

This is the Call Stack content:

IrrlichtRenderer.dll!003d3ad5()

[Frames below may be incorrect and/or missing, no symbols loaded for IrrlichtRenderer.dll]

>msvcr80.dll!operator new(unsigned int size=15235208) Line 59 + 0x8 bytes C++

game.exe!main(int argc=1, char * * argv=0x00de9db8) Line 157 + 0x39 bytes C++

game.exe!__tmainCRTStartup() Line 597 + 0x17 bytes C

kernel32.dll!7c816ff7()

Irrlicht.dll!inflate(z_stream_s * strm=0x00350036, int flush=3473465) Line 958 + 0x13 bytes C

Irrlicht.dll!irr::io::CNumbersAttribute::setRect(irr::core::rect<int> value={...}) Line 897 + 0x1c bytes C++

44d9eed9()


This is the code for initializing the irrlicht system:

Code: Select all

// irrlicht global declarations
IrrlichtDevice* device = NULL;
video::IVideoDriver* driver = NULL;
scene::ISceneManager* smgr = NULL;



Code: Select all

// in the main():
device = createDevice(EDT_OPENGL, dimension2d<s32>(800,600), 32, false, false, true, &rv);
driver = device->getVideoDriver();
smgr = device->getSceneManager();

IrrlichtRenderer* myRenderer = new CEGUI::IrrlichtRenderer(device, true);
winMgr = WindowManager::getSingletonPtr();
mGUISystem = System::getSingletonPtr();
myRoot = winMgr->getWindow("RootWindow"); // get default window
// the rest of the CEGUI system...


Thanks in advance!

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Jan 08, 2008 12:54

I've got no ideas as yet.

Now some rambling to help clarify thought...

The call stack shows that 'operator new' call from main() being the source of the issue, which means it's failing on allocation of memory for the object itself as opposed to initialisation of some internal part of the object. This might indicate some issues relating to heaps and such, though I'm not entirely convinced.

Are all components (all dependent libs, CEGUI, and your app) linked against the same runtime (such as Multithreaded debug dll, or whatever)? I'm thinking this may actually be linked to your other issue relating to runtime dlls TBH.

Yustme
Just popping in
Just popping in
Posts: 11
Joined: Sat Jan 05, 2008 23:03

Postby Yustme » Tue Jan 08, 2008 13:32

Hi CE,

It does indeed have to do with the allocation.

I'll tell you what libs are loaded and which paths are included.

First of all, the Runtime Library option is set on: Multi-threaded DLL (/MD)

The paths I have included for CEGUI are:

D:\CEGUI-SDK-0.5.0b-vc8\include,
D:\CEGUI-0.5.0b\CEGUI-0.5.0\Samples\common\include,
D:\CEGUI-0.5.0b\CEGUI-0.5.0\RendererModules\IrrlichtRenderer



The path for including additional libraries in Linker/General/Additional Library Directories are:

D:\CEGUI-SDK-0.5.0b-vc8\lib


The libraries i have included in the option Linker/Input/Additional Dependencies:

CEGUIBase.lib IrrlichtRenderer.lib


It doesn't matter whether i use (for example) CEGUIBase.lib or CEGUIBase_d.lib (same go's for IrrlichtRenderer.lib). Both ways generate this runtime error for me.

The only difference is, if I use the debug version it doesn't take me to the file called new.cpp with a green arrow pointing to the line containing the "while" key word in it.

It just stays in the main file and pointing the green arrow to this line:

Code: Select all

IrrlichtRenderer* myRenderer = new CEGUI::IrrlichtRenderer(device, true);


I have only included info about the paths and libraries of CEGUI because everything else works fine.

Just for the record, i am using visual studio 2005 with (afaik) all critical updates and latest service pack.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 17 guests