Hello ,
I need to trap WM_TIMECHANGE event in ogre application.
As their is no direct support for this.
How can i trap this event in any ogre application
rgds,
Ritz
How to trap win32 event (WM_TIMECHANGE) in ogre
-
- Gnoblar
- Posts: 12
- Joined: Tue Nov 02, 2004 6:16 am
-
- Gnoblar
- Posts: 12
- Joined: Tue Nov 02, 2004 6:16 am
Trapping win32 event
Hello,
Thanks for reply.
Can any body please give me any code sample for the same.
rgds
Ritz
Thanks for reply.
Can any body please give me any code sample for the same.
rgds
Ritz
-
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
Or post it in the "Back to Basics" area ?
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Kobold
- Posts: 33
- Joined: Sun Apr 27, 2003 6:57 pm
- Location: New York, USA
Here is the 0.15 Root::startRendering loop:
However, nothing requires you to use this method. You can write your own, duplicating most of the logic and adding any of your own. I believe you can simply add an if statement like the following:
Not sure if that's what you're looking for. Hope it helps.
Edit:
Not sure how to handle this part of the code though.
//-----------------------------------------------------------------------
void Root::startRendering(void)
{
assert(mActiveRenderer != 0);
mActiveRenderer->_initRenderTargets();
// Clear event times
for(int i=0; i!=3; ++i)
mEventTimes.clear();
// Infinite loop, until broken out of by frame listeners
// or break out by calling queueEndRendering()
mQueuedEnd = false;
while( !mQueuedEnd )
{
#if OGRE_PLATFORM == PLATFORM_WIN32
// Pump events on Win32
MSG msg;
while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
#endif
if (!renderOneFrame())
break;
}
However, nothing requires you to use this method. You can write your own, duplicating most of the logic and adding any of your own. I believe you can simply add an if statement like the following:
MSG msg;
while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
if (msg.message == WM_TIMECHANGE)
{
; // anything you want here
}
}
Not sure if that's what you're looking for. Hope it helps.
Edit:
Not sure how to handle this part of the code though.
// Clear event times
for(int i=0; i!=3; ++i)
mEventTimes.clear();
Last edited by Silent on Sun Jan 30, 2005 1:06 am, edited 1 time in total.
-
- Hobgoblin
- Posts: 542
- Joined: Sun Jan 12, 2003 7:35 pm
- Location: Copenhagen, Denmark
-
- Kobold
- Posts: 33
- Joined: Sun Apr 27, 2003 6:57 pm
- Location: New York, USA
Sorry, I guess my intention wasn't clear. I was proposing that the new rendering loop be implemented in the App code, not by modifying Ogre. I consider the Ogre startRendering method to be a convenience routine, to be used or not used as you see fit.
As an aside, I think the goal in writing a good library is that it should stand on it's own without the need for modification. So I tend to look for solutions that don't rely on changes in the core Ogre code. Of course, if a change is really needed ...
As an aside, I think the goal in writing a good library is that it should stand on it's own without the need for modification. So I tend to look for solutions that don't rely on changes in the core Ogre code. Of course, if a change is really needed ...

