Game Development Reference
In-Depth Information
conceivable message that the game views would want to see should be translated into
the generic message form and passed on to all the game views. The following is a code
fragment from GameCodeApp::MsgProc() , which is the main message handling call-
back that was set up with DXUTSetCallbackMsgProc( GameCodeApp::MsgProc ) :
switch (uMsg)
{
case WM_KEYDOWN:
case WM_KEYUP:
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
case MM_JOY1BUTTONDOWN:
case MM_JOY1BUTTONUP:
case MM_JOY1MOVE:
case MM_JOY1ZMOVE:
case MM_JOY2BUTTONDOWN:
case MM_JOY2BUTTONUP:
case MM_JOY2MOVE:
case MM_JOY2ZMOVE:
{
// translate the Windows message into the
'
generic
'
message.
AppMsg msg;
msg.m_hWnd = hWnd;
msg.m_uMsg = uMsg;
msg.m_wParam = wParam;
msg.m_lParam = lParam;
for ( GameViewList::reverse_iterator i=m_gameViews.rbegin();
i!=m_gameViews.rend(); ++i)
{
if ( (*i)->VOnMsgProc( msg ) )
{
return true;
}
}
}
break;
}
I completely admit that I
m cheating by taking the Windows message parameters and
sticking them into a structure. Call me lazy and unable to be truly platform agnostic;
I can live with that. It is a valuable exercise for you to generalize these messages into
'
Search WWH ::




Custom Search