State Manager
Ah got it...I think...
In onUpdate I put in:
irr::gui::IGUIImage* SplashScreenImage = gui->addImage( rect<s32>(0,0,800,600) );
SplashScreenImage->setImage(m_pSplashScreenTexture);
This avoids the onRender() addition I had made.
I'm a bit perplexed though as my frame rate dropped more than an order of magnitude from 150 fps with the draw2DImage call (below) vs about ~5 fps using the IGUIImage approach (above):
driver->draw2DImage(m_pSplashScreenTexture, SplashScreenCenterPosition, SplashScreenRect, NULL, SColor(m_Alpha, 255, 255, 255), true);
Am I missing something?
Thx!
In onUpdate I put in:
irr::gui::IGUIImage* SplashScreenImage = gui->addImage( rect<s32>(0,0,800,600) );
SplashScreenImage->setImage(m_pSplashScreenTexture);
This avoids the onRender() addition I had made.
I'm a bit perplexed though as my frame rate dropped more than an order of magnitude from 150 fps with the draw2DImage call (below) vs about ~5 fps using the IGUIImage approach (above):
driver->draw2DImage(m_pSplashScreenTexture, SplashScreenCenterPosition, SplashScreenRect, NULL, SColor(m_Alpha, 255, 255, 255), true);
Am I missing something?
Thx!
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
This is bad because you add the same image every frame over and over again. Only do this once, in the OnEnter() method.lymantok wrote: In onUpdate I put in:Code: Select all
irr::gui::IGUIImage* SplashScreenImage = gui->addImage( rect<s32>(0,0,800,600) ); SplashScreenImage->setImage(m_pSplashScreenTexture);
"Whoops..."
Sorry for bumping an old topic but this seemed better than making a new topic.
I've been looking at this state machine and it seems to do what I need, however since I will have some top states (Login, Play, Exit) and in the play state you would have something like Chat and Build states depending on the GUI state, now a state manage would be perfect for this. But how would I go about doing this?
Would I use substates, or would I let my Play State instantiate a new State Manager instance (Just thought of this option like 5 minutes ago).
My next problem would be the ability to chat while you're building. So I need to run concurrent states. However input would not depending on a window being open, but a window being focused. (Imagine the user seeing the chat window with no transparancy and the build window with 30% transparancy, the chat window has focus and receives input, but the build window is still accessible quickly).
EDIT:
As always the people from the chat have helped me out seeing the answer to my problem (Thx FuzzYspo0N and Josie). The substate for both the chat and build window are internal states for those windows. the main state machine shouldn't be bothered, I can however use another state machine for the windows internally.
I've been looking at this state machine and it seems to do what I need, however since I will have some top states (Login, Play, Exit) and in the play state you would have something like Chat and Build states depending on the GUI state, now a state manage would be perfect for this. But how would I go about doing this?
Would I use substates, or would I let my Play State instantiate a new State Manager instance (Just thought of this option like 5 minutes ago).
My next problem would be the ability to chat while you're building. So I need to run concurrent states. However input would not depending on a window being open, but a window being focused. (Imagine the user seeing the chat window with no transparancy and the build window with 30% transparancy, the chat window has focus and receives input, but the build window is still accessible quickly).
EDIT:
As always the people from the chat have helped me out seeing the answer to my problem (Thx FuzzYspo0N and Josie). The substate for both the chat and build window are internal states for those windows. the main state machine shouldn't be bothered, I can however use another state machine for the windows internally.
if (msg.getRubbishFactor() > rubbishLimit) { ignorePost(); cout << how it should be done << "\n"; }
This is a picture of the state machine I use for my game based on Vitek's great code.
http://www.flickr.com/photos/22251599@N04/4620456386/
To me the navigation, research, chat, etc are all activities the user takes in the running state. The chat window for example might be in the background and be transparent while the user is conducting research, and come in/out of focus if the user is actively chatting.
Anyway, my $ 0.02.
http://www.flickr.com/photos/22251599@N04/4620456386/
To me the navigation, research, chat, etc are all activities the user takes in the running state. The chat window for example might be in the background and be transparent while the user is conducting research, and come in/out of focus if the user is actively chatting.
Anyway, my $ 0.02.
Bumping old topic :< Anyway, I found that nice state machine - it seems to be ok for my app. Anyway, when I try to port it to Irrlicht 1.7.1, there are few errors which I don't know how to fix:
I can fix few of them, but I need to fix ENUMs and "conversion". Can anyone help me?
Code: Select all
||=== OrangeCraft, Debug ===|
J:\OrangeCraft\game\main.cpp|4|warning: ignoring #pragma comment |
J:\OrangeCraft\game\main.cpp|132|warning: ignoring #pragma warning |
J:\OrangeCraft\game\main.cpp||In member function 'virtual void MyOptionsState::onEnter(MyGame*)':|
J:\OrangeCraft\game\main.cpp|346|error: conversion from 'const irr::core::dimension2d<unsigned int>' to non-scalar type 'irr::core::dimension2di' requested|
J:\OrangeCraft\game\main.cpp|411|error: conversion from 'irr::core::dimension2d<unsigned int>' to non-scalar type 'const irr::core::dimension2di' requested|
J:\OrangeCraft\game\main.cpp||In member function 'virtual bool MyOptionsState::onEvent(MyGame*, irr::SEvent)':|
J:\OrangeCraft\game\main.cpp|472|warning: enumeration value 'EET_MOUSE_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|472|warning: enumeration value 'EET_JOYSTICK_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|472|warning: enumeration value 'EET_LOG_TEXT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|472|warning: enumeration value 'EET_USER_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|472|warning: enumeration value 'EGUIET_FORCE_32_BIT' not handled in switch|
J:\OrangeCraft\game\main.cpp||In member function 'virtual void MyPausedState::onEnter(MyGame*)':|
J:\OrangeCraft\game\main.cpp|593|error: conversion from 'const irr::core::dimension2d<unsigned int>' to non-scalar type 'irr::core::dimension2di' requested|
J:\OrangeCraft\game\main.cpp||In member function 'virtual bool MyPausedState::onEvent(MyGame*, irr::SEvent)':|
J:\OrangeCraft\game\main.cpp|617|warning: enumeration value 'EET_MOUSE_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|617|warning: enumeration value 'EET_JOYSTICK_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|617|warning: enumeration value 'EET_LOG_TEXT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|617|warning: enumeration value 'EET_USER_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|617|warning: enumeration value 'EGUIET_FORCE_32_BIT' not handled in switch|
J:\OrangeCraft\game\main.cpp||In member function 'virtual bool MyRunningState::onEvent(MyGame*, irr::SEvent)':|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EET_GUI_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EET_MOUSE_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EET_JOYSTICK_INPUT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EET_LOG_TEXT_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EET_USER_EVENT' not handled in switch|
J:\OrangeCraft\game\main.cpp|645|warning: enumeration value 'EGUIET_FORCE_32_BIT' not handled in switch|
J:\OrangeCraft\game\main.cpp||In function 'int main(int, char**)':|
J:\OrangeCraft\game\main.cpp|703|error: conversion from 'const irr::core::dimension2d<unsigned int>' to non-scalar type 'irr::core::dimension2di' requested|
J:\OrangeCraft\game\main.cpp|714|error: no matching function for call to 'irr::scene::ISceneManager::addHillPlaneMesh(const char [8], irr::core::dimension2df, irr::core::dimension2di)'|
irrlicht\include\ISceneManager.h|933|note: candidates are: virtual irr::scene::IAnimatedMesh* irr::scene::ISceneManager::addHillPlaneMesh(const irr::io::path&, const irr::core::dimension2d<float>&, const irr::core::dimension2d<unsigned int>&, irr::video::SMaterial*, irr::f32, const irr::core::dimension2d<float>&, const irr::core::dimension2d<float>&)|
J:\OrangeCraft\game\main.cpp|743|error: cannot declare variable 'game' to be of abstract type 'MyGame'|
J:\OrangeCraft\game\main.cpp|137|note: because the following virtual functions are pure within 'MyGame':|
irrlicht\include\IEventReceiver.h|445|note: virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)|
||=== Build finished: 6 errors, 18 warnings ===|
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
@pz
your first errors of 'conversion' look like due to const incorrectness
i just glanced over it but it looks like your last one is from not giving the right params for the method you want to call.
EDIT: missed one, the very last error is you need to implement OnEvent(), which is inherited to your class. if you dont add an implementation ( even empty brackets should do ) you can not create instance of an abstract type. because you still have 'pure virtual' functions.
no one likes getting errors, i suggest you read this. your errors were due really just to not knowing the language. it should only take a few days to read through and get hang of it (
only took me a few days )
http://cplusplus.com/doc/tutorial/
your first errors of 'conversion' look like due to const incorrectness
i just glanced over it but it looks like your last one is from not giving the right params for the method you want to call.
EDIT: missed one, the very last error is you need to implement OnEvent(), which is inherited to your class. if you dont add an implementation ( even empty brackets should do ) you can not create instance of an abstract type. because you still have 'pure virtual' functions.
no one likes getting errors, i suggest you read this. your errors were due really just to not knowing the language. it should only take a few days to read through and get hang of it (
![Wink :wink:](./images/smilies/icon_wink.gif)
http://cplusplus.com/doc/tutorial/
Last edited by ChaiRuiPeng on Fri Mar 25, 2011 5:35 pm, edited 1 time in total.
ent1ty wrote: success is a matter of concentration and desire
at a cost measure in computer resourcesButler Lampson wrote: all problems in Computer Science can be solved by another level of indirection
![Wink ;)](./images/smilies/icon_wink.gif)
pzduniak:
For the errors regarding irr::core::dimension2di, you need to use irr::core::dimension2d<irr::u32> or irr::core::dimension2du (which is the same thing) instead.
As for this one:
Example:
- Josiah
For the errors regarding irr::core::dimension2di, you need to use irr::core::dimension2d<irr::u32> or irr::core::dimension2du (which is the same thing) instead.
As for this one:
IEventReceiver::OnEvent() is pure virtual, so it has to be overridden in derived classes. So, you need to declare and define a function with the same name and parameters as this, then it will work.J:\OrangeCraft\game\main.cpp|743|error: cannot declare variable 'game' to be of abstract type 'MyGame'|
J:\OrangeCraft\game\main.cpp|137|note: because the following virtual functions are pure within 'MyGame':|
irrlicht\include\IEventReceiver.h|445|note: virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)|
Example:
Code: Select all
bool MyGame::OnEvent(const irr::SEvent& event)
{
doSomething();
}
- Josiah
-
- Posts: 6
- Joined: Wed Feb 06, 2013 9:10 am
- Location: UK
Re: State Manager
There seems to be a problem with the statte manager code and irrlicht 1.8.
In the class:
//calling this
does not work because i cannot instantiate an abstract class, which irr::IEventReceiver is
and Class MyGame is not.
I have tried to come up with a solution to avoid this but without any success.
Anyone still using this and has a solution it would be appreciated.
In the class:
Code: Select all
class MyGame : public irr::IEventReceiver, public GraphT<MyGame, irr::SEvent>
Code: Select all
MyGame game(device);
and Class MyGame is not.
I have tried to come up with a solution to avoid this but without any success.
Anyone still using this and has a solution it would be appreciated.
pararealist now.
-
- Posts: 6
- Joined: Wed Feb 06, 2013 9:10 am
- Location: UK
Re: State Manager
Sorry, just saw this, eyes falling asleep.
IEventReceiver::OnEvent() is pure virtual, so it has to be overridden in derived classes. So, you need to declare and define a function with the same name and parameters as this, then it will work.
IEventReceiver::OnEvent() is pure virtual, so it has to be overridden in derived classes. So, you need to declare and define a function with the same name and parameters as this, then it will work.
Code: Select all
bool MyGame::OnEvent(const irr::SEvent& event)
{
doSomething();
}
pararealist now.