-
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
The startRendering() method really is convenience!
If you don't call it, you are free make your own rendering loop.
No need to touch the Ogre core.
And the example framework is just an example. Feel free to do your own thing. And take a peek at meshviewer, Yake, etc. for hints on how to code.
If you don't call it, you are free make your own rendering loop.
No need to touch the Ogre core.
And the example framework is just an example. Feel free to do your own thing. And take a peek at meshviewer, Yake, etc. for hints on how to code.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
-
- Gnoblar
- Posts: 12
- Joined: Tue Nov 02, 2004 6:16 am
capturing WM_TIMECHANGE
Hello,
Thanks for responsind.
I tried using the first approach .
a) replacing startRendering method.
I am not able to undertand how do i replace the complete code of this methiod.
Can any body plese tell me siginificance of the code written above and after the loop.
I do not want to touch any default functionality except for catching WM_TIMECHANGE event.
Code for startRendering
------------------------------
assert(mActiveRenderer != 0);
mActiveRenderer->_initRenderTargets();
// Clear event times
for(int i=0; i!=3; ++i)
mEventTimes.clear();
// Infinite loop, until broken out of by frame listeners
// or break out by calling queueEndRendering()
mQueuedEnd = false;
while( !mQueuedEnd )
{
#if OGRE_PLATFORM == PLATFORM_WIN32
// Pump events on Win32
MSG msg;
while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
#endif
if (!renderOneFrame())
break;
}
Approach -2 ) hook to ogre render window message proc - Can i get more details about th eproc. where i can get this.
I am not able to reach to the windowproc in ogre code.
rgds,
Ritz
Thanks for responsind.
I tried using the first approach .
a) replacing startRendering method.
I am not able to undertand how do i replace the complete code of this methiod.
Can any body plese tell me siginificance of the code written above and after the loop.
I do not want to touch any default functionality except for catching WM_TIMECHANGE event.
Code for startRendering
------------------------------
assert(mActiveRenderer != 0);
mActiveRenderer->_initRenderTargets();
// Clear event times
for(int i=0; i!=3; ++i)
mEventTimes.clear();
// Infinite loop, until broken out of by frame listeners
// or break out by calling queueEndRendering()
mQueuedEnd = false;
while( !mQueuedEnd )
{
#if OGRE_PLATFORM == PLATFORM_WIN32
// Pump events on Win32
MSG msg;
while( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
#endif
if (!renderOneFrame())
break;
}
Approach -2 ) hook to ogre render window message proc - Can i get more details about th eproc. where i can get this.
I am not able to reach to the windowproc in ogre code.
rgds,
Ritz
-
- Gnoblar
- Posts: 12
- Joined: Tue Nov 02, 2004 6:16 am
Trapping WM_TIMECHANGE
Hello All,
Here is the Objective of doing ALL this
I am creating a Calender widget using CEGUI library.
I need to update the current date in the calender when ever user changes the date in the system.
In order to reflect the change i need a notification for the system date change in my widget.
Is their any other way to know about the date change.
Most important is i donot want to touch the nase ogre or CEGUI code.
rgds,
Ritz
Tried Approach - 2 Also.
--------------------------
I did tried trapping event in render window proc, i am able to trap it.
But again the issue is i do not want to touch the base code
----
LRESULT D3D7RenderWindow::WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
-----
Is their any way to do it so that the changes remain in my code onle.
Here is the Objective of doing ALL this
I am creating a Calender widget using CEGUI library.
I need to update the current date in the calender when ever user changes the date in the system.
In order to reflect the change i need a notification for the system date change in my widget.
Is their any other way to know about the date change.
Most important is i donot want to touch the nase ogre or CEGUI code.
rgds,
Ritz
Tried Approach - 2 Also.
--------------------------
I did tried trapping event in render window proc, i am able to trap it.
But again the issue is i do not want to touch the base code
----
LRESULT D3D7RenderWindow::WndProc(
HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
-----
Is their any way to do it so that the changes remain in my code onle.
-
- Kobold
- Posts: 33
- Joined: Sun Apr 27, 2003 6:57 pm
- Location: New York, USA
Here are some fragments from my own code (modified somewhat):Silent wrote:Sorry, I guess my intention wasn't clear. I was proposing that the new rendering loop be implemented in the App code, not by modifying Ogre. I consider the Ogre startRendering method to be a convenience routine, to be used or not used as you see fit.
Code: Select all
void Application::start()
{
if (setup())
startRendering(); // call our rendering loop, not Ogre's
}
void Application::startRendering()
{
renderSys->_initRenderTargets();
while (true) {
#ifdef WIN32
MSG msg;
while (PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
#endif
if (!root->renderOneFrame())
break;
}
}
I haven't rung out this section of code yet, in case someone spots any issues

Hope this helps.