|
WM_TIMER is a very low priority message, WM_IDLE is even lower priority. You will potentially have update problems if you use these messages. I would recommend using multimedia timers[^]. Multimedia timers operate as callbacks so you may need to implement some synchronization.
Best Wishes,
-David Delaune
|
|
|
|
|
hi David
i'm getting confused at that point whenever thinking on Timer mechanism. My 3D application should achieve a frame rate of at least 30 fps. What that means for each cycle frame takes almost 33.3 ms to (update+draw). What it means when i use 10ms as the time elapsed value if i use a Multimedia timer? It will call my callback every 10ms in where i put all my frame processing like updating entities, states, create new geometries or kill some and draw my scene etc. What happens if my updating and drawing is getting longer than 10 ms? or consider the other case what happens if i set 50 ms for timer period?..
using OnIdle time makes sense in that perspective. Since application main loop is consist of (Peeking Messages + Idle Processing) i'm not sure but i was just supposing that rest of the main loop time after handling messages would be happily used on Idle processing in which i put my updating and drawing code and this time is sufficent for all my needs.
would you please clarify that point?
..
thx for your reply,
lâ-edri.
|
|
|
|
|
atillaselem wrote:
It will call my callback every 10ms in where i put all my frame processing like updating entities, states, create new geometries or kill some and draw my scene etc. What happens if my updating and drawing is getting longer than 10 ms?
Use of synchronization objects should be able solve this problem. When your variables are being updated by the socket class you should lock access to them, perhaps with a spinlock.
atillaselem wrote: using OnIdle time makes sense in that perspective.
WM_IDLE has the lowest possible priority in the message que. You are not guaranteed to recieve this message at all. If your window is designed in such a way... in that the message que never reaches zero then your WindProc will never recieve a WM_IDLE message period. In fact a third party application using Send/PostMessage() could prevent your application from recieving WM_IDLE by continously posting/sending/broadcasting messages. In my opinion WM_IDLE cannot be reliably used for window updating/redrawing.
WM_TIMER is nearly the same in that it is also a low priority message. The only thing you can rely on with WM_TIMER is that your application will eventually get the message. Many other messages are higher priority and can potentially be inserted into the message que and processed ahead of the WM_TIMER. This can result in variable timer speed meaning that your update frequency will vary by a few milliseconds in a high volume messaging window.
Multimedia timers were designed for this very purpose where very accurate intervals were required.
Best Wishes,
-David Delaune
|
|
|
|
|
hi david,
i got the point with OnIdle
ok then what should i set as the multimedia timer period for a resonable 3D refresh rate? 10ms, 20ms..?
Is there a connection this timer period with drawing period?
It makes sense to me if UDP data coming from network is slower than drawing frame period. i mean UDP rate is 20 ms. if it was coming with 100ms rate then timer period would be ok but what now..
so that means i will store every packet in a queue and fetch them one by one with a rate of Timer frequency? Hmm.. That seems ok to me.
but i did not still understand relation between timer period and frame rate. Infact frame rate depends on geometry budget of gpu.
would you pls clarify this point if you know..
regards
|
|
|
|
|
It seems that you have alot of architectural decisions to make. I don't know enough about your specific requirements to give you a specific direction. Here are some of my thoughts on the subject.
I can say that most 3D applications will render the scene as fast as possible and do not care about how fast or slow the datagrams are arriving. If some of the 3D spacial information is missing many applications use a copy of the last known coordinate + direction/speed etcetera. Also keep in mind that UDP datagrams may be received out of sequence if passing through multiple routers over a WAN. Which means if the server sends packet 1 then packet 2... You may recieve packet 2 before packet 1. TCP does not suffer from this limitation but requires much more overhead as you well know.
Its really your choice if you want to limit frame rate and remain synchronous with the data update rate. Some simulators can be implemented this way if they require the spacial data to be exactly as the motion estimators. If you have such a requirement then you can use the CreateEvent[^], OpenEvent[^] and SetEvent[^] to inform the scene renderer when data arrival has completed and it can safely render the next frame.
The choice is yours if you want frame rate to depend on UDP network speed.
Hope it helps,
-David Delaune
|
|
|
|
|
atillaselem wrote: ok then what should i set as the multimedia timer period for a resonable 3D refresh rate? 10ms, 20ms..?
Is there a connection this timer period with drawing period?
a 10 ms timer period with a 20ms updating+drawing time do not makes sense to me
i still need the answer to that question?
if i understand the high level timing mechanism then synchronization is no problem. But i just want to grasp that point as clear as possible. Could you write your 3D frame loop and timing implementation and packet synchronization with frame loop in Pseudocode way?
thx.
|
|
|
|
|
Hi all,
I am trying to create a log file using notepad in MFC(C++) can you please guide me how start ?i mean how to create a log file and update timings everytime log file is created.
Thanks in advance,
Anitha
|
|
|
|
|
AnithaSubramani wrote: I am trying to create a log file using notepad in MFC(C++) can you please guide me how start ?
You mean you want to start notepad to create a file ? Why don't you create the file directly in your code? Why do you need notepad for that purpose?
AnithaSubramani wrote: update timings everytime log file is created.
What do you mean by 'timings' ?
|
|
|
|
|
AnithaSubramani wrote: I am trying to create a log file using notepad in MFC(C++) can you please guide me how start ?
I remember during my college days someone showing me this trick, but not sure how useful or how practical this will be...
http://support.microsoft.com/kb/260563[^]
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
My hello to everybody,
I made some dialog based application using MFC. When I start this application it asks my to input file name where to store results using simple CFileDialog. It give me a file name like:
CString OriginalFileName = dlg.GetPathName();
Now I want to create a second file with the same name, but different extention. For now I use the following sequence of command:
int dotposition = OriginalFileName.Find('.');
SecondOriginalFileName = OriginalFileName.Left(dotposition);
SecondOriginalFileName += _T(".fscn");
It works, but may be there is some other solution. Could you please help me?
Thanks
Igor
|
|
|
|
|
Member 1980999 wrote: It works, but may be there is some other solution. Could you please help me?
Use PathRenameExtension but this means you've got to link to shell lightweight library (shlwapi.dll and .lib) which is not that lightweight.
If you are linking to shlwapi for just this one function then I would recommend you don't. If your existing solution works fine then I would keep it.
Well if there are other functions that you are already using from this library then feel free to link to.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
|
I can see a huge problem with your current solution...
What if...
c:\myproject v3.10\somefile.myext
(I use .'s in my directory names quite liberally)
You idea is fine if you search backwards though!
OR...
The filename comes from a CFileDialog. This has a GetFileExtension method [*], so you know just how characters you need to chop off the end. Whether it includes the '.' or not, I can't remember. But it should be easy to find out for yourself.
Iain.
[*] from memory - look up docs for exact name.
|
|
|
|
|
If you know the extension, and you know that the sequence of letters do not appear in the filename, you can use CString::Replace() . A better solution is to just use PathRenameExtension() .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Thank you very much. I already implemented PathRenameExtention() in my program.
|
|
|
|
|
Hi.
I'm writing an app which can show more instances of 'CMyDlg' class.
void CMainFrame::OnSomething()
{
CMyDlg *m_Dlg = new CMyDlg();
...
m_Dlg->Create(...);
m_Dlg->ShowWindow(...);
m_DlgPtr.AddHead(m_Dlg);
}
When App is about to close I clean out CPtrList:
void CMainFrame::OnClose()
{
POSITION pos = m_DlgPtr.GetTailPosition();
while(pos != NULL)
{
CMyDlg *m_Dlg = (CMyDlg *)m_DlgPtr.GetPrev(pos);
m_Dlg->CloseWindow();
delete m_Dlg;
}
CFrameWnd::OnClose();
}
When user closes the dialog manually (on cancel), I was thinking to send message to main frame on which I'll find appropriate dialog pointer among m_DlgPtr and delete it. My concern is how to send pointer trough message?
void CGrafQueueDlg::OnCancel()
{
...
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd( );
pMainFrame->PostMessage(WM_DLG_CLOSE,?,?);
CDialog::OnCancel();
}
Thanks in advance.
|
|
|
|
|
josip cagalj wrote: m_DlgPtr.AddHead(m_Dlg);//add to CPtrList member
Instead of adding the dialog pointer add m_hWnd member since sometimes there can be a mismatch between windows pointers and internal handles. For eg: CWnd::FromHandle can just create a temporary CWnd for wrapping around a window handle.
A better option will be to keep a map, look ups will be faster. As a key let every dialog create a unique index for itself and map this to the window handle.
josip cagalj wrote: pMainFrame->PostMessage(WM_DLG_CLOSE,?,?);//how to pass pointer to this?
You can pass window handle in WPARAM or LPARAM parameter of ::PostMessage.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
Thanks for yours replay.
You mean I should use:
m_DlgPtr.AddHead(m_Dlg->m_hWnd);
and m_DlgPtr should be A map object. Did you mean CMapPtrToPtr?
Could you please provide some brief code as I did in my first post?
Thanks!
P.S.
Post message should be like this:
pMainFrame->PostMessage(WM_DLG_CLOSE,(UINT)this->m_hWnd,0);
?
|
|
|
|
|
Another option which I use myself is to pass the modeless dialog a pointer to itself. When the dialog is destroyed it nulls the pointer.
|
|
|
|
|
First and foremost, does it run?! If not, would it run on a 32-bit XP VM in VMWare server under 64-bit Vista?
I'm trying to avoid keeping a legacy machine to run older programs on...
TIA.
|
|
|
|
|
|
Hi Friends,
My program has a code which calculates time passed for a perticular opertion like
Total time = End time - Start time
Here I am using _ftime() function which says that it will provide me time since midnight (00:00:00), January 1, 1970, coordinated universal time (UTC).
Now my programs keeps running on a machine which uses Network Time Protocol. Here NTP is compatible of leap seconds adjustment.
I heard that leap second will be inserted on Dec 31 23:59:60(GMT).
Now will this break my above expression?
|
|
|
|
|
If extra time is added in between start and end, then the total time may be skewed.
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
hi to all,
i could find my local pc system IP Address and MAC Address by using gethostbyname().Now i want to find what are system connect in the Network and its MAC Address also IP Address. This is possible to get all system IP Address and MAC Address in VC++6.0.
can anyone help me.........
Regards
Muthukkumaran
|
|
|
|
|
See this link, maybe it can give you a starting point:
http://www.codeproject.com/KB/IP/enetstatasp.aspx[^]
I think it is not possible to get the MAC address of a remote computer thorough nothing more than its IP. As far as i know for example when a packet arrives at your ISP it will know that the IP addressed in that packet belongs to your modem's/computer's MAC address and will "relay" the packet to it, but on the other side of the ISP i doubt there is a way to ask the ISP what MAC address has been assigned to a certain IP address. It might be possible on a local network though.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|