How to define OpenGL camera movement using MFC OnKeyDown .?

Hello, I am doing real time movement of object using OpenGL. I have created OpenGL window using MFC framework. I want to implement MFC OnKeyDown() in order to rotate camera around an object. I have declared OnKeyDown() and incremented pitch, yaw, roll, dist for each keypress. I want to use that incremented value in the DrawWindow(), but its showing that m.pitch, m.yaw, m.roll, m.dist are undefined. Can somebody please suggest me an answer for this. Below is the Code… Can Somebody please help me with this. Thank You


void CubeWnd::OnkeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
    if (nChar = VK_LEFT)
    {
        m.pitch+=0.1f; 
    }
 
    if (nChar = VK_RIGHT)
    {
        m.yaw+=0.1f;
    }
    if(nChar= VK_TOP)
     {
       m.roll+=0.1f;
     }
      if(nChar= VK_BOTTOM)
     {
       m.dist+=0.1f;
     }
   DrawWindow();
}
 

void CubeWnd::OnPaint() 
{
    CPaintDC dc(this); // device context for painting
 
    dc.RealizePalette();
 
   // Make the HGLRC current.
   BOOL bResult = wglMakeCurrent (dc.m_hDC, m_hrc);
   if (!bResult)
   {
      TRACE("wglMakeCurrent Failed %x
", GetLastError() ) ;
   }
 
   // Draw.
   DrawWindow();
 
   // Swap buffers. 
   SwapBuffers(dc.m_hDC) ;
 
   wglMakeCurrent(NULL, NULL);
 
    // Do not call CWnd::OnPaint() for painting messages
}
 
 
void CubeWnd:DrawWindow()
{
    CRect space;
    GetClientRect(&space);
 
    // Clear the color and depth buffers
    glClearColor(.96,.96,.96,0) ;  //this sets the background color, (RGB, alpha)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
    //Move the camera back some so we get a good view of the sensors.
    glTranslatef(0,0,-m.dist);        // [b]here m.dist, m.pitch, m.yaw, m.roll are showing as "identifier is undefined"[/b]
    glRotatef(m.pitch, 1, 0, 0);
    glRotatef(m.yaw, 0, 1, 0);
    glRotatef(m.roll, 0, 0, 1);
 
    .........................
    
        
 
    }
 
}

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.